Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

PMString Class Reference

The Package Manger string class. More...

#include <pmstring.h>

List of all members.

Public Member Functions

 PMString ()
 Inherits from std::string.
 PMString (const char *ptr)
 Inherits from std::string.
 PMString (const std::string &s)
 Inherits from std::string.
 PMString (size_type length, const char &ch)
 Inherits from std::string.
 PMString (const char *str, size_type length)
 Inherits from std::string.
 PMString (const std::string &str, size_type index, size_type length)
 Inherits from std::string.
std::vector< PMStringSplit (char const *delims=" \t\r\n")
 Split the string around delims and return a vector of the split. Delims defaults to whitespace.
std::vector< PMStringProcessUseFlags (std::vector< PMString > useFlags)
 Removes atoms not associated with useflags provided.
PMString GetName ()
 Returns the name when string is in cat/name-version format.
PMString GetCategory ()
 Returns the category when string is in cat/name-version format.
PMString GetVersion ()
 Returns the version when string is in cat/name-version format.
PMString GetFileName ()
 Returns the filename if string is in the form dir/dir/filename.
void TrimWhitespace ()
 Remove the whitespace from either end of the string.
void FormatSize (int size)
 Format the string as a size - should only be called if the string only contains numbers.
int VersionCompare (PMString secondVersion)
 Compare this string with secondVersion string.
bool StartsWith (PMString secondString)
 True if this starts with secondString.

Protected Member Functions

std::vector< PMString >::iterator _BypassBrackets (std::vector< PMString >::iterator currentLocation, std::vector< PMString >::iterator endLocation)
 Go out of scope of the current bracket.


Detailed Description

Simple inherited class to inherit from std::string. Includes some string manipulation functions useful to the package manager.


Member Function Documentation

std::vector< PMString >::iterator PMString::_BypassBrackets std::vector< PMString >::iterator  currentLocation,
std::vector< PMString >::iterator  endLocation
[protected]
 

Goes out of scope of the brackets pointed to by currentLocation.

Parameters:
currentLocation The location of the first bracket.
endLocation The location of the end of the vector.
Returns:
An Iterator to the first string out of the scope of the brackets.

void PMString::FormatSize int  size  ) 
 

Take an integer and format the string as the integer treated as a filesize. Adds Kb to the end of the string.

Parameters:
size The filesize to put as a filesize in the string.

PMString PMString::GetCategory  ) 
 

Takes in a PMString of the form category/name-version and returns the category of the package.

Returns:
The Category of the Package.

PMString PMString::GetFileName  ) 
 

Returns the filename from a string. i.e. substring from the last /.

Returns:
The filename.

PMString PMString::GetName  ) 
 

Takes in a PMString of the form category/name-version and returns the name of the package. It assumes that name is the only present quantity if the format is not met.

Returns:
The Name of the Package.

PMString PMString::GetVersion  ) 
 

Takes in a PMString of the form category/name-version and returns the version of the package.

Returns:
The Version of the Package.

std::vector< PMString > PMString::ProcessUseFlags std::vector< PMString useFlags  ) 
 

Removes all useflags not contained in useFlags. Removes the atoms associated with it too. For use in dependency strings.

Parameters:
useFlags The useflags to allow.
Returns:
The atoms that are allowed by useFlags.

std::vector< PMString > PMString::Split char const *  delims = " \t\r\n"  ) 
 

Splits the string around the delims and returns a vector of the resultant strings. delims has a default value of whitespace.

Parameters:
delims The characters to split around. Default to whitespace.
Returns:
A vector of the resultant values.

bool PMString::StartsWith PMString  secondString  ) 
 

Returns true if this starts with secondString.

Parameters:
secondString The string to test this string starts with.
Returns:
true if this string starts with secondString.

void PMString::TrimWhitespace  ) 
 

Remove whitespace from the start and end of the string.

int PMString::VersionCompare PMString  secondVersion  ) 
 

Compare a string with this one. Assumes they are both versions and does the comparison as such. Examines the string from the start and as soon as it sees a difference it returns. This really should be as quick as possible as it is called all the time Returns 1 if secondVersion is newer, -1 if this is newer and 0 if they are the same.

Parameters:
secondVersion The version number to test against.
Returns:
1 if second version is newer. 0 if the two versions are the same. -1 is this string is newer.
Exceptions:
PortageException(eBadVersionCompare,thisVersion secondVersion)
PortageException(eEmptyVersionCompare) 


The documentation for this class was generated from the following files:
Generated on Wed May 25 15:29:54 2005 for Package Management System for Gentoo Linux by  doxygen 1.4.1