/* * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team * Rights to this code are as documented in doc/pod/license.pod. * * JSON-RPC for Ermyth * * $Id: iterator.C,v 1.3 2007/09/05 11:23:15 pippijn Exp $ */ //>>>>>>>>>>> iterator.C <<<<<<<<<< namespace json { // class ValueIteratorBase ValueIteratorBase::ValueIteratorBase () { } ValueIteratorBase::ValueIteratorBase (const Value::ObjectValues::iterator ¤t) : current_ (current) { } Value & ValueIteratorBase::deref () const { return current_->second; } void ValueIteratorBase::increment () { ++current_; } void ValueIteratorBase::decrement () { --current_; } ValueIteratorBase::difference_type ValueIteratorBase::computeDistance (const SelfType &other) const { return difference_type (std::distance (current_, other.current_)); } bool ValueIteratorBase::isEqual (const SelfType &other) const { return current_ == other.current_; } void ValueIteratorBase::copy (const SelfType &other) { current_ = other.current_; } Value ValueIteratorBase::key () const { const Value::CZString czstring = (*current_).first; if (czstring.c_str ()) { if (czstring.isStaticString ()) return Value (StaticString (czstring.c_str ())); return Value (czstring.c_str ()); } return Value (czstring.index ()); } unsigned ValueIteratorBase::index () const { const Value::CZString czstring = (*current_).first; if (!czstring.c_str ()) return czstring.index (); return unsigned (-1); } char const * ValueIteratorBase::memberName () const { char const *name = (*current_).first.c_str (); return name ? name : ""; } // class ValueConstIterator ValueConstIterator::ValueConstIterator () { } ValueConstIterator::ValueConstIterator (const Value::ObjectValues::iterator ¤t) : ValueIteratorBase (current) { } ValueConstIterator & ValueConstIterator::operator = (const ValueIteratorBase &other) { copy (other); return *this; } // class ValueIterator ValueIterator::ValueIterator () { } ValueIterator::ValueIterator (const Value::ObjectValues::iterator ¤t) : ValueIteratorBase (current) { } ValueIterator::ValueIterator (const ValueConstIterator &other) : ValueIteratorBase (other) { } ValueIterator::ValueIterator (const ValueIterator &other) : ValueIteratorBase (other) { } ValueIterator & ValueIterator::operator = (const SelfType &other) { copy (other); return *this; } }