yast2-core
Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | Friends | List of all members
YCPMapRep Class Reference

A mapping from keys to values. A map is also called assiciative array. It is a mapping from a set of keys to a set of values. Each key in a map is unique. Each key is assigned a value. Keys and values may only be String or Integer constants. Elements inside a map are kept in a sorted order based on the key value. More...

#include <YCPMap.h>

Inheritance diagram for YCPMapRep:
YCPValueRep YCPElementRep

Public Member Functions

void add (const YCPValue &key, const YCPValue &value)
 
YCPMap functionalAdd (const YCPValue &key, const YCPValue &value) const
 
virtual const YCPElementRepshallowCopy () const
 
void remove (const YCPValue &key)
 
bool isEmpty () const
 
long size () const
 
bool hasKey (const YCPValue &key) const
 
YCPValue value (const YCPValue &key) const
 
YCPMapIterator begin () const
 
YCPMapIterator end () const
 
YCPOrder compare (const YCPMap &v) const
 
string toString () const
 
std::ostream & toStream (std::ostream &str) const
 
std::ostream & toXml (std::ostream &str, int indent) const
 
YCPValueType valuetype () const
 
- Public Member Functions inherited from YCPValueRep
const char * valuetype_str () const
 
bool isVoid () const
 
bool isBoolean () const
 
bool isInteger () const
 
bool isFloat () const
 
bool isString () const
 
bool isByteblock () const
 
bool isPath () const
 
bool isSymbol () const
 
bool isList () const
 
bool isTerm () const
 
bool isMap () const
 
bool isCode () const
 
bool isBreak () const
 
bool isReturn () const
 
bool isEntry () const
 
bool isReference () const
 
bool isExternal () const
 
YCPVoid asVoid () const
 
YCPBoolean asBoolean () const
 
YCPInteger asInteger () const
 
YCPFloat asFloat () const
 
YCPString asString () const
 
YCPByteblock asByteblock () const
 
YCPPath asPath () const
 
YCPSymbol asSymbol () const
 
YCPList asList () const
 
YCPTerm asTerm () const
 
YCPMap asMap () const
 
YCPCode asCode () const
 
YCPEntry asEntry () const
 
YCPReference asReference () const
 
YCPExternal asExternal () const
 
bool equal (const YCPValue &) const
 
YCPOrder compare (const YCPValue &v, bool rl=false) const
 
- Public Member Functions inherited from YCPElementRep
YCPValue asValue () const
 

Protected Types

typedef YCPValueYCPValueMap::iterator iterator
 
typedef YCPValueYCPValueMap::const_iterator const_iterator
 
typedef YCPValueYCPValueMap::value_type value_type
 
typedef YCPValueYCPValueMap::const_reference const_reference
 
typedef YCPValueYCPValueMap::key_compare key_compare
 

Protected Member Functions

 YCPMapRep ()
 
 ~YCPMapRep ()
 
- Protected Member Functions inherited from YCPElementRep
 YCPElementRep ()
 
virtual ~YCPElementRep ()
 

Private Attributes

YCPValueYCPValueMap stl_map
 

Friends

class YCPMap
 

Detailed Description

A mapping from keys to values. A map is also called assiciative array. It is a mapping from a set of keys to a set of values. Each key in a map is unique. Each key is assigned a value. Keys and values may only be String or Integer constants. Elements inside a map are kept in a sorted order based on the key value.

Member Typedef Documentation

typedef YCPValueYCPValueMap::const_iterator YCPMapRep::const_iterator
protected
typedef YCPValueYCPValueMap::const_reference YCPMapRep::const_reference
protected
typedef YCPValueYCPValueMap::iterator YCPMapRep::iterator
protected
typedef YCPValueYCPValueMap::key_compare YCPMapRep::key_compare
protected
typedef YCPValueYCPValueMap::value_type YCPMapRep::value_type
protected

Constructor & Destructor Documentation

YCPMapRep::YCPMapRep ( )
protected

Creates a new and empty mapping.

Referenced by shallowCopy().

YCPMapRep::~YCPMapRep ( )
inlineprotected

Member Function Documentation

