osgEarth 2.1.1
Public Types | Public Member Functions | Protected Member Functions | Private Attributes

osgEarth::Json::ValueIteratorBase Class Reference

Experimental and untested: base class for Value iterators. More...

Inheritance diagram for osgEarth::Json::ValueIteratorBase:

List of all members.

Public Types

typedef unsigned int size_t
typedef int difference_type
typedef ValueIteratorBase SelfType

Public Member Functions

 ValueIteratorBase ()
 ValueIteratorBase (const Value::ObjectValues::iterator &current)
bool operator== (const SelfType &other) const
bool operator!= (const SelfType &other) const
difference_type operator- (const SelfType &other) const
Value key () const
 Return either the index or the member name of the referenced value as a Value.
Value::UInt index () const
 Return the index of the referenced Value. -1 if it is not an arrayValue.
const char * memberName () const
 Return the member name of the referenced Value. "" if it is not an objectValue.

Protected Member Functions

Valuederef () const
void increment ()
void decrement ()
difference_type computeDistance (const SelfType &other) const
bool isEqual (const SelfType &other) const
void copy (const SelfType &other)

Private Attributes

Value::ObjectValues::iterator current_

Detailed Description

Experimental and untested: base class for Value iterators.

Definition at line 922 of file JsonUtils.


Member Typedef Documentation

Reimplemented in osgEarth::Json::ValueConstIterator, and osgEarth::Json::ValueIterator.

Definition at line 926 of file JsonUtils.

Reimplemented in osgEarth::Json::ValueConstIterator, and osgEarth::Json::ValueIterator.

Definition at line 927 of file JsonUtils.

Reimplemented in osgEarth::Json::ValueConstIterator, and osgEarth::Json::ValueIterator.

Definition at line 925 of file JsonUtils.


Constructor & Destructor Documentation

ValueIteratorBase::ValueIteratorBase ( )

Definition at line 142 of file JsonUtils.cpp.

{
}
ValueIteratorBase::ValueIteratorBase ( const Value::ObjectValues::iterator &  current) [explicit]

Definition at line 148 of file JsonUtils.cpp.

   : current_( current )
{
}

Member Function Documentation

ValueIteratorBase::difference_type ValueIteratorBase::computeDistance ( const SelfType other) const [protected]

Definition at line 207 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
# ifdef JSON_USE_CPPTL_SMALLMAP
   return current_ - other.current_;
# else
   return difference_type( std::distance( current_, other.current_ ) );
# endif
#else
   if ( isArray_ )
      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );
   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );
#endif
}
void ValueIteratorBase::copy ( const SelfType other) [protected]

Definition at line 237 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   current_ = other.current_;
#else
   if ( isArray_ )
      iterator_.array_ = other.iterator_.array_;
   iterator_.map_ = other.iterator_.map_;
#endif
}

Here is the caller graph for this function:

void ValueIteratorBase::decrement ( ) [protected]

Definition at line 194 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   --current_;
#else
   if ( isArray_ )
      ValueInternalArray::decrement( iterator_.array_ );
   ValueInternalMap::decrement( iterator_.map_ );
#endif
}
Value & ValueIteratorBase::deref ( ) const [protected]

Definition at line 168 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   return current_->second;
#else
   if ( isArray_ )
      return ValueInternalArray::dereference( iterator_.array_ );
   return ValueInternalMap::value( iterator_.map_ );
#endif
}
void ValueIteratorBase::increment ( ) [protected]

Definition at line 181 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   ++current_;
#else
   if ( isArray_ )
      ValueInternalArray::increment( iterator_.array_ );
   ValueInternalMap::increment( iterator_.map_ );
#endif
}
Value::UInt ValueIteratorBase::index ( ) const

Return the index of the referenced Value. -1 if it is not an arrayValue.

Definition at line 274 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   const Value::CZString czstring = (*current_).first;
   if ( !czstring.c_str() )
      return czstring.index();
   return Value::UInt( -1 );
#else
   if ( isArray_ )
      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );
   return Value::UInt( -1 );
#endif
}

Here is the call graph for this function:

bool ValueIteratorBase::isEqual ( const SelfType other) const [protected]

Definition at line 224 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   return current_ == other.current_;
#else
   if ( isArray_ )
      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );
   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );
#endif
}
Value ValueIteratorBase::key ( ) const

Return either the index or the member name of the referenced value as a Value.

Definition at line 250 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   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() );
#else
   if ( isArray_ )
      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );
   bool isStatic;
   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );
   if ( isStatic )
      return Value( StaticString( memberName ) );
   return Value( memberName );
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char * ValueIteratorBase::memberName ( ) const

Return the member name of the referenced Value. "" if it is not an objectValue.

Definition at line 290 of file JsonUtils.cpp.

{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
   const char *name = (*current_).first.c_str();
   return name ? name : "";
#else
   if ( !isArray_ )
      return ValueInternalMap::key( iterator_.map_ );
   return "";
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool osgEarth::Json::ValueIteratorBase::operator!= ( const SelfType other) const [inline]

Definition at line 942 of file JsonUtils.

      {
         return !isEqual( other );
      }
difference_type osgEarth::Json::ValueIteratorBase::operator- ( const SelfType other) const [inline]

Definition at line 947 of file JsonUtils.

      {
         return computeDistance( other );
      }
bool osgEarth::Json::ValueIteratorBase::operator== ( const SelfType other) const [inline]

Definition at line 937 of file JsonUtils.

      {
         return isEqual( other );
      }

Member Data Documentation

Value::ObjectValues::iterator osgEarth::Json::ValueIteratorBase::current_ [private]

Definition at line 976 of file JsonUtils.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines