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


C++ StructPtr::getId方法代码示例

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


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

示例1:

/*******************************StructPtr********************************/
string Jce2Php::tostrStruct(const StructPtr &pPtr) const
{
    return pPtr->getId();
}
开发者ID:daliniu,项目名称:mobile,代码行数:5,代码来源:jce2php.cpp

示例2: __clone

string Jce2Php::generatePHP(const StructPtr &pPtr, const string& namespaceId) const
{
    ostringstream s;

	vector<TypeIdPtr>& member = pPtr->getAllMemberPtr();

    s << TAB << "class " << pPtr->getId() << " extends c_struct" << endl;
    s << TAB << "{" << endl;
    INC_TAB;

    //变量声明
    for(size_t k = 0;k < member.size();k++)
    {
        s<< TAB << "public $" <<member[k]->getId()<<";"<<endl;
    }
    s<<endl;
    s << TAB << "public function __clone()" << endl;
    s << TAB << "{" << endl;
    INC_TAB;
    for(size_t k = 0;k < member.size();k++)
    {
        s<< TAB << "$this->" <<member[k]->getId()<<" = clone $this->"<<member[k]->getId()<<";"<<endl;
    }
    DEL_TAB;
    s << TAB << "}" << endl;
    s <<endl;

    s << TAB << "public function __construct()" << endl;
    s << TAB << "{" << endl;
    INC_TAB;
    for(size_t k = 0;k < member.size();k++)
    {
        s<< TAB << "$this->" <<member[k]->getId()<<" = new  "<< tostr(member[k]->getTypePtr())<<";"<<endl;
    }
    DEL_TAB;
    s << TAB << "}" << endl;
    s <<endl;
    ////////////////////////////////////////////////////////////
    s << TAB << "public function get_class_name()" << endl;
    s << TAB << "{" << endl;
    INC_TAB;
    s << TAB << "return " << "\"" << namespaceId << "." << pPtr->getId() << "\"" << ";" << endl;
    DEL_TAB;
    s << TAB << "}" << endl;
    s<<endl;

	//write begin
	if(m_bPDU)
	{
	    s << TAB << "public function writeTo(&$_out,$tag)" << endl;
	    s << TAB << "{" << endl;
	    INC_TAB;
	    //s << TAB << "jce_header::_pack_header($_out,'c_struct_begin',$tag);" << endl;
	}
	else
	{
		s << TAB << "public function write(&$_out,$tag)" << endl;
		s << TAB << "{" << endl;
		INC_TAB;
		s << TAB << "jce_header::_pack_header($_out,'c_struct_begin',$tag);" << endl;
	}

    for(size_t j = 0; j < member.size(); j++)
    {
        s << writeTo(member[j]);
    }

    if(m_bPDU)
    {
        //s << TAB << "jce_header::_pack_header($_out,'c_struct_end',0);" << endl;
    }
	else
	{
		 s << TAB << "jce_header::_pack_header($_out,'c_struct_end',0);" << endl;
	}

    DEL_TAB;
    s << TAB << "}" << endl;
	//write end


	///read begin
	if(m_bPDU)
	{
		s << TAB << "public function readFrom(&$_in,$tag,$isRequire = true)" << endl;
		s << TAB << "{" << endl;

		INC_TAB;
#if 0

		s << TAB << "jce_header::_peek_header($_in,$type,$this_tag);"<<endl;

		s << TAB << "if($tag != $this_tag)" <<endl;
		s << TAB << "{" << endl;
		INC_TAB;
		s << TAB << "if($isRequire == true){"<<endl;
		s << TAB << "throw new JceException(__LINE__ ,TAG_NOT_MATCH);"<<endl;
		s << TAB << "}else{" <<endl;
		INC_TAB;
		s << TAB << "return;"<<endl;
//.........这里部分代码省略.........
开发者ID:daliniu,项目名称:mobile,代码行数:101,代码来源:jce2php.cpp

示例3: readStruct

int TarsAnalyzer::readStruct(const StructPtr & pPtr, const NamespacePtr & nPtr)
{
    vector<TypeIdPtr>& member = pPtr->getAllMemberPtr();

    AnalyzerDataHead h;
    size_t hLen = h.peekFrom(*this);
    if (AnalyzerDataHead::eStructBegin == h.getType()) // 检查结构开始
    {
        cout << endl;
        incTab();
        cout << getTab()<<  "struct " << pPtr->getId() << " {"  << endl;
        skip(hLen);
    }

    //解析struct成员变量
    for (size_t i = 0; i < member.size(); i++)
    {
        cout<< getTab() <<"expect tag ";
        cout.setf(ios::right);
        cout.width(CHAR_WIDTH_TAG);
        cout<< member[i]->getTag();
        cout.width(CHAR_WIDTH_ID); // 成员名12字符宽
        cout<< member[i]->getId();

        //获取tup版本号
        if(isTup() && (pPtr->getId() == "RequestPacket"))
        {
            if(member[i]->getTag() == 1)
            {
                char iVer = 2;
                this->peekBuf(&iVer, sizeof(iVer),1);
                _tupVersion = iVer;
            }
            else if(member[i]->getTag() == 7)///解析sbuffer
            {
                _tup_sbuffer_pos = _cur;
                _cur +=2; //7D 00

                int n;
                uint8_t  tag = 0;
                int  realType;
                read(n,  tag,  realType, true ); //sbuffer的长度

                if(_tupVersion == 2)
                {
                    read(_tup2_helper, 7);
                    _bIsDumpTup?dumpTup(_tup2_helper):(void(0));
                }
                else///3
                {
                    read(_tup3_helper, 7);
                    _bIsDumpTup?dumpTup(_tup3_helper):(void(0));
                }

                _cur = _tup_sbuffer_pos;
            }
        }

        //读取内置基本类型
        BuiltinPtr bPtr = BuiltinPtr::dynamicCast(member[i]->getTypePtr());
        if (bPtr)
        {
            cout.width(CHAR_WIDTH_TYPE);
            cout<<tostrBuiltin(bPtr);

            cout<<getSep();
            readBuiltin(bPtr, member[i]->getTag(), member[i]->isRequire(), NULL);
        }

        VectorPtr vPtr = VectorPtr::dynamicCast(member[i]->getTypePtr());
        if (vPtr)
        {
            cout.width(CHAR_WIDTH_TYPE);
            cout<<tostrVector(vPtr);
            cout<<getSep();
            readVector(vPtr, member[i]->getTag(),member[i]->isRequire(), NULL);
        }

        MapPtr mPtr   = MapPtr::dynamicCast(member[i]->getTypePtr());
        if (mPtr)
        {
            cout.width(CHAR_WIDTH_TYPE);
            cout<<tostrMap(mPtr);
            cout<<getSep();
            readMap(mPtr, member[i]->getTag(), member[i]->isRequire());
        }

        StructPtr sPtr = StructPtr::dynamicCast(member[i]->getTypePtr());
        if (sPtr)
        {
            cout.width(CHAR_WIDTH_TYPE);
            cout<< tostrStruct(sPtr);
            cout<<getSep();
            readStruct(sPtr, NULL);
        }

        EnumPtr ePtr = EnumPtr::dynamicCast(member[i]->getTypePtr());
        if (ePtr)
        {

//.........这里部分代码省略.........
开发者ID:Blucezhang,项目名称:Tars,代码行数:101,代码来源:tarsAnalyzer.cpp


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