- <1>
- rapidjson::Document_doc;
- <2>
- _doc.Parse<0>(_msg.c_str());
- <3>
- @H_301_45@template<unsignedparseFlags>
- GenericDocument&Parse(constCh*str){
- RAPIDJSON_ASSERT(!(parseFlags&kParseInsituFlag));
- GenericStringStream<Encoding>s(str);
- returnParseStream<parseFlags>(s);
- }
- <4>
- template<typenameEncoding>
- structGenericStringStream{
- typedeftypenameEncoding::ChCh;
- GenericStringStream(constCh*src):src_(src),head_(src){}
- ChPeek()const{return*src_;}
- ChTake(){return*src_++;}
- size_tTell()returnsrc_-head_;}
- Ch*PutBegin(){RAPIDJSON_ASSERT(false);return0;}
- voidPut(Ch){RAPIDJSON_ASSERT(false);}
- size_tPutEnd(Ch*){RAPIDJSON_ASSERT(constCh*src_;//!<Currentreadposition.
- constCh*head_;//!<Originalheadofthestring.
- };
- <5>
- template<unsignedparseFlags,typenameStream>
- GenericDocument&ParseStream(Stream&stream){
- ValueType::SetNull();//Removeexistingrootifexist
- GenericReader<Encoding,Allocator>reader;
- if(reader.templateParse<parseFlags>(stream,*this)){
- RAPIDJSON_ASSERT(stack_.GetSize()==sizeof(ValueType));//Gotoneandonlyonerootobject
- this->RawAssign(*stack_.templatePop<ValueType>(1));//Addthis->topreventissue13.
- parseError_=0;
- errorOffset_=0;
- }
- else{
- parseError_=reader.GetParseError();
- errorOffset_=reader.GetErrorOffset();
- ClearStack();
- return*this;
- }