加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

rapidjson::Document _doc

发布时间:2020-12-16 18:55:55 所属栏目:百科 来源:网络整理
导读:[cpp] view plain copy 1 rapidjson::Document_doc; 2 _doc.Parse0(_msg.c_str()); 3 template unsignedparseFlags GenericDocumentParse( const Ch*str){ RAPIDJSON_ASSERT(!(parseFlagskParseInsituFlag)); GenericStringStreamEncodings(str); return Par
[cpp] view plain copy
  1. <1>
  2. rapidjson::Document_doc;
  3. <2>
  4. _doc.Parse<0>(_msg.c_str());
  5. <3>
  6. template<unsignedparseFlags>
  7. GenericDocument&Parse(constCh*str){
  8. RAPIDJSON_ASSERT(!(parseFlags&kParseInsituFlag));
  9. GenericStringStream<Encoding>s(str);
  10. returnParseStream<parseFlags>(s);
  11. }
  12. <4>
  13. template<typenameEncoding>
  14. structGenericStringStream{
  15. typedeftypenameEncoding::ChCh;
  16. GenericStringStream(constCh*src):src_(src),head_(src){}
  17. ChPeek()const{return*src_;}
  18. ChTake(){return*src_++;}
  19. size_tTell()returnsrc_-head_;}
  20. Ch*PutBegin(){RAPIDJSON_ASSERT(false);return0;}
  21. voidPut(Ch){RAPIDJSON_ASSERT(false);}
  22. size_tPutEnd(Ch*){RAPIDJSON_ASSERT(constCh*src_;//!<Currentreadposition.
  23. constCh*head_;//!<Originalheadofthestring.
  24. };
  25. <5>
  26. template<unsignedparseFlags,typenameStream>
  27. GenericDocument&ParseStream(Stream&stream){
  28. ValueType::SetNull();//Removeexistingrootifexist
  29. GenericReader<Encoding,Allocator>reader;
  30. if(reader.templateParse<parseFlags>(stream,*this)){
  31. RAPIDJSON_ASSERT(stack_.GetSize()==sizeof(ValueType));//Gotoneandonlyonerootobject
  32. this->RawAssign(*stack_.templatePop<ValueType>(1));//Addthis->topreventissue13.
  33. parseError_=0;
  34. errorOffset_=0;
  35. }
  36. else{
  37. parseError_=reader.GetParseError();
  38. errorOffset_=reader.GetErrorOffset();
  39. ClearStack();
  40. return*this;
  41. }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读