資源簡介
json.rar

代碼片段和文件信息
#include?“reader.h“
#include?“value.h“
#include?
#include?
#include?
#include?
#include?
#include?
#if?_MSC_VER?>=?1400?//?VC++?8.0
#pragma?warning(?disable?:?4996?)???//?disable?warning?about?strdup?being?deprecated.
#endif
namespace?Json?{
static?inline?bool?
in(?Reader::Char?c?Reader::Char?c1?Reader::Char?c2?Reader::Char?c3?Reader::Char?c4?)
{
???return?c?==?c1??||??c?==?c2??||??c?==?c3??||??c?==?c4;
}
static?inline?bool?
in(?Reader::Char?c?Reader::Char?c1?Reader::Char?c2?Reader::Char?c3?Reader::Char?c4?Reader::Char?c5?)
{
???return?c?==?c1??||??c?==?c2??||??c?==?c3??||??c?==?c4??||??c?==?c5;
}
static?bool?
containsNewLine(?Reader::Location?begin?
?????????????????Reader::Location?end?)
{
???for?(?;begin???????if?(?*begin?==?‘\n‘??||??*begin?==?‘\r‘?)
?????????return?true;
???return?false;
}
//?Class?Reader
//?//////////////////////////////////////////////////////////////////
Reader::Reader()
{
}
bool
Reader::parse(?const?std::string?&document?
???????????????Value?&root
???????????????bool?collectComments?)
{
???document_?=?document;
???const?char?*begin?=?document_.c_str();
???const?char?*end?=?begin?+?document_.length();
???return?parse(?begin?end?root?collectComments?);
}
bool
Reader::parse(?std::istream&?sin
???????????????Value?&root
???????????????bool?collectComments?)
{
???//std::istream_iterator?begin(sin);
???//std::istream_iterator?end;
???//?Those?would?allow?streamed?input?from?a?file?if?parse()?were?a
???//?template?function.
???//?Since?std::string?is?reference-counted?this?at?least?does?not
???//?create?an?extra?copy.
???std::string?doc;
???std::getline(sin?doc?(char)EOF);
???return?parse(?doc?root?collectComments?);
}
bool?
Reader::parse(?const?char?*beginDoc?const?char?*endDoc?
???????????????Value?&root
???????????????bool?collectComments?)
{
???begin_?=?beginDoc;
???end_?=?endDoc;
???collectComments_?=?collectComments;
???current_?=?begin_;
???lastValueEnd_?=?0;
???lastValue_?=?0;
???commentsBefore_?=?““;
???errors_.clear();
???while?(?!nodes_.empty()?)
??????nodes_.pop();
???nodes_.push(?&root?);
???
???bool?successful?=?readValue();
???Token?token;
???skipCommentTokens(?token?);
???if?(?collectComments_??&&??!commentsBefore_.empty()?)
??????root.setComment(?commentsBefore_?commentAfter?);
???return?successful;
}
bool
Reader::readValue()
{
???Token?token;
???skipCommentTokens(?token?);
???bool?successful?=?true;
???if?(?collectComments_??&&??!commentsBefore_.empty()?)
???{
??????currentValue().setComment(?commentsBefore_?commentBefore?);
??????commentsBefore_?=?““;
???}
???switch?(?token.type_?)
???{
???case?tokenobjectBegin:
??????successful?=?readobject(?token?);
??????break;
???case?tokenArrayBegin:
??????successful?=?readArray(?token?);
??????break;
???case?tokenNumber:
??????successful?=?decodeNumber(?token?);
??????break;
???case?tokenString:
??????successful?=?decodeString(?token?);
???
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
????.......???????457??2010-11-19?10:31??json\autoli
????.......??????1429??2010-11-19?10:31??json\config.h
????.......???????648??2010-11-19?10:31??json\forwards.h
????.......???????186??2010-11-19?10:31??json\json.h
????.......??????4054??2010-11-19?10:31??json\json_batchallocator.h
????.......?????13117??2010-11-19?10:31??json\json_internalarray.inl
????.......?????16899??2010-11-19?10:31??json\json_internalmap.inl
????.......?????17582??2010-11-19?10:31??json\json_reader.cpp
????.......?????40412??2010-11-19?10:31??json\json_value.cpp
????.......??????6592??2010-11-19?10:31??json\json_valueiterator.inl
????.......?????19957??2010-11-19?10:31??json\json_writer.cpp
????.......??????5947??2010-11-19?10:31??json\reader.h
????.......?????34630??2010-11-19?10:31??json\value.h
????.......??????6376??2010-11-19?10:31??json\writer.h
?????目錄??????????0??2010-11-19?10:37??json
-----------?---------??----------?-----??----
???????????????168286????????????????????15
評(píng)論
共有 條評(píng)論