\hypertarget{_number_unit_to_text_8h_source}{}\doxysection{Number\+Unit\+To\+Text.\+h}
\label{_number_unit_to_text_8h_source}\index{src/NumberUnitToText.h@{src/NumberUnitToText.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}NumberToText.h"{}}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{keyword}{namespace\ }simple\_tts\ \{}
\DoxyCodeLine{00005\ }
\DoxyCodeLine{00013\ \textcolor{keyword}{class\ }\mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text}{NumberUnitToText}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{classsimple__tts_1_1_simple_t_t_s_base}{SimpleTTSBase}}\ \{}
\DoxyCodeLine{00014\ \ \textcolor{keyword}{public}:}
\DoxyCodeLine{00015\ \ \ \textcolor{comment}{//\ Default\ constructor\ with\ no\ default\ unit}}
\DoxyCodeLine{00016\ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text}{NumberUnitToText}}()\ =\ \textcolor{keywordflow}{default};}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ \ \ \textcolor{comment}{//\ Constructor\ which\ assigns\ a\ default\ uinit\ so\ that\ we\ do\ not\ need\ to\ provide}}
\DoxyCodeLine{00019\ \ \ \textcolor{comment}{//\ it}}
\DoxyCodeLine{00020\ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text}{NumberUnitToText}}(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ defaultUnit)\ \{\ default\_unit\ =\ defaultUnit;\ \}}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00023\ \ \ audio\_tools::Vector<const\ char*>\&\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aaca7f2bfba41ce229addd8d8177a95d0}{say}}(\textcolor{keywordtype}{double}\ value,}
\DoxyCodeLine{00024\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit\ =\ \textcolor{keyword}{nullptr},}
\DoxyCodeLine{00025\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ decimals\ =\ 2)\ \{}
\DoxyCodeLine{00026\ \ \ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number}{Number}}\ number;}
\DoxyCodeLine{00027\ \ \ \ \ number.set(value,\ decimals);}
\DoxyCodeLine{00028\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aaca7f2bfba41ce229addd8d8177a95d0}{say}}(number.\mbox{\hyperlink{classsimple__tts_1_1_number_a0768e8ce47dff8521cec1e662587da32}{intValue}}(),\ number.\mbox{\hyperlink{classsimple__tts_1_1_number_a33e8504471cb6f4ab31a43b178ec26e5}{decValues}}(),\ unit);}
\DoxyCodeLine{00029\ \ \ \}}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00032\ \ \ audio\_tools::Vector<const\ char*>\&\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_a5e192470d25434cd6d45aec3916fc409}{say}}(int64\_t\ wholeNumber,}
\DoxyCodeLine{00033\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit\ =\ \textcolor{keyword}{nullptr})\ \{}
\DoxyCodeLine{00034\ \ \ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number}{Number}}\ number;}
\DoxyCodeLine{00035\ \ \ \ \ number.set(wholeNumber);}
\DoxyCodeLine{00036\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aaca7f2bfba41ce229addd8d8177a95d0}{say}}(number.\mbox{\hyperlink{classsimple__tts_1_1_number_a0768e8ce47dff8521cec1e662587da32}{intValue}}(),\ number.\mbox{\hyperlink{classsimple__tts_1_1_number_a33e8504471cb6f4ab31a43b178ec26e5}{decValues}}(),\ unit);}
\DoxyCodeLine{00037\ \ \ \}}
\DoxyCodeLine{00038\ }
\DoxyCodeLine{00040\ \ \ audio\_tools::Vector<const\ char*>\&\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_acf1210691e7681c739e27e6cba875bcf}{say}}(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ wholeNumber,}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ decimals,}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unitIn)\ \{}
\DoxyCodeLine{00043\ \ \ \ \ result.clear();}
\DoxyCodeLine{00044\ }
\DoxyCodeLine{00045\ \ \ \ \ \textcolor{comment}{//\ determine\ unit}}
\DoxyCodeLine{00046\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit\ =\ unitIn\ ?\ unitIn\ :\ default\_unit;}
\DoxyCodeLine{00047\ \ \ \ \ \textcolor{comment}{//\ singular\ or\ plural\ ?}}
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keywordtype}{bool}\ isOne\ =\ Str(wholeNumber).toLong()\ ==\ 1l;}
\DoxyCodeLine{00049\ }
\DoxyCodeLine{00050\ \ \ \ \ \textcolor{comment}{//\ We\ support\ 2\ scenarios:\ combined\ units\ or\ just\ a\ smple\ number\ with\ a\ single\ unit.}}
\DoxyCodeLine{00051\ \ \ \ \ \textcolor{keywordtype}{int}\ idx\ =\ idxCombinedUnit(unit);}
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keywordflow}{if}\ (idx\ ==\ -\/1)\ \{}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \textcolor{comment}{//\ Simple\ units\ scenario}}
\DoxyCodeLine{00054\ \ \ \ \ \ \ addAll(ntt.\mbox{\hyperlink{classsimple__tts_1_1_number_to_text_aa5cb276b1a65ece56fcae76bb22b6e1d}{say}}(wholeNumber,\ decimals));}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aa2ef301472f16644e12ca377537188a0}{process}}(unit,\ isOne);}
\DoxyCodeLine{00056\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \textcolor{comment}{//\ Combined\ units\ -\/>}}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \textcolor{comment}{//\ say\ the\ wholeNumber\ first}}
\DoxyCodeLine{00059\ \ \ \ \ \ \ addAll(ntt.\mbox{\hyperlink{classsimple__tts_1_1_number_to_text_aa5cb276b1a65ece56fcae76bb22b6e1d}{say}}(wholeNumber));}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \textcolor{comment}{//\ say\ whole\ number\ unit}}
\DoxyCodeLine{00061\ \ \ \ \ \ \ processCombinedUnit(idx,\ isOne);}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \textcolor{comment}{//\ combine\ them\ with\ AND}}
\DoxyCodeLine{00063\ \ \ \ \ \ \ add(\textcolor{stringliteral}{"{}AND"{}});}
\DoxyCodeLine{00064\ \ \ \ \ \ \ \textcolor{comment}{//\ say\ converted\ decimals}}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number}{Number}}\ calc;}
\DoxyCodeLine{00066\ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ digits\ =\ decimalInfo(unit);}
\DoxyCodeLine{00067\ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ decimals\_to\_say\ =\ calc.decAsInt(decimals,\ digits);}
\DoxyCodeLine{00068\ \ \ \ \ \ \ addAll(ntt.\mbox{\hyperlink{classsimple__tts_1_1_number_to_text_aa5cb276b1a65ece56fcae76bb22b6e1d}{say}}(decimals\_to\_say));}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \textcolor{comment}{//\ say\ decimals\ unit}}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ decIsOne\ =\ Str(decimals).toLong()\ ==\ 1l;}
\DoxyCodeLine{00071\ \ \ \ \ \ \ processDecimalUnit(idx,\ decIsOne);}
\DoxyCodeLine{00072\ \ \ \ \ \}}
\DoxyCodeLine{00073\ }
\DoxyCodeLine{00074\ \ \ \ \ \textcolor{comment}{//\ provide\ result\ to\ callback}}
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{keywordflow}{if}\ (callback)\{}
\DoxyCodeLine{00076\ \ \ \ \ \ \ \ \ callback(result,\ reference);}
\DoxyCodeLine{00077\ \ \ \ \ \}}
\DoxyCodeLine{00078\ }
\DoxyCodeLine{00079\ \ \ \ \ \textcolor{keywordflow}{return}\ result;}
\DoxyCodeLine{00080\ \ \ \}}
\DoxyCodeLine{00081\ }
\DoxyCodeLine{00083\ \ \ \textcolor{keyword}{virtual}\ audio\_tools::Vector<const\ char*>\&\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_adfa5999c7e6b9adc5f51d8213614abc3}{allTexts}}()\ \{}
\DoxyCodeLine{00084\ \ \ \ \ result.clear();}
\DoxyCodeLine{00085\ }
\DoxyCodeLine{00086\ \ \ \ \ \textcolor{comment}{//\ add\ words\ from\ unit\_1}}
\DoxyCodeLine{00087\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ j\ =\ 0;\ j\ <\ max\_unit\_1;\ j++)\ \{}
\DoxyCodeLine{00088\ \ \ \ \ \ \ add(unit\_1[j][1]);}
\DoxyCodeLine{00089\ \ \ \ \ \ \ add(unit\_1[j][2]);}
\DoxyCodeLine{00090\ \ \ \ \ \}}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \ \ \ \ \textcolor{comment}{//\ add\ words\ form\ unit\_3}}
\DoxyCodeLine{00093\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ j\ =\ 0;\ j\ <\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_ac9a76bb190de0cd5ebb2fe80cd990945}{max\_unit\_2}};\ j++)\ \{}
\DoxyCodeLine{00094\ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 1;\ i\ <\ 4;\ i++)\ \{}
\DoxyCodeLine{00095\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ word\ =\ unit2[j][i];}
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (word\ !=\ \textcolor{keyword}{nullptr})\ \{}
\DoxyCodeLine{00097\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!isKey(word))\ \{}
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ \ \ \ \ add(word);}
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00100\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00101\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00102\ \ \ \ \ \}}
\DoxyCodeLine{00103\ }
\DoxyCodeLine{00104\ \ \ \ \ \textcolor{keywordflow}{return}\ result;}
\DoxyCodeLine{00105\ \ \ \}}
\DoxyCodeLine{00106\ }
\DoxyCodeLine{00107\ \ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00108\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ default\_unit\ =\ \textcolor{keyword}{nullptr};}
\DoxyCodeLine{00109\ \ \ audio\_tools::Vector<const\ char*>\ result;}
\DoxyCodeLine{00110\ \ \ \mbox{\hyperlink{classsimple__tts_1_1_number_to_text}{NumberToText}}\ ntt;}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \ \ \textcolor{comment}{//\ units\ which\ can\ have\ singurlar\ and\ plural}}
\DoxyCodeLine{00113\ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ max\_unit\_1\ =\ 6;}
\DoxyCodeLine{00114\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit\_1[max\_unit\_1][3]\ =\ \{}
\DoxyCodeLine{00115\ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}lb"{}},\ \textcolor{stringliteral}{"{}pound"{}},\ \textcolor{stringliteral}{"{}pounds"{}}\},\ \ \{\textcolor{stringliteral}{"{}ft"{}},\ \textcolor{stringliteral}{"{}foot"{}},\ \textcolor{stringliteral}{"{}feet"{}}\},}
\DoxyCodeLine{00116\ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}in"{}},\ \textcolor{stringliteral}{"{}inch"{}},\ \textcolor{stringliteral}{"{}inches"{}}\},\ \ \ \{\textcolor{stringliteral}{"{}mi"{}},\ \textcolor{stringliteral}{"{}mile"{}},\ \textcolor{stringliteral}{"{}miles"{}}\},}
\DoxyCodeLine{00117\ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}\$"{}},\ \textcolor{stringliteral}{"{}dollar"{}},\ \textcolor{stringliteral}{"{}dollars"{}}\},\ \{\textcolor{stringliteral}{"{}¢"{}},\ \textcolor{stringliteral}{"{}cent"{}},\ \textcolor{stringliteral}{"{}cents"{}}\}\};}
\DoxyCodeLine{00118\ }
\DoxyCodeLine{00120\ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_ac9a76bb190de0cd5ebb2fe80cd990945}{max\_unit\_2}}\ =\ 15;}
\DoxyCodeLine{00121\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit2[\mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_ac9a76bb190de0cd5ebb2fe80cd990945}{max\_unit\_2}}][4]\ =\ \{\{\textcolor{stringliteral}{"{}mph"{}},\ \textcolor{stringliteral}{"{}miles"{}},\ \textcolor{stringliteral}{"{}per"{}},\ \textcolor{stringliteral}{"{}hour"{}}\},}
\DoxyCodeLine{00122\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}C"{}},\ \textcolor{stringliteral}{"{}degrees"{}},\ \textcolor{stringliteral}{"{}celcius"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00123\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}F"{}},\ \textcolor{stringliteral}{"{}degrees"{}},\ \textcolor{stringliteral}{"{}fahrenheit"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}\%"{}},\ \textcolor{stringliteral}{"{}percent"{}},\ \textcolor{keyword}{nullptr},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00125\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}lt"{}},\ \textcolor{stringliteral}{"{}liter"{}},\ \textcolor{keyword}{nullptr},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00126\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}ml"{}},\ \textcolor{stringliteral}{"{}milli"{}},\ \textcolor{stringliteral}{"{}lt"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}gr"{}},\ \textcolor{stringliteral}{"{}gram"{}},\ \textcolor{keyword}{nullptr},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00128\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}kg"{}},\ \textcolor{stringliteral}{"{}kilo"{}},\ \textcolor{stringliteral}{"{}gr"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00129\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}mg"{}},\ \textcolor{stringliteral}{"{}milli"{}},\ \textcolor{stringliteral}{"{}gr"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00130\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}km"{}},\ \textcolor{stringliteral}{"{}kilo"{}},\ \textcolor{stringliteral}{"{}m"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00131\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}m"{}},\ \textcolor{stringliteral}{"{}meter"{}},\ \textcolor{keyword}{nullptr},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00132\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}cm"{}},\ \textcolor{stringliteral}{"{}centi"{}},\ \textcolor{stringliteral}{"{}m"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00133\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}mm"{}},\ \textcolor{stringliteral}{"{}milli"{}},\ \textcolor{stringliteral}{"{}m"{}},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00134\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}u.s."{}},\ \textcolor{stringliteral}{"{}us"{}},\ \textcolor{keyword}{nullptr},\ \textcolor{keyword}{nullptr}\},}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}usd"{}},\ \textcolor{stringliteral}{"{}u.s."{}},\ \textcolor{stringliteral}{"{}\$"{}},\ \textcolor{keyword}{nullptr}\}\};}
\DoxyCodeLine{00136\ }
\DoxyCodeLine{00137\ \ \ \textcolor{comment}{//\ split\ unit\ before\ and\ after\ the\ decimal\ point:\ 1.20\ USD\ is\ 1\ dollar\ and\ 20}}
\DoxyCodeLine{00138\ \ \ \textcolor{comment}{//\ cents}}
\DoxyCodeLine{00139\ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ max\_unit\_3\ =\ 6;}
\DoxyCodeLine{00140\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit3[max\_unit\_3][2]\ =\ \{\{\textcolor{stringliteral}{"{}usd"{}},\ \textcolor{stringliteral}{"{}¢"{}}\},\ \{\textcolor{stringliteral}{"{}gr"{}},\ \textcolor{stringliteral}{"{}mg"{}}\},\ \{\textcolor{stringliteral}{"{}kg"{}},\ \textcolor{stringliteral}{"{}gr"{}}\},}
\DoxyCodeLine{00141\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}m"{}},\ \textcolor{stringliteral}{"{}mm"{}}\},\ \ \{\textcolor{stringliteral}{"{}km"{}},\ \textcolor{stringliteral}{"{}m"{}}\},\ \ \{\textcolor{stringliteral}{"{}lt"{}},\ \textcolor{stringliteral}{"{}ml"{}}\}\};}
\DoxyCodeLine{00142\ \ \ }
\DoxyCodeLine{00144\ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{structsimple__tts_1_1_number_unit_to_text_1_1_decimal_info}{DecimalInfo}}\ \{}
\DoxyCodeLine{00145\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ id;}
\DoxyCodeLine{00146\ \ \ \ \ \textcolor{keywordtype}{int}\ dec;}
\DoxyCodeLine{00147\ \ \ \};}
\DoxyCodeLine{00148\ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ decimal\_info\_len\ =\ 1;}
\DoxyCodeLine{00149\ \ \ \textcolor{keyword}{const}\ \mbox{\hyperlink{structsimple__tts_1_1_number_unit_to_text_1_1_decimal_info}{DecimalInfo}}\ decimal\_info[decimal\_info\_len]\ =\ \{\{\textcolor{stringliteral}{"{}usd"{}},\ 2\}\};}
\DoxyCodeLine{00150\ }
\DoxyCodeLine{00151\ \ \ \textcolor{comment}{//\ add\ a\ single\ word\ to\ the\ result}}
\DoxyCodeLine{00152\ \ \ \textcolor{keywordtype}{void}\ add(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ str)\ \{\ result.push\_back(str);\ \}}
\DoxyCodeLine{00153\ }
\DoxyCodeLine{00154\ \ \ \textcolor{comment}{//\ add\ a\ list\ to\ the\ result}}
\DoxyCodeLine{00155\ \ \ \textcolor{keywordtype}{void}\ addAll(audio\_tools::Vector<const\ char*>\&\ words)\ \{}
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ word\ :\ words)\ \{}
\DoxyCodeLine{00157\ \ \ \ \ \ \ add(word);}
\DoxyCodeLine{00158\ \ \ \ \ \}}
\DoxyCodeLine{00159\ \ \ \}}
\DoxyCodeLine{00160\ }
\DoxyCodeLine{00162\ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aa2ef301472f16644e12ca377537188a0}{process}}(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit,\ \textcolor{keywordtype}{bool}\ isOne)\ \{}
\DoxyCodeLine{00163\ \ \ \ \ \textcolor{keywordflow}{if}\ (!isKey(unit))\ \{}
\DoxyCodeLine{00164\ \ \ \ \ \ \ add(unit);}
\DoxyCodeLine{00165\ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00166\ \ \ \ \ \}}
\DoxyCodeLine{00167\ \ \ \ \ \textcolor{comment}{//\ check\ in\ table1\ first}}
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{keywordflow}{if}\ (process1(unit,\ isOne))\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00169\ \ \ \ \ \textcolor{comment}{//\ process\ table\ 2}}
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{keywordflow}{if}\ (process2(unit,\ isOne))\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{comment}{//\ last\ resort\ use\ the\ unit\ directly}}
\DoxyCodeLine{00172\ \ \ \ \ \textcolor{keywordflow}{if}\ (!isKey(unit))\ \{}
\DoxyCodeLine{00173\ \ \ \ \ \ \ LOGE(\textcolor{stringliteral}{"{}Error\ \%s"{}},\ unit);}
\DoxyCodeLine{00174\ \ \ \ \ \}}
\DoxyCodeLine{00175\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00176\ \ \ \}}
\DoxyCodeLine{00177\ }
\DoxyCodeLine{00178\ \ \ \textcolor{keywordtype}{bool}\ process2(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit,\ \textcolor{keywordtype}{bool}\ isOne)\ \{}
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{comment}{//\ process\ table\ 2}}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keywordtype}{bool}\ result\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00181\ \ \ \ \ Str\ u(unit);}
\DoxyCodeLine{00182\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ j\ =\ 0;\ j\ <\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_ac9a76bb190de0cd5ebb2fe80cd990945}{max\_unit\_2}};\ j++)\ \{}
\DoxyCodeLine{00183\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (u.equalsIgnoreCase(unit2[j][0]))\ \{}
\DoxyCodeLine{00184\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 1;\ i\ <\ 4;\ i++)\ \{}
\DoxyCodeLine{00185\ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ word\ =\ unit2[j][i];}
\DoxyCodeLine{00186\ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (word\ !=\ \textcolor{keyword}{nullptr})\ \{}
\DoxyCodeLine{00187\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!isKey(word))\ \{}
\DoxyCodeLine{00188\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ add(word);}
\DoxyCodeLine{00189\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ result\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00190\ \ \ \ \ \ \ \ \ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00191\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aa2ef301472f16644e12ca377537188a0}{process}}(word,\ isOne))\ \{}
\DoxyCodeLine{00192\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ result\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00193\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00194\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00195\ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00196\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00197\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00198\ \ \ \ \ \}}
\DoxyCodeLine{00199\ \ \ \ \ \textcolor{keywordflow}{return}\ result;}
\DoxyCodeLine{00200\ \ \ \}}
\DoxyCodeLine{00201\ }
\DoxyCodeLine{00202\ \ \ \textcolor{keywordtype}{bool}\ process1(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit,\ \textcolor{keywordtype}{bool}\ isOne)\ \{}
\DoxyCodeLine{00203\ \ \ \ \ Str\ u(unit);}
\DoxyCodeLine{00204\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ j\ =\ 0;\ j\ <\ max\_unit\_1;\ j++)\ \{}
\DoxyCodeLine{00205\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (u.equalsIgnoreCase(unit\_1[j][0]))\ \{}
\DoxyCodeLine{00206\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ determine\ singular\ or\ plural}}
\DoxyCodeLine{00207\ \ \ \ \ \ \ \ \ add(isOne\ ?\ unit\_1[j][1]\ :\ unit\_1[j][2]);}
\DoxyCodeLine{00208\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00209\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00210\ \ \ \ \ \}}
\DoxyCodeLine{00211\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00212\ \ \ \}}
\DoxyCodeLine{00213\ }
\DoxyCodeLine{00214\ \ \ \textcolor{keywordtype}{bool}\ isKey(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit)\ \{}
\DoxyCodeLine{00215\ \ \ \ \ Str\ u(unit);}
\DoxyCodeLine{00216\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ j\ =\ 0;\ j\ <\ max\_unit\_1;\ j++)\ \{}
\DoxyCodeLine{00217\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (u.equalsIgnoreCase(unit\_1[j][0]))\ \{}
\DoxyCodeLine{00218\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00219\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00220\ \ \ \ \ \}}
\DoxyCodeLine{00221\ }
\DoxyCodeLine{00222\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ j\ =\ 0;\ j\ <\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_ac9a76bb190de0cd5ebb2fe80cd990945}{max\_unit\_2}};\ j++)\ \{}
\DoxyCodeLine{00223\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (u.equalsIgnoreCase(unit2[j][0]))\ \{}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00225\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00226\ \ \ \ \ \}}
\DoxyCodeLine{00227\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00228\ \ \ \}}
\DoxyCodeLine{00229\ }
\DoxyCodeLine{00230\ \ \ \textcolor{comment}{//\ checks\ if\ this\ is\ a\ combined\ unit\ (part\ of\ unit3)\ where\ we\ need\ to}}
\DoxyCodeLine{00231\ \ \ \textcolor{comment}{//\ separate\ the\ integers\ from\ the\ decimals\ with\ a\ different\ unit}}
\DoxyCodeLine{00232\ \ \ \textcolor{keywordtype}{int}\ idxCombinedUnit(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit)\ \{}
\DoxyCodeLine{00233\ \ \ \ \ Str\ u(unit);}
\DoxyCodeLine{00234\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ max\_unit\_3;\ i++)\ \{}
\DoxyCodeLine{00235\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (u.equalsIgnoreCase(unit3[i][0]))\ \{}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ i;}
\DoxyCodeLine{00237\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00238\ \ \ \ \ \}}
\DoxyCodeLine{00239\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{00240\ \ \ \}}
\DoxyCodeLine{00241\ }
\DoxyCodeLine{00242\ \ \ \textcolor{keywordtype}{bool}\ processCombinedUnit(\textcolor{keywordtype}{int}\ idx,\ \textcolor{keywordtype}{bool}\ isOne)\ \{}
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aa2ef301472f16644e12ca377537188a0}{process}}(unit3[idx][0],\ isOne);}
\DoxyCodeLine{00244\ \ \ \}}
\DoxyCodeLine{00245\ }
\DoxyCodeLine{00246\ \ \ \textcolor{keywordtype}{bool}\ processDecimalUnit(\textcolor{keywordtype}{int}\ idx,\ \textcolor{keywordtype}{bool}\ isOne)\ \{}
\DoxyCodeLine{00247\ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classsimple__tts_1_1_number_unit_to_text_aa2ef301472f16644e12ca377537188a0}{process}}(unit3[idx][1],\ isOne);}
\DoxyCodeLine{00248\ \ \ \}}
\DoxyCodeLine{00249\ }
\DoxyCodeLine{00250\ \ \ \textcolor{keywordtype}{int}\ decimalInfo(\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}*\ unit)\ \{}
\DoxyCodeLine{00251\ \ \ \ \ Str\ u(unit);}
\DoxyCodeLine{00252\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ decimal\_info\_len;\ i++)\ \{}
\DoxyCodeLine{00253\ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (u.equalsIgnoreCase(decimal\_info[i].id))\ \{}
\DoxyCodeLine{00254\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ decimal\_info[i].dec;}
\DoxyCodeLine{00255\ \ \ \ \ \ \ \}}
\DoxyCodeLine{00256\ \ \ \ \ \}}
\DoxyCodeLine{00257\ \ \ \ \ \textcolor{comment}{//\ all\ metric\ units\ are\ based\ on\ 1000}}
\DoxyCodeLine{00258\ \ \ \ \ \textcolor{keywordflow}{return}\ 3;}
\DoxyCodeLine{00259\ \ \ \}}
\DoxyCodeLine{00260\ \};}
\DoxyCodeLine{00261\ }
\DoxyCodeLine{00262\ \}\ \ \textcolor{comment}{//\ namespace\ simple\_tts}}

\end{DoxyCode}
