\doxysection{include/sphinxbase/strfuncs.h File Reference}
\label{strfuncs_8h}\index{include/sphinxbase/strfuncs.h@{include/sphinxbase/strfuncs.h}}


Miscellaneous useful string functions.  


{\ttfamily \#include $<$stdarg.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
\doxysubsubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ string\+\_\+edge\+\_\+e} \{ \textbf{ STRING\+\_\+\+START}
, \textbf{ STRING\+\_\+\+END}
, \textbf{ STRING\+\_\+\+BOTH}
 \}
\begin{DoxyCompactList}\small\item\em Which end of a string to operate on for \doxyref{string\+\_\+trim()}{p.}{strfuncs_8h_a46cec779df97c32fa432d4792722931d}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
SPHINXBASE\+\_\+\+EXPORT char $\ast$ \textbf{ string\+\_\+join} (const char $\ast$base,...)
\begin{DoxyCompactList}\small\item\em Concatenate a NULL-\/terminated argument list of strings, returning a newly allocated string. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT char $\ast$ \textbf{ string\+\_\+trim} (char $\ast$string, enum \textbf{ string\+\_\+edge\+\_\+e} which)
\begin{DoxyCompactList}\small\item\em Remove whitespace from a string, modifying it in-\/place. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT double \textbf{ atof\+\_\+c} (char const $\ast$str)
\begin{DoxyCompactList}\small\item\em Locale independent version of atof(). \end{DoxyCompactList}\item 
\label{strfuncs_8h_aab1bdad6b50285de4b7cd042f67314dd} 
SPHINXBASE\+\_\+\+EXPORT uint32 {\bfseries utf8\+\_\+decode} (uint32 $\ast$state, uint32 $\ast$codep, uint32 $\ast$byte)
\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ str2words} (char $\ast$line, char $\ast$$\ast$wptr, int32 n\+\_\+wptr)
\begin{DoxyCompactList}\small\item\em Convert a line to an array of "{}words"{}, based on whitespace separators. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT int32 \textbf{ nextword} (char $\ast$line, const char $\ast$delim, char $\ast$$\ast$word, char $\ast$delimfound)
\begin{DoxyCompactList}\small\item\em Yet another attempt at a clean "{}next-\/word-\/in-\/string"{} function. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Miscellaneous useful string functions. 



Definition in file \textbf{ strfuncs.\+h}.



\doxysubsection{Enumeration Type Documentation}
\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9} 
\index{strfuncs.h@{strfuncs.h}!string\_edge\_e@{string\_edge\_e}}
\index{string\_edge\_e@{string\_edge\_e}!strfuncs.h@{strfuncs.h}}
\doxysubsubsection{string\_edge\_e}
{\footnotesize\ttfamily enum \textbf{ string\+\_\+edge\+\_\+e}}



Which end of a string to operate on for \doxyref{string\+\_\+trim()}{p.}{strfuncs_8h_a46cec779df97c32fa432d4792722931d}. 

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{STRING\_START@{STRING\_START}!strfuncs.h@{strfuncs.h}}\index{strfuncs.h@{strfuncs.h}!STRING\_START@{STRING\_START}}}\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9a5e4d73e6ca445be10fa48351b9571125} 
STRING\+\_\+\+START&Beginning of string. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{STRING\_END@{STRING\_END}!strfuncs.h@{strfuncs.h}}\index{strfuncs.h@{strfuncs.h}!STRING\_END@{STRING\_END}}}\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9a11f31598e50bf3cf1d0aa97d967bb9b9} 
STRING\+\_\+\+END&End of string. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{STRING\_BOTH@{STRING\_BOTH}!strfuncs.h@{strfuncs.h}}\index{strfuncs.h@{strfuncs.h}!STRING\_BOTH@{STRING\_BOTH}}}\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9a4fcbb0fe16fa4aa48723ba3ba10c26dd} 
STRING\+\_\+\+BOTH&Both ends of string. \\
\hline

\end{DoxyEnumFields}


Definition at line \textbf{ 70} of file \textbf{ strfuncs.\+h}.



\doxysubsection{Function Documentation}
\label{strfuncs_8h_ab708351fe7308551632a782bfad75a1e} 
\index{strfuncs.h@{strfuncs.h}!atof\_c@{atof\_c}}
\index{atof\_c@{atof\_c}!strfuncs.h@{strfuncs.h}}
\doxysubsubsection{atof\_c()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT double atof\+\_\+c (\begin{DoxyParamCaption}\item[{char const $\ast$}]{str }\end{DoxyParamCaption})}



Locale independent version of atof(). 

This function behaves like atof() in the "{}\+C"{} locale. Switching locale in a threaded program is extremely uncool, therefore we need this since we pass floats as strings in 1000 different places. 

Definition at line \textbf{ 56} of file \textbf{ strfuncs.\+c}.



References \textbf{ atof\+\_\+c()}.



Referenced by \textbf{ atof\+\_\+c()}, and \textbf{ logmath\+\_\+read()}.

\label{strfuncs_8h_a41d9a59e4326b545bf1282401319f553} 
\index{strfuncs.h@{strfuncs.h}!nextword@{nextword}}
\index{nextword@{nextword}!strfuncs.h@{strfuncs.h}}
\doxysubsubsection{nextword()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 nextword (\begin{DoxyParamCaption}\item[{char $\ast$}]{line,  }\item[{const char $\ast$}]{delim,  }\item[{char $\ast$$\ast$}]{word,  }\item[{char $\ast$}]{delimfound }\end{DoxyParamCaption})}



