NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CStringPairs< TContainer > Class Template Reference

Search Toolkit Book for CStringPairs

Template for parsing string into pairs of name and value or merging them back into a single string. More...

#include <corelib/ncbistr.hpp>

+ Inheritance diagram for CStringPairs< TContainer >:
+ Collaboration diagram for CStringPairs< TContainer >:

Public Types

typedef TContainer TStrPairs
 
typedef TContainer::value_type TStrPair
 The container's value type must be pair<string, string> or a compatible type. More...
 

Public Member Functions

 CStringPairs (IStringDecoder *decoder=NULL, EOwnership own_decoder=eTakeOwnership, IStringEncoder *encoder=NULL, EOwnership own_encoder=eTakeOwnership)
 Create parser with the specified decoder/encoder and default separators. More...
 
 CStringPairs (const CTempString arg_sep, const CTempString val_sep, IStringDecoder *decoder=NULL, EOwnership own_decoder=eTakeOwnership, IStringEncoder *encoder=NULL, EOwnership own_encoder=eTakeOwnership)
 Create parser with the specified parameters. More...
 
 CStringPairs (NStr::EUrlDecode decode_flag, NStr::EUrlEncode encode_flag)
 Create parser with the selected URL-encoding/decoding options and default separators. More...
 
virtual ~CStringPairs (void)
 
void SetDecoder (IStringDecoder *decoder, EOwnership own=eTakeOwnership)
 Set string decoder. More...
 
IStringDecoderGetDecoder (void)
 Get decoder or NULL. Does not affect decoder ownership. More...
 
void SetEncoder (IStringEncoder *encoder, EOwnership own=eTakeOwnership)
 Set string encoder. More...
 
IStringEncoderGetEncoder (void)
 Get encoder or NULL. Does not affect encoder ownership. More...
 
void Parse (const CTempString str, NStr::EMergeDelims merge_argsep=NStr::eMergeDelims)
 Parse the string. More...
 
string Merge (void) const
 Merge name-value pairs into a single string using the currently set separators and the provided encoder if any. More...
 
const TStrPairsGetPairs (void) const
 Read data. More...
 
TStrPairsGetPairs (void)
 Get non-const data. More...
 

Static Public Member Functions

static void Parse (TStrPairs &pairs, const CTempString str, const CTempString arg_sep, const CTempString val_sep, IStringDecoder *decoder=NULL, EOwnership own=eTakeOwnership, NStr::EMergeDelims merge_argsep=NStr::eMergeDelims)
 Parse the string using the provided decoder, put data into the container. More...
 
static string Merge (const TStrPairs &pairs, const string &arg_sep, const string &val_sep, IStringEncoder *encoder=NULL, EOwnership own=eTakeOwnership)
 Merge name-value pairs from the provided container, separators and encoder. More...
 

Private Attributes

string m_ArgSep
 
string m_ValSep
 
AutoPtr< IStringDecoderm_Decoder
 
AutoPtr< IStringEncoderm_Encoder
 
TStrPairs m_Data
 

Detailed Description

template<class TContainer>
class CStringPairs< TContainer >

Template for parsing string into pairs of name and value or merging them back into a single string.

The container class must hold pairs of strings (pair<string, string>).

Examples
/home/coremake/doxygen/cxx/include/corelib/ncbistr.hpp.

Definition at line 4592 of file ncbistr.hpp.


The documentation for this class was generated from the following file:
Modified on Fri Dec 01 04:44:41 2023 by modify_doxy.py rev. 669887