void YCPMapRep::add ( const YCPValue key,
const YCPValue value 
)

Adds a new key/value pair. If the key is existent, the old entry will be overwritten with the new one.

References stl_map, value(), and ycp2error.

Referenced by shallowCopy(), and ~YCPMapRep().

YCPMapIterator YCPMapRep::begin ( ) const

Returns a bidirectional iterator for the YCPMap that is positioned at the first value pair in the map.

References stl_map.

Referenced by compare(), functionalAdd(), shallowCopy(), toStream(), toString(), toXml(), and ~YCPMapRep().

YCPOrder YCPMapRep::compare ( const YCPMap v) const

Compares two YCPMaps for equality, greaterness or smallerness. Comparison is done as follows: shorter < longer pairwise comparison for maps of equal length not being empty

Parameters
vvalue to compare against
Returns
YO_LESS, if this is smaller than v, YO_EQUAL, if this is equal to v, YO_GREATER, if this is greater to v

References begin(), YCPMap::begin(), end(), order, size(), YCPMap::size(), YO_EQUAL, YO_GREATER, and YO_LESS.

Referenced by ~YCPMapRep().

YCPMapIterator YCPMapRep::end ( ) const

Returns a bidirectional iterator for the YCPMap that is positioned behind the last value pair in the map.

References stl_map.

Referenced by compare(), functionalAdd(), shallowCopy(), toStream(), toString(), toXml(), value(), and ~YCPMapRep().

YCPMap YCPMapRep::functionalAdd ( const YCPValue key,
const YCPValue value 
) const

Is like add, but doesn't change this map. It creates a newly created map.

References YCPMap::add(), begin(), end(), toString(), y2debug, and ycp2error.

Referenced by ~YCPMapRep().

bool YCPMapRep::hasKey ( const YCPValue key) const

Returns true iff the map contains the key.

References stl_map.

Referenced by ~YCPMapRep().

bool YCPMapRep::isEmpty ( ) const

Returns true, iff this map is empty.

References stl_map.

Referenced by ~YCPMapRep().

void YCPMapRep::remove ( const YCPValue key)

Remove a value from the map.

References stl_map, and ycp2error.

const YCPElementRep * YCPMapRep::shallowCopy ( ) const
virtual

Creates a copy of this list, i.e. creates a new list with the same elements as this one. The elements themselves are not copied, but only cloned!

Reimplemented from YCPElementRep.

References add(), begin(), end(), and YCPMapRep().

Referenced by ~YCPMapRep().

long YCPMapRep::size ( ) const

Returns the number of key/value pairs.

References stl_map.

Referenced by compare(), and ~YCPMapRep().

std::ostream & YCPMapRep::toStream ( std::ostream &  str) const
virtual

Output value as bytecode to stream

Implements YCPElementRep.

References begin(), end(), stl_map, str, Bytecode::writeInt32(), and Bytecode::writeValue().

Referenced by ~YCPMapRep().

string YCPMapRep::toString ( void  ) const
virtual

Returns an ASCII representation of the map. Maps are denoted by a comma separated list of pairs of the form key : value enclosed in $[ ... ]

Implements YCPElementRep.

References begin(), and end().

Referenced by functionalAdd(), and ~YCPMapRep().

std::ostream & YCPMapRep::toXml ( std::ostream &  str,
int  indent 
) const
virtual

Implements YCPValueRep.

References begin(), end(), and stl_map.

Referenced by ~YCPMapRep().

YCPValue YCPMapRep::value ( const YCPValue key) const

Looks for a certain key and returns the value assigned to that key. Returns 0, if the key is not found.

References end(), and stl_map.

Referenced by add(), and ~YCPMapRep().

YCPValueType YCPMapRep::valuetype ( ) const
virtual

Returns YT_MAP. See YCPValueRep::valuetype.

Implements YCPValueRep.

References YT_MAP.

Referenced by ~YCPMapRep().

Friends And Related Function Documentation

friend class YCPMap
friend

Referenced by YCPMap::YCPMap().

Member Data Documentation

YCPValueYCPValueMap YCPMapRep::stl_map
private

The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.8.11