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


C++ intrusive_ptr::getType方法代码示例

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


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

示例1: addField

    void Document::addField(const string &fieldName,
			    const intrusive_ptr<const Value> &pValue) {
	assert(pValue->getType() != Undefined);

        vFieldName.push_back(fieldName);
        vpValue.push_back(pValue);
    }
开发者ID:meharris,项目名称:mongo,代码行数:7,代码来源:document.cpp

示例2: addField

    void Document::addField(const string &fieldName,
                            const intrusive_ptr<const Value> &pValue) {
        uassert(15945, str::stream() << "cannot add undefined field " <<
                fieldName << " to document", pValue->getType() != Undefined);

        vFieldName.push_back(fieldName);
        vpValue.push_back(pValue);
    }
开发者ID:Eric-Lu,项目名称:mongo,代码行数:8,代码来源:document.cpp

示例3: setField

    void Document::setField(size_t index,
                            const string &fieldName,
			    const intrusive_ptr<const Value> &pValue) {
	/* special case:  should this field be removed? */
	if (!pValue.get()) {
	    vFieldName.erase(vFieldName.begin() + index);
	    vpValue.erase(vpValue.begin() + index);
	    return;
	}

	/* make sure we have a valid value */
	assert(pValue->getType() != Undefined);

	/* set the indicated field */
        vFieldName[index] = fieldName;
        vpValue[index] = pValue;
    }
开发者ID:meharris,项目名称:mongo,代码行数:17,代码来源:document.cpp

示例4: compare

    int Value::compare(const intrusive_ptr<const Value> &rL,
                       const intrusive_ptr<const Value> &rR) {
        BSONType lType = rL->getType();
        BSONType rType = rR->getType();

        /*
          Special handling for Undefined and NULL values; these are types,
          so it's easier to handle them here before we go below to handle
          values of the same types.  This allows us to compare Undefined and
          NULL values with everything else.  As coded now:
          (*) Undefined is less than everything except itself (which is equal)
          (*) NULL is less than everything except Undefined and itself
         */
        if (lType == Undefined) {
            if (rType == Undefined)
                return 0;

            /* if rType is anything else, the left value is less */
            return -1;
        }
        
        if (lType == jstNULL) {
            if (rType == Undefined)
                return 1;
            if (rType == jstNULL)
                return 0;

            return -1;
        }

        if ((rType == Undefined) || (rType == jstNULL)) {
            /*
              We know the left value isn't Undefined, because of the above.
              Count a NULL value as greater than an undefined one.
            */
            return 1;
        }

        /* if the comparisons are numeric, prepare to promote the values */
        if (((lType == NumberDouble) || (lType == NumberLong) ||
             (lType == NumberInt)) &&
            ((rType == NumberDouble) || (rType == NumberLong) ||
             (rType == NumberInt))) {

            /* if the biggest type of either is a double, compare as doubles */
            if ((lType == NumberDouble) || (rType == NumberDouble)) {
                const double left = rL->getDouble();
                const double right = rR->getDouble();
                if (left < right)
                    return -1;
                if (left > right)
                    return 1;
                return 0;
            }

            /* if the biggest type of either is a long, compare as longs */
            if ((lType == NumberLong) || (rType == NumberLong)) {
                const long long left = rL->getLong();
                const long long right = rR->getLong();
                if (left < right)
                    return -1;
                if (left > right)
                    return 1;
                return 0;
            }

            /* if we got here, they must both be ints; compare as ints */
            {
                const int left = rL->getInt();
                const int right = rR->getInt();
                if (left < right)
                    return -1;
                if (left > right)
                    return 1;
                return 0;
            }
        }

        // CW TODO for now, only compare like values
        uassert(16016, str::stream() <<
                "can't compare values of BSON types " << typeName(lType) <<
                " and " << typeName(rType),
                lType == rType);

        switch(lType) {
        case NumberDouble:
        case NumberInt:
        case NumberLong:
            /* these types were handled above */
            verify(false);

        case String:
            return rL->stringValue.compare(rR->stringValue);

        case Object:
            return Document::compare(rL->getDocument(), rR->getDocument());

        case Array: {
            intrusive_ptr<ValueIterator> pli(rL->getArray());
            intrusive_ptr<ValueIterator> pri(rR->getArray());
//.........这里部分代码省略.........
开发者ID:milkie,项目名称:mongo,代码行数:101,代码来源:value.cpp


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