CNVList
Name/value string pair list management class
[Previous] [Main] [Next]


Description
CNVList is a general-purpose, standalone class that provides management, storage, retrieval, and enumeration of name/value string pairs. Many aspects of HTML involve name/value pairs (e.g., forms, configuration files). This class is provided as a convenience to the developer.  
 
Declaration
#include <dcmicro/htmlpp/nvlist.h>  
 
Hierarchy
cnvlist.gif  
 
See Also
None.  
 
Related Constants/Definitions
None.  
 
Constructors
CNVList()  
Constructs an empty object.  
 
CNVList( const CNVList& rhs )  
Copy constructor.  
 
Destructors
virtual ~CNVList()  
Destroys the object.  
 
Member Methods
=   CNVList& operator= ( const CNVList& rhs )  
Replaces list contents with a copy of rhs and returns a reference to the list.  
 
( )   String& operator ( ) ( const String& name )  
Accepts a name string and returns a reference to the appropriate value string object, creating one if it doesn't exist. This makes it very convenient to create name/value pairs on-the-fly for use in the left side of an assignment.  
 
ValueCNVList& Value( const String& name, const String& value )  
Adds or replaces name in the list, associating string value with it.  
 
ValueCNVList& Value( const String& name, int value )  
Adds or replaces name in the list, converting value to a string and associating it with name.  
 
ValueString Value( const String& name ) const  
Retrieve a copy of the value associated with name from the list as a string (empty string if not found).  
 
ValueAsIntint ValueAsInt( const String& name ) const  
Retrieve the value associated with name from the list as an integer (zero if not found).  
 
ExistsBoolean Exists( const String& name ) const  
Returns TRUE if a value exists for name in the list, FALSE if no value exists.  
 
EnumerateBoolean Enumerate( String& name, String& value, Boolean first = FALSE )  
Consecutively traverses all name/value pairs stored in the list. Returns TRUE as long as there are values to enumerate, returning the strings in name and value. If first is TRUE, traversal will begin at the start of the list. Otherwise, traversal resumes from the list position at the last call.  
 
EnumerateName String EnumerateName( const String& starting_name  
) const  
Similar to Enumerate, consecutively traversing the list of name/value pairs. It differs in that the return parameter is a string containing the next name in the list, and the starting_name argument represents the point in the list at which searching begins. If starting_name is an empty string (e.g., "") searching will start at the first item in the list. EnumerateName will continue returning string names as long as there are name/value pairs to enumerate.  
 
The value associated with the returned name can be obtained using the Value() method or the () operator. An empty string is returned when the end of the list is reached.  
 
Countint Count() const  
Returns the number of name/value pairs stored in the list.  
 
Resetvoid Reset()  
Empties the list of all name/value pairs.  
 
Example Use
 
See the example in Tutorial : Using html++ : CNVList  
 


©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.