\section{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$>$}\\*
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\\*
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\\*
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum {\bf string\+\_\+edge\+\_\+e} \{ {\bf S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T}, 
{\bf S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D}, 
{\bf S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H}
 \}
\begin{DoxyCompactList}\small\item\em Which end of a string to operate on for \doxyref{string\+\_\+trim()}{p.}{strfuncs_8h_ac36a095632a4f16cf4e0fbcdb01de5ad}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T char $\ast$ {\bf string\+\_\+join} (const char $\ast$base,...)\label{strfuncs_8h_a317522f23d291311e366de34ef86b777}

\begin{DoxyCompactList}\small\item\em Concatenate a N\+U\+L\+L-\/terminated argument list of strings, returning a newly allocated string. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T char $\ast$ {\bf string\+\_\+trim} (char $\ast$string, enum {\bf string\+\_\+edge\+\_\+e} which)
\begin{DoxyCompactList}\small\item\em Remove whitespace from a string, modifying it in-\/place. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T double {\bf atof\+\_\+c} (char const $\ast$str)
\begin{DoxyCompactList}\small\item\em Locale independent version of atof(). \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T uint32 {\bfseries utf8\+\_\+decode} (uint32 $\ast$state, uint32 $\ast$codep, uint32 $\ast$byte)\label{strfuncs_8h_aab1bdad6b50285de4b7cd042f67314dd}

\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf str2words} (char $\ast$line, char $\ast$$\ast$wptr, int32 n\+\_\+wptr)
\begin{DoxyCompactList}\small\item\em Convert a line to an array of \char`\"{}words\char`\"{}, based on whitespace separators. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf 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 \char`\"{}next-\/word-\/in-\/string\char`\"{} function. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Miscellaneous useful string functions. 



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



\subsection{Enumeration Type Documentation}
\index{strfuncs.\+h@{strfuncs.\+h}!string\+\_\+edge\+\_\+e@{string\+\_\+edge\+\_\+e}}
\index{string\+\_\+edge\+\_\+e@{string\+\_\+edge\+\_\+e}!strfuncs.\+h@{strfuncs.\+h}}
\subsubsection[{string\+\_\+edge\+\_\+e}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf string\+\_\+edge\+\_\+e}}\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9}


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

\begin{Desc}
\item[Enumerator]\par
\begin{description}
\index{S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T@{S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T}!strfuncs.\+h@{strfuncs.\+h}}\index{strfuncs.\+h@{strfuncs.\+h}!S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T@{S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T}}\item[{\em 
S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9a5e4d73e6ca445be10fa48351b9571125}
}]Beginning of string. \index{S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D@{S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D}!strfuncs.\+h@{strfuncs.\+h}}\index{strfuncs.\+h@{strfuncs.\+h}!S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D@{S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D}}\item[{\em 
S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9a11f31598e50bf3cf1d0aa97d967bb9b9}
}]End of string. \index{S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H@{S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H}!strfuncs.\+h@{strfuncs.\+h}}\index{strfuncs.\+h@{strfuncs.\+h}!S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H@{S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H}}\item[{\em 
S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H\label{strfuncs_8h_ab5c9ca15770a4bd3047705762b815df9a4fcbb0fe16fa4aa48723ba3ba10c26dd}
}]Both ends of string. \end{description}
\end{Desc}


Definition at line 70 of file strfuncs.\+h.



\subsection{Function Documentation}
\index{strfuncs.\+h@{strfuncs.\+h}!atof\+\_\+c@{atof\+\_\+c}}
\index{atof\+\_\+c@{atof\+\_\+c}!strfuncs.\+h@{strfuncs.\+h}}
\subsubsection[{atof\+\_\+c}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T double atof\+\_\+c (
\begin{DoxyParamCaption}
\item[{char const $\ast$}]{str}
\end{DoxyParamCaption}
)}\label{strfuncs_8h_ab708351fe7308551632a782bfad75a1e}


Locale independent version of atof(). 

This function behaves like atof() in the \char`\"{}\+C\char`\"{} 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 56 of file strfuncs.\+c.



Referenced by logmath\+\_\+read().

\index{strfuncs.\+h@{strfuncs.\+h}!nextword@{nextword}}
\index{nextword@{nextword}!strfuncs.\+h@{strfuncs.\+h}}
\subsubsection[{nextword}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 nextword (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{line, }
\item[{const char $\ast$}]{delim, }
\item[{char $\ast$$\ast$}]{word, }
\item[{char $\ast$}]{delimfound}
\end{DoxyParamCaption}
)}\label{strfuncs_8h_a41d9a59e4326b545bf1282401319f553}


Yet another attempt at a clean \char`\"{}next-\/word-\/in-\/string\char`\"{} 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 (N\+U\+L 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 N\+U\+L\+L 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 N\+U\+L\+L 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 158 of file strfuncs.\+c.

\index{strfuncs.\+h@{strfuncs.\+h}!str2words@{str2words}}
\index{str2words@{str2words}!strfuncs.\+h@{strfuncs.\+h}}
\subsubsection[{str2words}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 str2words (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{line, }
\item[{char $\ast$$\ast$}]{wptr, }
\item[{int32}]{n\+\_\+wptr}
\end{DoxyParamCaption}
)}\label{strfuncs_8h_a5b520fdebcca599db86faaf75a82173f}


Convert a line to an array of \char`\"{}words\char`\"{}, 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\+: N\+U\+L\+L 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! (N\+U\+L 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 N\+U\+L\+L 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, N\+U\+L\+L, 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 == N\+U\+L\+L \\
\hline
\end{DoxyParams}


Definition at line 115 of file strfuncs.\+c.

\index{strfuncs.\+h@{strfuncs.\+h}!string\+\_\+trim@{string\+\_\+trim}}
\index{string\+\_\+trim@{string\+\_\+trim}!strfuncs.\+h@{strfuncs.\+h}}
\subsubsection[{string\+\_\+trim}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T char$\ast$ string\+\_\+trim (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{string, }
\item[{enum {\bf string\+\_\+edge\+\_\+e}}]{which}
\end{DoxyParamCaption}
)}\label{strfuncs_8h_ac36a095632a4f16cf4e0fbcdb01de5ad}


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 S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T, S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D, or S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H. \\
\hline
\end{DoxyParams}


Definition at line 89 of file strfuncs.\+c.



References S\+T\+R\+I\+N\+G\+\_\+\+B\+O\+T\+H, S\+T\+R\+I\+N\+G\+\_\+\+E\+N\+D, and S\+T\+R\+I\+N\+G\+\_\+\+S\+T\+A\+R\+T.



Referenced by lineiter\+\_\+next(), and lineiter\+\_\+start\+\_\+clean().

