NameList Class Reference

NameList class - Encapsulates a vector of strings, adding conveniences for tasks liking saving to / loading from files, or determining the length of the longest string in the set. More...

#include <NameList.h>

List of all members.

Public Member Functions

 NameList ()
 Create an empty NameList, then use add() to fill it.
 NameList (vector< std::string > &names)
 Create a NameList, and then fill it from the passed vector.
 NameList (NameList &nl)
 Create a clone of the passed NameList.
 NameList (const char *fname)
 Create a NameList, and fill it from whitespace-separated strings in the passed file.
 NameList (string &list)
 Create a NameList, and fill it by parsing the passed string, breaking at whitespace.
void load (const char *fname)
 Fills the NameList from whitespace-separated strings in the passed file.
int size ()
 Returns the number of stored names.
void add (const string &name)
 Adds a string to the set.
const string & at (int i)
 Returns the string stored at position i.
bool operator== (NameList &a)
 Returns true if the lists are the same length and each entry is the same.
bool operator!= (NameList &a)
 The converse of the '==' operator.
int getIndex (const string &name)
 If the passed string is identical to one of the stored entries, returns the entry's index.
int maxNameLen ()
 Returns the length of the longest stored string.

Friends

ostream & operator<< (ostream &s, NameList &nl)
 Prints the entries in the NameList, separated by spaces, preceded by "[ ", and with the suffix "] ".
istream & operator>> (istream &s, NameList &nl)
 Reads a NameList from the passed istream.


Detailed Description

NameList class - Encapsulates a vector of strings, adding conveniences for tasks liking saving to / loading from files, or determining the length of the longest string in the set.


Constructor & Destructor Documentation

NameList::NameList  ) 
 

Create an empty NameList, then use add() to fill it.

NameList::NameList vector< std::string > &  names  ) 
 

Create a NameList, and then fill it from the passed vector.

NameList::NameList NameList nl  ) 
 

Create a clone of the passed NameList.

NameList::NameList const char *  fname  ) 
 

Create a NameList, and fill it from whitespace-separated strings in the passed file.

NameList::NameList string &  list  ) 
 

Create a NameList, and fill it by parsing the passed string, breaking at whitespace.


Member Function Documentation

void NameList::add const string &  name  ) 
 

Adds a string to the set.

const string & NameList::at int  i  ) 
 

Returns the string stored at position i.

int NameList::getIndex const string &  name  ) 
 

If the passed string is identical to one of the stored entries, returns the entry's index.

void NameList::load const char *  fname  ) 
 

Fills the NameList from whitespace-separated strings in the passed file.

int NameList::maxNameLen  ) 
 

Returns the length of the longest stored string.

bool NameList::operator!= NameList a  ) 
 

The converse of the '==' operator.

bool NameList::operator== NameList a  ) 
 

Returns true if the lists are the same length and each entry is the same.

int NameList::size  ) 
 

Returns the number of stored names.


Friends And Related Function Documentation

ostream& operator<< ostream &  s,
NameList nl
[friend]
 

Prints the entries in the NameList, separated by spaces, preceded by "[ ", and with the suffix "] ".

istream& operator>> istream &  s,
NameList nl
[friend]
 

Reads a NameList from the passed istream.

The "[" and "]" are optional


The documentation for this class was generated from the following files:
Generated on Tue Dec 13 11:00:27 2005 for Classer by  doxygen 1.4.3