[yast-commit] r54312 - in /trunk/core/libycp/src: YCPMap.cc YCPString.cc include/ycp/YCPMap.h include/ycp/YCPString.h

Author: aschnell Date: Sat Dec 20 17:21:36 2008 New Revision: 54312 URL: http://svn.opensuse.org/viewcvs/yast?rev=54312&view=rev Log: - added isEmpty for YCPString and YCPMap Modified: trunk/core/libycp/src/YCPMap.cc trunk/core/libycp/src/YCPString.cc trunk/core/libycp/src/include/ycp/YCPMap.h trunk/core/libycp/src/include/ycp/YCPString.h Modified: trunk/core/libycp/src/YCPMap.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPMap.cc?rev=543... ============================================================================== --- trunk/core/libycp/src/YCPMap.cc (original) +++ trunk/core/libycp/src/YCPMap.cc Sat Dec 20 17:21:36 2008 @@ -113,6 +113,13 @@ } +bool +YCPMapRep::isEmpty() const +{ + return stl_map.empty(); +} + + long YCPMapRep::size() const { Modified: trunk/core/libycp/src/YCPString.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPString.cc?rev=... ============================================================================== --- trunk/core/libycp/src/YCPString.cc (original) +++ trunk/core/libycp/src/YCPString.cc Sat Dec 20 17:21:36 2008 @@ -33,6 +33,14 @@ { } + +bool +YCPStringRep::isEmpty() const +{ + return v.empty(); +} + + string YCPStringRep::value() const { Modified: trunk/core/libycp/src/include/ycp/YCPMap.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPMa... ============================================================================== --- trunk/core/libycp/src/include/ycp/YCPMap.h (original) +++ trunk/core/libycp/src/include/ycp/YCPMap.h Sat Dec 20 17:21:36 2008 @@ -82,6 +82,11 @@ void remove(const YCPValue& key); /** + * Returns true, iff this map is empty. + */ + bool isEmpty() const; + + /** * Returns the number of key/value pairs. */ long size() const; @@ -212,6 +217,7 @@ void add(const YCPValue& key, const YCPValue& value) { ELEMENT->add (key,value); } YCPMap functionalAdd(const YCPValue& key, const YCPValue& value) const { return CONST_ELEMENT-> functionalAdd (key,value); } void remove(const YCPValue& key) { ELEMENT-> remove (key); } + bool isEmpty() const { return CONST_ELEMENT->isEmpty(); } long size() const { return CONST_ELEMENT-> size (); } YCPValue value(const YCPValue& key) const { return CONST_ELEMENT-> value (key); } YCPMapIterator begin() const { return CONST_ELEMENT-> begin (); } Modified: trunk/core/libycp/src/include/ycp/YCPString.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPSt... ============================================================================== --- trunk/core/libycp/src/include/ycp/YCPString.h (original) +++ trunk/core/libycp/src/include/ycp/YCPString.h Sat Dec 20 17:21:36 2008 @@ -53,6 +53,12 @@ YCPStringRep(string s); public: + + /** + * Returns true, iff this string is empty. + */ + bool isEmpty() const; + /** * Returns the value of this object in form of a C++ * string value. @@ -94,6 +100,9 @@ YCPValueType valuetype() const; }; + +#define CONST_ELEMENT (static_cast<const YCPStringRep*>(element)) + /** * @short Wrapper for YCPStringRep * This class realizes an automatic memory management @@ -106,7 +115,11 @@ public: YCPString(string s) : YCPValue(new YCPStringRep(s)) {} YCPString(bytecodeistream & str); + + bool isEmpty() const { return CONST_ELEMENT->isEmpty(); } }; +#undef CONST_ELEMENT + #endif // YCPString_h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn.opensuse.org