[yast-commit] r56544 - in /trunk/storage/libstorage/src: Dasd.cc Disk.cc ProcPart.cc ProcPart.h
Author: aschnell Date: Wed Apr 1 16:55:29 2009 New Revision: 56544 URL: http://svn.opensuse.org/viewcvs/yast?rev=56544&view=rev Log: - templated programming Modified: trunk/storage/libstorage/src/Dasd.cc trunk/storage/libstorage/src/Disk.cc trunk/storage/libstorage/src/ProcPart.cc trunk/storage/libstorage/src/ProcPart.h Modified: trunk/storage/libstorage/src/Dasd.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Dasd.cc?rev=56544&r1=56543&r2=56544&view=diff ============================================================================== --- trunk/storage/libstorage/src/Dasd.cc (original) +++ trunk/storage/libstorage/src/Dasd.cc Wed Apr 1 16:55:29 2009 @@ -199,9 +199,9 @@ if( !reg.empty() && reg.find( '/' )!=string::npos && isdigit(reg[reg.length()-1]) ) reg += "p"; - reg += "[0-9]+"; - list<string> ps = ppart.getMatchingEntries( reg ); - y2mil("regex " << reg << " ps " << ps); + reg = "^" + reg + "[0-9]+" "$"; + list<string> ps = ppart.getMatchingEntries(regex_matches(reg)); + y2mil("regex:\"" << reg << "\" ps:" << ps); unsigned long dummy = 0; if( !checkPartedValid( ppart, nm, pl, dummy ) ) { Modified: trunk/storage/libstorage/src/Disk.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=56544&r1=56543&r2=56544&view=diff ============================================================================== --- trunk/storage/libstorage/src/Disk.cc (original) +++ trunk/storage/libstorage/src/Disk.cc Wed Apr 1 16:55:29 2009 @@ -872,9 +872,9 @@ if( !reg.empty() && reg.find( '/' )!=string::npos && isdigit(reg[reg.length()-1]) ) reg += "p"; - reg += "[0-9]+"; - list<string> ps = pp.getMatchingEntries( reg ); - y2mil("regex " << reg << " ps " << ps); + reg = "^" + reg + "[0-9]+" "$"; + list<string> ps = pp.getMatchingEntries(regex_matches(reg)); + y2mil("regex:\"" << reg << "\" ps:" << ps); for( list<string>::const_iterator i=ps.begin(); i!=ps.end(); i++ ) { pair<string,unsigned> p = getDiskPartition( *i ); Modified: trunk/storage/libstorage/src/ProcPart.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/ProcPart.cc?rev=56544&r1=56543&r2=56544&view=diff ============================================================================== --- trunk/storage/libstorage/src/ProcPart.cc (original) +++ trunk/storage/libstorage/src/ProcPart.cc Wed Apr 1 16:55:29 2009 @@ -5,7 +5,6 @@ #include "y2storage/AppUtil.h" -#include "y2storage/Regex.h" #include "y2storage/StorageTmpl.h" #include "y2storage/AsciiFile.h" #include "y2storage/ProcPart.h" @@ -59,15 +58,11 @@ list<string> - ProcPart::getMatchingEntries(const string& regexp) const + ProcPart::getEntries() const { - Regex reg("^" + regexp + "$"); list<string> ret; for (map<string, unsigned long long>::const_iterator i = data.begin(); i != data.end(); ++i) - { - if (reg.match(i->first)) - ret.push_back(i->first); - } + ret.push_back(i->first); return ret; } Modified: trunk/storage/libstorage/src/ProcPart.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/ProcPart.h?rev=56544&r1=56543&r2=56544&view=diff ============================================================================== --- trunk/storage/libstorage/src/ProcPart.h (original) +++ trunk/storage/libstorage/src/ProcPart.h Wed Apr 1 16:55:29 2009 @@ -24,7 +24,17 @@ bool getSize(const string& device, unsigned long long& sizeK) const; - list<string> getMatchingEntries(const string& regexp) const; + list<string> getEntries() const; + + template<class Pred> + list<string> getMatchingEntries(Pred pred) const + { + list<string> ret; + for (map<string, unsigned long long>::const_iterator i = data.begin(); i != data.end(); ++i) + if (pred(i->first)) + ret.push_back(i->first); + return ret; + } protected: -- 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