// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors// Distributed under MIT license, or public domain if desired and// recognized in your jurisdiction.// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE// included by json_value.cppnamespace Json {// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// class ValueIteratorBase// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////ValueIteratorBase::ValueIteratorBase(): current_(), isNull_(true) {}ValueIteratorBase::ValueIteratorBase(const Value::ObjectValues::iterator& current): current_(current), isNull_(false) {}Value& ValueIteratorBase::deref() const {return current_->second;}void ValueIteratorBase::increment() {++current_;}void ValueIteratorBase::decrement() {--current_;}ValueIteratorBase::difference_typeValueIteratorBase::computeDistance(const SelfType& other) const {#ifdef JSON_USE_CPPTL_SMALLMAPreturn other.current_ - current_;#else// Iterator for null value are initialized using the default// constructor, which initialize current_ to the default// std::map::iterator. As begin() and end() are two instance// of the default std::map::iterator, they can not be compared.// To allow this, we handle this comparison specifically.if (isNull_ && other.isNull_) {return 0;}// Usage of std::distance is not portable (does not compile with Sun Studio 12// RogueWave STL,// which is the one used by default).// Using a portable hand-made version for non random iterator instead:// return difference_type( std::distance( current_, other.current_ ) );difference_type myDistance = 0;for (Value::ObjectValues::iterator it = current_; it != other.current_;++it) {++myDistance;}return myDistance;#endif}bool ValueIteratorBase::isEqual(const SelfType& other) const {if (isNull_) {return other.isNull_;}return current_ == other.current_;}void ValueIteratorBase::copy(const SelfType& other) {current_ = other.current_;isNull_ = other.isNull_;}Value ValueIteratorBase::key() const {const Value::CZString czstring = (*current_).first;if (czstring.data()) {if (czstring.isStaticString())return Value(StaticString(czstring.data()));return Value(czstring.data(), czstring.data() + czstring.length());}return Value(czstring.index());}UInt ValueIteratorBase::index() const {const Value::CZString czstring = (*current_).first;if (!czstring.data())return czstring.index();return Value::UInt(-1);}JSONCPP_STRING ValueIteratorBase::name() const {char const* keey;char const* end;keey = memberName(&end);if (!keey) return JSONCPP_STRING();return JSONCPP_STRING(keey, end);}char const* ValueIteratorBase::memberName() const {const char* cname = (*current_).first.data();return cname ? cname : "";}char const* ValueIteratorBase::memberName(char const** end) const {const char* cname = (*current_).first.data();if (!cname) {*end = NULL;return NULL;}*end = cname + (*current_).first.length();return cname;}// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// class ValueConstIterator// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////ValueConstIterator::ValueConstIterator() {}ValueConstIterator::ValueConstIterator(const Value::ObjectValues::iterator& current): ValueIteratorBase(current) {}ValueConstIterator::ValueConstIterator(ValueIterator const& other): ValueIteratorBase(other) {}ValueConstIterator& ValueConstIterator::operator=(const ValueIteratorBase& other) {copy(other);return *this;}// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// class ValueIterator// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////ValueIterator::ValueIterator() {}ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current): ValueIteratorBase(current) {}ValueIterator::ValueIterator(const ValueConstIterator& other): ValueIteratorBase(other) {throwRuntimeError("ConstIterator to Iterator should never be allowed.");}ValueIterator::ValueIterator(const ValueIterator& other): ValueIteratorBase(other) {}ValueIterator& ValueIterator::operator=(const SelfType& other) {copy(other);return *this;}} // namespace Json
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. Open source ecosystem
2. Collaboration, People, Software
3. Evaluation model