Edinburgh Speech Tools  2.1-release
EST_string_aux.h
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1994,1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author : Paul Taylor, Simon King */
34 /* Date : 1994-99 */
35 /*-----------------------------------------------------------------------*/
36 /* Utility EST_String Functions header file */
37 /* */
38 /*=======================================================================*/
39 
40 #ifndef __EST_STRING_AUX_H__
41 #define __EST_STRING_AUX_H__
42 
43 #include "EST_TList.h"
44 #include "EST_String.h"
45 #include "EST_types.h"
46 #include "EST_rw_status.h"
47 
48 /** \defgroup utilityfunctionsforstrings Utility functions for strings
49  */
50 
51 
52 /** \file
53  * \brief Utility EST_String Functions header file.
54  * \addtogroup utilityfunctionsforstrings
55  * @{
56  * \fn void StringtoStrList(EST_String s, EST_StrList &l, EST_String sep="")
57  * \brief Convert a EST_String to a EST_StrList by separating tokens in s delimited by the separator sep. By default, the string is assumed to be delimited by whitespace.
58  * \param s String to be split.
59  * \param l StringList the separated tokens will be stored.
60  * \param sep Token delimiter. By default, whitespace is used.
61  *
62  * \fn void BracketStringtoStrList(EST_String s, EST_StrList &l, EST_String sep="")
63  * \brief Convert a EST_String enclosed in a single set of brackets to a EST_StrList by separating tokens in s delimited by the separator sep. By default, the string is assumed to be delimited by whitespace.
64  * \fn EST_read_status load_StrList(EST_String filename, EST_StrList &l)
65  * \brief Load tokens from a file and return them in a EST_StrList
66  * \fn EST_write_status save_StrList(EST_String filename, EST_StrList &l, EST_String style="words")
67  * \brief Save tokens from a EST_StrList. If style is set to "lines" each item is stored on a separate line, otherwise each item is separated by a single space.
68  * \fn void strip_quotes(EST_String &s, const EST_String quote_char="\"")
69  * \brief remove quotes from a string
70  * \fn EST_String itoString(int n)
71  * \brief Make a EST_String object from an integer
72  * \fn EST_String ftoString(float n, int pres=3, int width=0, int l=0)
73  * \brief Make a EST_String object from an float, with variable precision
74  * \fn int Stringtoi(EST_String s)
75  * \brief Make an int from a EST_String. EST_String equivalent of atoi()
76  * \fn int StrListtoIList(EST_StrList &s, EST_IList &il)
77  * \brief Convert a list of strings to a list of integers
78  * \fn int StrListtoFList(EST_StrList &s, EST_FList &il)
79  * \brief Convert a list of strings to a list of floats
80  * \fn void StrList_to_StrVector(EST_StrList &l, EST_StrVector &v)
81  * \brief Convert a list of strings to a vector of strings
82  * \fn void StrVector_to_StrList(EST_StrVector &v,EST_StrList &l)
83  * \brief Convert a vector of strings to a list of strings
84  * \fn int StrVector_index(const EST_StrVector &v,const EST_String &s)
85  * \brief Search the vector and return the position of the first occurance of string s in the vector
86  * \fn int strlist_member(const EST_StrList &l,const EST_String &s)
87  * \brief Return true if s is in list l
88  * \fn int strlist_index(const EST_StrList &l,const EST_String &s)
89  * \brief Search the vector and return the position of the first occurance of string s in the list
90  * \fn EST_String basename(EST_String full, EST_String ext="")
91  * \brief This acts like the bourne shell basename command. By default, it strips any leading path from a string. If ext is defined, it strips any suffix matching this string.
92  * @}
93  */
94 
96 
98 
101  EST_String style="words");
102 
103 
104 void strip_quotes(EST_String &s, const EST_String quote_char="\"");
105 
106 // makes EST_String from integer.
107 EST_String itoString(int n);
108 // makes EST_String from float, with variable precision
109 EST_String ftoString(float n, int pres=3, int width=0, int l=0);
110 int Stringtoi(EST_String s);
111 
114 
117 long int StrVector_index(const EST_StrVector &v,const EST_String &s);
118 
119 int strlist_member(const EST_StrList &l,const EST_String &s);
120 long int strlist_index(const EST_StrList &l,const EST_String &s);
121 
122 // strips path off front of filename
124 
125 // this is not the right place for these
128 long int IVector_index(const EST_IVector &v,const int s);
129 
130 int ilist_member(const EST_IList &l,int i);
131 long int ilist_index(const EST_IList &l,int i);
132 
133 #endif // __EST_STRING_AUX_H__
void StrList_to_StrVector(EST_StrList &l, EST_StrVector &v)
Convert a list of strings to a vector of strings.
EST_write_status
EST_write_status save_StrList(EST_String filename, EST_StrList &l, EST_String style="words")
Save tokens from a EST_StrList. If style is set to "lines" each item is stored on a separate line...
int StrListtoIList(EST_StrList &s, EST_IList &il)
Convert a list of strings to a list of integers.
void BracketStringtoStrList(EST_String s, EST_StrList &l, EST_String sep="")
Convert a EST_String enclosed in a single set of brackets to a EST_StrList by separating tokens in s ...
long int IVector_index(const EST_IVector &v, const int s)
EST_String itoString(int n)
Make a EST_String object from an integer.
Definition: util_io.cc:141
long int ilist_index(const EST_IList &l, int i)
EST_String ftoString(float n, int pres=3, int width=0, int l=0)
Make a EST_String object from an float, with variable precision.
Definition: util_io.cc:149
void IVector_to_IList(EST_IVector &v, EST_IList &l)
int Stringtoi(EST_String s)
Make an int from a EST_String. EST_String equivalent of atoi()
Definition: util_io.cc:131
void StringtoStrList(EST_String s, EST_StrList &l, EST_String sep="")
Convert a EST_String to a EST_StrList by separating tokens in s delimited by the separator sep...
void StrVector_to_StrList(EST_StrVector &v, EST_StrList &l)
Convert a vector of strings to a list of strings.
EST_String basename(EST_String full, EST_String ext="")
This acts like the bourne shell basename command. By default, it strips any leading path from a strin...
Definition: util_io.cc:167
int ilist_member(const EST_IList &l, int i)
EST_read_status
int strlist_member(const EST_StrList &l, const EST_String &s)
Return true if s is in list l.
Template vector.
Definition: EST_TVector.h:145
long int strlist_index(const EST_StrList &l, const EST_String &s)
Search the vector and return the position of the first occurance of string s in the list...
void strip_quotes(EST_String &s, const EST_String quote_char="\"")
remove quotes from a string
Definition: util_io.cc:191
long int StrVector_index(const EST_StrVector &v, const EST_String &s)
Search the vector and return the position of the first occurance of string s in the vector...
void IList_to_IVector(EST_IList &l, EST_IVector &v)
int StrListtoFList(EST_StrList &s, EST_FList &il)
Convert a list of strings to a list of floats.
EST_read_status load_StrList(EST_String filename, EST_StrList &l)
Load tokens from a file and return them in a EST_StrList.