diff options
author | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-13 18:22:09 +0000 |
---|---|---|
committer | djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-13 18:22:09 +0000 |
commit | b2c16472f6ebb134f46d63af2265b9d741f5748e (patch) | |
tree | 41643b05f09c0dcd559c8c44f7531b248f9a1792 /third_party/bson_c/src/encoding.h | |
parent | aba0e3b6bc91ae6b95bca2325933c5893070ac99 (diff) |
Add BSON implementation to third_party
Review URL: https://codereview.appspot.com/6267044
git-svn-id: http://skia.googlecode.com/svn/trunk@4252 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'third_party/bson_c/src/encoding.h')
-rw-r--r-- | third_party/bson_c/src/encoding.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/third_party/bson_c/src/encoding.h b/third_party/bson_c/src/encoding.h new file mode 100644 index 0000000000..86d5e8ea9a --- /dev/null +++ b/third_party/bson_c/src/encoding.h @@ -0,0 +1,54 @@ +/* + * Copyright 2009-2011 10gen, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_ENCODING_H_ +#define BSON_ENCODING_H_ + +MONGO_EXTERN_C_START + +/** + * Check that a field name is valid UTF8, does not start with a '$', + * and contains no '.' characters. Set bson bit field appropriately. + * Note that we don't need to check for '\0' because we're using + * strlen(3), which stops at '\0'. + * + * @param b The bson object to which field name will be appended. + * @param string The field name as char*. + * @param length The length of the field name. + * + * @return BSON_OK if valid UTF8 and BSON_ERROR if not. All BSON strings must be + * valid UTF8. This function will also check whether the string + * contains '.' or starts with '$', since the validity of this depends on context. + * Set the value of b->err appropriately. + */ +int bson_check_field_name( bson *b, const char *string, + const int length ); + +/** + * Check that a string is valid UTF8. Sets the buffer bit field appropriately. + * + * @param b The bson object to which string will be appended. + * @param string The string to check. + * @param length The length of the string. + * + * @return BSON_OK if valid UTF-8; otherwise, BSON_ERROR. + * Sets b->err on error. + */ +bson_bool_t bson_check_string( bson *b, const char *string, + const int length ); + +MONGO_EXTERN_C_END +#endif |