当前位置: 首页>>代码示例>>C++>>正文


C++ BSONElement::fieldNameSize方法代码示例

本文整理汇总了C++中BSONElement::fieldNameSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BSONElement::fieldNameSize方法的具体用法?C++ BSONElement::fieldNameSize怎么用?C++ BSONElement::fieldNameSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BSONElement的用法示例。


在下文中一共展示了BSONElement::fieldNameSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: documentFromBsonWithDeps

    Document DocumentSource::documentFromBsonWithDeps(const BSONObj& bson,
                                                      const ParsedDeps& neededFields) {
        MutableDocument md(neededFields.size());

        BSONObjIterator it(bson);
        while (it.more()) {
            BSONElement bsonElement (it.next());
            StringData fieldName (bsonElement.fieldName(), bsonElement.fieldNameSize()-1);
            Value isNeeded = neededFields[fieldName];

            if (isNeeded.missing())
                continue;

            if (isNeeded.getType() == Bool) {
                md.addField(fieldName, Value(bsonElement));
                continue;
            }

            dassert(isNeeded.getType() == Object);

            if (bsonElement.type() == Object) {
                Document sub = documentFromBsonWithDeps(bsonElement.embeddedObject(),
                                                        isNeeded.getDocument());
                md.addField(fieldName, Value(sub));
            }

            if (bsonElement.type() == Array) {
                md.addField(fieldName, arrayHelper(bsonElement.embeddedObject(),
                                                   isNeeded.getDocument()));
            }
        }

        return md.freeze();
    }
开发者ID:7segments,项目名称:mongo,代码行数:34,代码来源:document_source.cpp

示例2: isValidSortOrder

 // static
 bool LiteParsedQuery::isValidSortOrder(const BSONObj& sortObj) {
     BSONObjIterator i(sortObj);
     while (i.more()) {
         BSONElement e = i.next();
         // fieldNameSize() includes NULL terminator. For empty field name,
         // we should be checking for 1 instead of 0.
         if (1 == e.fieldNameSize()) {
             return false;
         }
         if (isTextScoreMeta(e)) {
             continue;
         }
         long long n = e.safeNumberLong();
         if (!(e.isNumber() && (n == -1LL || n == 1LL))) {
             return false;
         }
     }
     return true;
 }
开发者ID:AshishThakur,项目名称:mongo,代码行数:20,代码来源:lite_parsed_query.cpp

示例3: recursiveHash

    void BSONElementHasher::recursiveHash( Hasher* h ,
                                           const BSONElement& e ,
                                           bool includeFieldName ) {

        int canonicalType = e.canonicalType();
        h->addData( &canonicalType , sizeof( canonicalType ) );

        if ( includeFieldName ){
            h->addData( e.fieldName() , e.fieldNameSize() );
        }

        if ( !e.mayEncapsulate() ){
            //if there are no embedded objects (subobjects or arrays),
            //compute the hash, squashing numeric types to 64-bit ints
            if ( e.isNumber() ){
                long long int i = e.safeNumberLong(); //well-defined for troublesome doubles
                h->addData( &i , sizeof( i ) );
            }
            else {
                h->addData( e.value() , e.valuesize() );
            }
        }
        else {
            //else identify the subobject.
            //hash any preceding stuff (in the case of codeWscope)
            //then each sub-element
            //then finish with the EOO element.
            BSONObj b;
            if ( e.type() == CodeWScope ) {
                h->addData( e.codeWScopeCode() , e.codeWScopeCodeLen() );
                b = e.codeWScopeObject();
            }
            else {
                b = e.embeddedObject();
            }
            BSONObjIterator i(b);
            while( i.moreWithEOO() ) {
                BSONElement el = i.next();
                recursiveHash( h , el ,  true );
            }
        }
    }
开发者ID:10genReviews,项目名称:mongo,代码行数:42,代码来源:hasher.cpp


注:本文中的BSONElement::fieldNameSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。