Yet another attempt at a clean "{}next-\/word-\/in-\/string"{} function. 

See arguments below. \begin{DoxyReturn}{Returns}
Length of word returned, or -\/1 if nothing found. This allows you to scan through a line\+:
\end{DoxyReturn}

\begin{DoxyPre}
while ((n = nextword(line, delim, \&word, \&delimfound)) >= 0) \{
    ... do something with word ..
    word[n] = delimfound;
    line = word + n;
\}
\end{DoxyPre}
 
\begin{DoxyParams}{Parameters}
{\em line} & Input\+: String being searched for next word. Will be modified by this function (NUL characters inserted)  \\
\hline
{\em delim} & Input\+: A word, if found, must be delimited at either end by a character from this string (or at the end by the NULL char)  \\
\hline
{\em word} & Output\+: $\ast$word = ptr within line to beginning of first word, if found. Delimiter at the end of word replaced with the NULL char.  \\
\hline
{\em delimfound} & Output\+: $\ast$delimfound = original delimiter found at the end of the word. (This way, the caller can restore the delimiter, preserving the original string.) \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 158} of file \textbf{ strfuncs.\+c}.



References \textbf{ nextword()}.



Referenced by \textbf{ nextword()}.

\label{strfuncs_8h_a5b520fdebcca599db86faaf75a82173f} 
\index{strfuncs.h@{strfuncs.h}!str2words@{str2words}}
\index{str2words@{str2words}!strfuncs.h@{strfuncs.h}}
\doxysubsubsection{str2words()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT int32 str2words (\begin{DoxyParamCaption}\item[{char $\ast$}]{line,  }\item[{char $\ast$$\ast$}]{wptr,  }\item[{int32}]{n\+\_\+wptr }\end{DoxyParamCaption})}



Convert a line to an array of "{}words"{}, based on whitespace separators. 

A word is a string with no whitespace chars in it. Note that the string line is modified as a result\+: NULL chars are placed after every word in the line. Return value\+: No. of words found; -\/1 if no. of words in line exceeds n\+\_\+wptr. 
\begin{DoxyParams}{Parameters}
{\em line} & In/\+Out\+: line to be parsed. This string will be modified! (NUL characters inserted at word boundaries)  \\
\hline
{\em wptr} & In/\+Out\+: Array of pointers to words found in line. The array must be allocated by the caller. It may be NULL in which case the number of words will be counted. This allows you to allcate it to the proper size, e.\+g.\+:\\
\hline
\end{DoxyParams}
n = str2words(line, NULL, 0); wptr = \doxyref{ckd\+\_\+calloc(n, sizeof($\ast$wptr))}{p.}{ckd__alloc_8h_aa00ef21903bc4f8a972488417adc8d2e}; str2words(line, wptr, n);  
\begin{DoxyParams}{Parameters}
{\em n\+\_\+wptr} & In\+: Size of wptr array, ignored if wptr == NULL \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 115} of file \textbf{ strfuncs.\+c}.



References \textbf{ str2words()}.



Referenced by \textbf{ str2words()}.

\label{strfuncs_8h_a4fc6c9f6c763819b16c4e3307fb67cb1} 
\index{strfuncs.h@{strfuncs.h}!string\_join@{string\_join}}
\index{string\_join@{string\_join}!strfuncs.h@{strfuncs.h}}
\doxysubsubsection{string\_join()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT char $\ast$ string\+\_\+join (\begin{DoxyParamCaption}\item[{const char $\ast$}]{base,  }\item[{}]{... }\end{DoxyParamCaption})}



Concatenate a NULL-\/terminated argument list of strings, returning a newly allocated string. 



Definition at line \textbf{ 62} of file \textbf{ strfuncs.\+c}.



References \textbf{ ckd\+\_\+calloc}, and \textbf{ string\+\_\+join()}.



Referenced by \textbf{ fopen\+\_\+comp()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+read()}, and \textbf{ string\+\_\+join()}.

\label{strfuncs_8h_a46cec779df97c32fa432d4792722931d} 
\index{strfuncs.h@{strfuncs.h}!string\_trim@{string\_trim}}
\index{string\_trim@{string\_trim}!strfuncs.h@{strfuncs.h}}
\doxysubsubsection{string\_trim()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT char $\ast$ string\+\_\+trim (\begin{DoxyParamCaption}\item[{char $\ast$}]{string,  }\item[{enum \textbf{ string\+\_\+edge\+\_\+e}}]{which }\end{DoxyParamCaption})}



Remove whitespace from a string, modifying it in-\/place. 


\begin{DoxyParams}{Parameters}
{\em string} & string to trim, contents will be modified. \\
\hline
{\em which} & one of STRING\+\_\+\+START, STRING\+\_\+\+END, or STRING\+\_\+\+BOTH. \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 89} of file \textbf{ strfuncs.\+c}.



References \textbf{ STRING\+\_\+\+BOTH}, \textbf{ STRING\+\_\+\+END}, \textbf{ STRING\+\_\+\+START}, and \textbf{ string\+\_\+trim()}.



Referenced by \textbf{ lineiter\+\_\+next()}, \textbf{ lineiter\+\_\+start\+\_\+clean()}, and \textbf{ string\+\_\+trim()}.

