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


C++ Any::verifyType方法代码示例

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


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

示例1: toLower

Matrix4::Matrix4(const Any& any) {
    any.verifyName("Matrix4");
    any.verifyType(Any::ARRAY);

    const std::string& name = toLower(any.name());
    if (name == "matrix4") {
        any.verifySize(16);

        for (int r = 0; r < 4; ++r) {
            for (int c = 0; c < 4; ++c) {
                elt[r][c] = any[r * 4 + c];
            }
        }
    } else if (name == "matrix4::scale") {
        if (any.size() == 1) {
            *this = scale(any[0].number());
        } else if (any.size() == 3) {
            *this = scale(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::scale() takes either 1 or 3 arguments");
        }
    } else if (name == "matrix4::translation") {
        if (any.size() == 3) {
            *this = translation(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::translation() takes either 1 or 3 arguments");
        }    } else {
        any.verify(false, "Expected Matrix4 constructor");
    }
}
开发者ID:Akenyshka,项目名称:MythCore,代码行数:30,代码来源:Matrix4.cpp

示例2:

UprightFrame::UprightFrame(const Any& any) {
    any.verifyName("UprightFrame");
    any.verifyType(Any::TABLE);

    translation = any["translation"];
    pitch = any["pitch"];
    yaw = any["yaw"];
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:8,代码来源:UprightFrame.cpp

示例3: toUpper

CoordinateFrame::CoordinateFrame(const Any& any) {
    *this = CFrame();

    const std::string& n = toUpper(any.name());

    if (beginsWith(n, "VECTOR3")) {
        translation = any;
    } else if (beginsWith(n, "MATRIX3")) {
        rotation = any;
    } else if ((n == "CFRAME") || (n == "COORDINATEFRAME")) {
        any.verifyType(Any::TABLE, Any::ARRAY);
        if (any.type() == Any::ARRAY) {
            any.verifySize(2);
            rotation    = any[0];
            translation = any[1];
        } else {
            for (Any::AnyTable::Iterator it = any.table().begin(); it.hasMore(); ++it) {
                const std::string& n = toLower(it->key);
                if (n == "translation") {
                    translation = Vector3(it->value);
                } else if (n == "rotation") {
                    rotation = Matrix3(it->value);
                } else {
                    any.verify(false, "Illegal table key: " + it->key);
                }
            }
        }
    } else if (beginsWith(n, "PHYSICSFRAME") || beginsWith(n, "PFRAME")) {
        *this = PhysicsFrame(any);
    } else {
        any.verifyName("CFrame::fromXYZYPRDegrees", "CoordinateFrame::fromXYZYPRDegrees");
        any.verifyType(Any::ARRAY);
        any.verifySize(3, 6);

        int s = any.size();

        *this = fromXYZYPRDegrees(any[0], any[1], any[2],
                                  (s > 3) ? any[3].number() : 0.0f,
                                  (s > 4) ? any[4].number() : 0.0f,
                                  (s > 5) ? any[5].number() : 0.0f);
    }
}
开发者ID:Akenyshka,项目名称:MythCore,代码行数:42,代码来源:CoordinateFrame.cpp

示例4:

/** \param any Must either Rect2D::xywh(#, #, #, #) or Rect2D::xyxy(#, #, #, #)*/
Rect2D::Rect2D(const Any& any) {
    any.verifyName("Rect2D");
    any.verifyType(Any::ARRAY);
    any.verifySize(4);
    if (toUpper(any.name()) == "RECT2D::XYWH") {
        *this = Rect2D::xywh(any[0], any[1], any[2], any[3]);
    } else {
        any.verifyName("Rect2D::xyxy");
        *this = Rect2D::xyxy(any[0], any[1], any[2], any[3]);
    }
}
开发者ID:08keelr,项目名称:TrinityCore,代码行数:12,代码来源:Rect2D.cpp

示例5: r

CoordinateFrame::CoordinateFrame(const Any& any) {
    *this = CFrame();

    const String& n = toUpper(any.name());

    if (beginsWith(n, "VECTOR3") || beginsWith(n, "POINT3")) {
        translation = Point3(any);
    } else if (beginsWith(n, "MATRIX3")) {
        rotation = Matrix3(any);
    } else if (beginsWith(n, "MATRIX4")) {
        *this = Matrix4(any).approxCoordinateFrame();
    } else if ((n == "CFRAME") || (n == "COORDINATEFRAME")) {
        any.verifyType(Any::TABLE, Any::ARRAY);
        if (any.type() == Any::ARRAY) {
            any.verifySize(2);
            rotation    = any[0];
            translation = any[1];
        } else {
            AnyTableReader r(any);
            r.getIfPresent("translation", translation);
            r.getIfPresent("rotation", rotation);
            r.verifyDone();
        }
    } else if (beginsWith(n, "PHYSICSFRAME") || beginsWith(n, "PFRAME")) {
        *this = PhysicsFrame(any);
//    } else if (beginsWith(n, "UPRIGHTFRAME") || beginsWith(n, "UFRAME")) {
//        *this = UprightFrame(any);
    } else {
        any.verifyName("CFrame::fromXYZYPRDegrees", "CoordinateFrame::fromXYZYPRDegrees");
        any.verifyType(Any::ARRAY);
        any.verifySize(3, 6);

        int s = any.size();

        *this = fromXYZYPRDegrees(any[0], any[1], any[2], 
                                  (s > 3) ? (float)any[3].number() : 0.0f,
                                  (s > 4) ? (float)any[4].number() : 0.0f,
                                  (s > 5) ? (float)any[5].number() : 0.0f);
    }
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:40,代码来源:CoordinateFrame.cpp

示例6:

Vector2int32::Vector2int32(const Any& any) {
    any.verifyName("Vector2int32", "Point2int32");
    any.verifyType(Any::TABLE, Any::ARRAY);
    any.verifySize(2);

    if (any.type() == Any::ARRAY) {
        x = any[0];
        y = any[1];
    } else {
        // Table
        x = any["x"];
        y = any["y"];
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:14,代码来源:Vector2int32.cpp

示例7: testParse

static void testParse() {
    {
        const String& src = "name[ \"foo\", b4r, { a = b, c = d}]";
        Any a = Any::parse(src);
        a.verifyType(Any::ARRAY);
        a[0].verifyType(Any::STRING);
        testAssert(a[0].string() == "foo"); 
        testAssert(a[1].string() == "b4r");
        testAssert(a[2]["a"].string() == "b");
    }
    {
        const String& src =  
        "[v = 1,\r\n/*\r\n*/\r\nx = 1]";
        Any a = Any::parse(src);
        testAssert(a.type() == Any::TABLE);
        testAssert(a.size() == 2);

        Any val1 = a["v"];
        testAssert(val1.type() == Any::NUMBER);
        testAssert(val1.number() == 1);
    }
    {
        const String& src =  
        "{\n\
            val0 : (1);\n\
           \n\
           // Comment 1\n\
           val1 : 3;\n\
           \
           // Comment 2\n\
           // Comment 3\n\
           val2 : None;\n\
           val3 : none;\n\
           val4 : NIL;\n\
        }";

        Any a = Any::parse(src);
        testAssert(a.type() == Any::TABLE);
        testAssert(a.size() == 5);

        Any val1 = a["val1"];
        testAssert(val1.type() == Any::NUMBER);
        testAssert(val1.number() == 3);
        testAssert(val1.comment() == "Comment 1");
        testAssert(a["val2"].isNil());       
        testAssert(a["val3"].string() == "none");
        testAssert(a["val4"].isNil());
    }
开发者ID:elfprince13,项目名称:G3D10,代码行数:48,代码来源:tAny.cpp

示例8:

Vector3::Vector3(const Any& any) {
    any.verifyName("Vector3");
    any.verifyType(Any::TABLE, Any::ARRAY);
    any.verifySize(3);

    if (any.type() == Any::ARRAY) {
        x = any[0];
        y = any[1];
        z = any[2];
    } else {
        // Table
        x = any["x"];
        y = any["y"];
        z = any["z"];
    }
}
开发者ID:h4s0n,项目名称:Sandshroud,代码行数:16,代码来源:Vector3.cpp

示例9:

Matrix2::Matrix2(const Any& any) {
    any.verifyName("Matrix2");
    any.verifyType(Any::ARRAY);

    if (any.nameEquals("Matrix2::identity")) {
        *this = identity();
    } else {
        any.verifySize(4);

        for (int r = 0; r < 3; ++r) {
            for (int c = 0; c < 3; ++c) {
                data[r][c] = any[r * 2 + c];
            }
        }
    }
}
开发者ID:lieff,项目名称:g3d,代码行数:16,代码来源:Matrix2.cpp

示例10: if

Matrix4::Matrix4(const Any& any) {
    any.verifyNameBeginsWith("Matrix4", "CFrame", "CoordinateFrame");
    any.verifyType(Any::ARRAY);

    const std::string& name = any.name();
    if (name == "Matrix4") {
        any.verifySize(16);

        for (int r = 0; r < 4; ++r) {
            for (int c = 0; c < 4; ++c) {
                elt[r][c] = any[r * 4 + c];
            }
        }
    } else if (name == "Matrix4::scale") {
        if (any.size() == 1) {
            *this = scale(any[0].floatValue());
        } else if (any.size() == 3) {
            *this = scale(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::scale() takes either 1 or 3 arguments");
        }
    } else if (name == "Matrix4::rollDegrees") {
        any.verifySize(1);
        *this = rollDegrees(any[0].floatValue());
    } else if (name == "Matrix4::yawDegrees") {
        any.verifySize(1);
        *this = yawDegrees(any[0].floatValue());
    } else if (name == "Matrix4::pitchDegrees") {
        any.verifySize(1);
        *this = pitchDegrees(any[0].floatValue());
    } else if (name == "Matrix4::translation") {
        if (any.size() == 3) {
            *this = translation(any[0], any[1], any[2]);
        } else {
            any.verify(false, "Matrix4::translation() requires 3 arguments");
        }    
    } else if (name == "Matrix4::diagonal") {
        any.verifySize(4);
        *this = diagonal(any[0], any[1], any[2], any[3]);
    } else if (name == "Matrix4::identity") {
        *this = identity();
    } else if (beginsWith(name, "CFrame") || beginsWith(name, "CoordinateFrame")) {
        *this = CFrame(any);
    } else {
        any.verify(false, "Expected Matrix4 constructor");
    }
}
开发者ID:93RNounen,项目名称:mangosbot,代码行数:47,代码来源:Matrix4.cpp

示例11:

CompassDelta::CompassDelta(const Any& a) {
    a.verifyType(Any::ARRAY);
    a.verifyName("CompassDelta", "CompassBearing", "degrees");
    a.verifySize(1);
    m_angleDegrees = a[1];
}
开发者ID:lieff,项目名称:g3d,代码行数:6,代码来源:CompassDirection.cpp

示例12: Identifier

ArticulatedModel::Instruction::Instruction(const Any& any) {
    any.verifyType(Any::ARRAY);

    source = any;
    part = Identifier();
    mesh = Identifier();
    arg = Any();

    const std::string& instructionName = any.name();

    if (instructionName == "scale") {

        type = SCALE;
        any.verifySize(1);
        arg = any[0];

    } else if (instructionName == "moveCenterToOrigin") {

        type = MOVE_CENTER_TO_ORIGIN;
        any.verifySize(0);

    } else if (instructionName == "moveBaseToOrigin") {

        type = MOVE_BASE_TO_ORIGIN;
        any.verifySize(0);

    } else if (instructionName == "setCFrame") {

        type = SET_CFRAME;
        any.verifySize(2);
        part = any[0];
        arg = any[1];

    } else if (instructionName == "transformCFrame") {

        type = TRANSFORM_CFRAME;
        any.verifySize(2);
        part = any[0];
        arg = any[1];

    } else if (instructionName == "transformGeometry") {

        type = TRANSFORM_GEOMETRY;
        any.verifySize(2);
        part = any[0];
        arg = any[1];

    } else if (instructionName == "deleteMesh") {

        type = DELETE_MESH;
        any.verifySize(2);
        part = any[0];
        mesh = any[1];

    } else if (instructionName == "deletePart") {

        type = DELETE_PART;
        any.verifySize(1);
        part = any[0];

    } else if (instructionName == "setMaterial") {

        type = SET_MATERIAL;
        any.verifySize(3);
        part = any[0];
        mesh = any[1];
        arg = any[2];

    } else if (instructionName == "setTwoSided") {

        type = SET_TWO_SIDED;
        any.verifySize(3);
        part = any[0];
        mesh = any[1];
        arg = any[2];

    } else if (instructionName == "mergeAll") {

        type = MERGE_ALL;
        any.verifySize(0);

    } else if (instructionName == "renamePart") {

        type = RENAME_PART;
        any.verifySize(2);
        part = any[0];
        arg = any[1];

    } else if (instructionName == "renameMesh") {

        type = RENAME_MESH;
        any.verifySize(3);
        part = any[0];
        mesh = any[1];
        arg = any[2];

    } else if (instructionName == "add") {

        type = ADD;
        mesh = Identifier::none();
//.........这里部分代码省略.........
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:101,代码来源:ArticulatedModel_serialize.cpp


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