TOP --> libjdl
A dynamic list of strings.
public CJdlStringList ( ) ;
Default constructor.
public CJdlStringList ( uint size ) ;
Constructor.
size | The initial size of the list. |
public CJdlStringList ( const CJdlStringList & ) ;
Copy constructor.
size | The initial size of the list. |
public CJdlStringList ( const char * str , const char * sep ) ;
Tokenizing constructor.
The constructor allows you to create a list of tokens from an input string. It is useful for parsing and is similar to the ::strtok() operator in "C".
Sample usage:
// Parse the tokens that are separated by colons. CJdlString str = "fld1:fld2:fld3:fld4::"; CJdlStringList list(str,":"); printf("token[0] = '%s'\n",0,token[0].str()); printf("token[1] = '%s'\n",0,token[1].str());
str | Input string. |
sep | Separator list. |
public ~ CJdlStringList ( ) ;
Destructor.
public void Append ( const char * str ) ;
Append a string to the list.
Sample usage:
#include "jdlstringlist.h" static void foo() { CJdlStringList list; list.Append("this"); list.Append("that"); list.Append("the"); list.Append("other"); list.Append("zzz"); list.Append("aaa"); }
str | The string to append. |
public void Append ( CJdlStringList & list ) ;
Append a string list to the list.
Sample usage:
#include "jdlstringlist.h" static void foo() { CJdlStringList list; list.Append("this"); list.Append("that"); list.Append("the"); list.Append("other"); list.Append("zzz"); list.Append("aaa"); CJdlStringList list1; list1.Append(list); }
list | The list to append. |
public const char * str ( CJdlString & out , const char * sep = 0 ) const ;
Convert a list to a string.
Sample usage:
#include "jdlstringlist.h" static void foo() { CJdlStringList list; list.Append("this"); list.Append("that"); list.Append("the"); list.Append("other"); list.Append("zzz"); list.Append("aaa"); CJdlString tmp; printf("list contents:",list.str(tmp,"\n\t"); printf("\n"); }
out | The string that will contain the output. |
sep | The separator. |
public void Tokenize ( const char * str , const char * sep ) ;
Tokenize a string and store the substrings in this list.
Sample usage:
// Parse the tokens that are separated by colons. CJdlString str = "fld1:fld2:fld3:fld4::"; CJdlStringList list; list.Tokenize(str,":"); printf("token[0] = '%s'\n",0,token[0].str()); printf("token[1] = '%s'\n",0,token[1].str());
str | Input string. |
sep | Separator list. |
public void ReadDir ( const char * dir , bool sort = true ) ;
Read the contents of a directory and append it to this list.
The file names in the returned list do not have the root directory pre-pended.
An example is shown below:
CJdlString list; list.ReadDir("."); for(uint i=0;i<list.Length();i++) { printf("file[%03d] = '%s'\n",list[i].str()); }
dir | The path to the directory. This is O/S dependent. If the dir string is NULL, it is ignored and no directory processing takes place. |
sort | If true, sort the list in ascending order with case sensitivity, otherwise do not sort the list. If you wish to sort the list in another way, see the CJdlStringListSorter class. |
public bool BinarySearchFor ( const char * str ) const ;
Do binary search to see whether the specified string exists in the list. This is only valid for sorted lists.
str | The string to search for. |
public bool SearchFor ( const char * str ) const ;
Do linear search to see whether the specified string exists in the list.
str | The string to search for. |
public void Copy ( const CJdlStringList & list ) ;
Copy.
list | The list to copy. |
public CJdlStringList & operator = ( const CJdlStringList & list ) ;
Copy operator.
list | The object to copy. |
This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.
Click here to return to the top of the page.