diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/a03729.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a03729.html | 569 |
1 files changed, 569 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a03729.html b/docs/doxygen/nel/a03729.html new file mode 100644 index 00000000..c28e6f28 --- /dev/null +++ b/docs/doxygen/nel/a03729.html @@ -0,0 +1,569 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLMISC::CWordsDictionary class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLMISC::CWordsDictionary Class Reference</h1><code>#include <<a class="el" href="a06754.html">words_dictionary.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +Words dictionary: allows to search for keys and words in _words_<language>.txt Unicode files. All searches are case not-sensitive.<p> +<dl compact><dt><b>Author:</b></dt><dd>Olivier Cado <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>2003 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a06754.html#l00044">44</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya0">CWordsDictionary</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#NLMISC_1_1CWordsDictionarya0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya1">exactLookupByKey</a> (const <a class="el" href="a03435.html">CSString</a> &key, <a class="el" href="a03670.html">CVectorSString</a> &resultVec)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the result vector with the word(s) corresponding to the key. <a href="#NLMISC_1_1CWordsDictionarya1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03670.html">CVectorSString</a> & </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya2">getKeys</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03670.html">CVectorSString</a> & </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya3">getWords</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03435.html">CSString</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya4">getWordsKey</a> (const <a class="el" href="a03435.html">CSString</a> &resultStr)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the key contained in the provided string returned by <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya6">lookup()</a> (without extension). <a href="#NLMISC_1_1CWordsDictionarya4"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya5">init</a> (const std::string &configFileName="words_dic.cfg")</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya6">lookup</a> (const <a class="el" href="a03435.html">CSString</a> &inputStr, <a class="el" href="a03670.html">CVectorSString</a> &resultVec)</td></tr> + +<tr><td colspan=2><br><h2>Protected Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03435.html">CSString</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryb0">makeResult</a> (const <a class="el" href="a03435.html">CSString</a> key, const <a class="el" href="a03435.html">CSString</a> word)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Make a result string. <a href="#NLMISC_1_1CWordsDictionaryb0"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03670.html">CVectorSString</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a></td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Keys (same indices as in _Words). <a href="#NLMISC_1_1CWordsDictionaryr0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03670.html">CVectorSString</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a></td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Words (same indices as in _Keys). <a href="#NLMISC_1_1CWordsDictionaryr1"></a><br><br></td></tr> +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya0" doxytag="NLMISC::CWordsDictionary::CWordsDictionary" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CWordsDictionary::CWordsDictionary </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Constructor. +<p> + +<p> +Definition at line <a class="el" href="a06753.html#l00041">41</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>. +<p> +<div class="fragment"><pre>00042 { +00043 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya1" doxytag="NLMISC::CWordsDictionary::exactLookupByKey" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CWordsDictionary::exactLookupByKey </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> & </td> + <td class="mdname" nowrap> <em>key</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03670.html">CVectorSString</a> & </td> + <td class="mdname" nowrap> <em>resultVec</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Set the result vector with the word(s) corresponding to the key. +<p> + +<p> +Definition at line <a class="el" href="a06753.html#l00190">190</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>. +<p> +References <a class="el" href="a06754.html#l00091">_Words</a>. +<p> +<div class="fragment"><pre>00191 { +00192 <span class="comment">// Search</span> +00193 <span class="keywordflow">for</span> ( CVectorSString::const_iterator ivs=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin(); ivs!=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.end(); ++ivs ) +00194 { +00195 <span class="keywordflow">if</span> ( key == *ivs ) +00196 resultVec.push_back( _Words[ivs-<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin()] ); +00197 } +00198 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya2" doxytag="NLMISC::CWordsDictionary::getKeys" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> const <a class="el" href="a03670.html">CVectorSString</a>& NLMISC::CWordsDictionary::getKeys </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06754.html#l00077">77</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>. +<p> +<div class="fragment"><pre>00077 { <span class="keywordflow">return</span> <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya3" doxytag="NLMISC::CWordsDictionary::getWords" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> const <a class="el" href="a03670.html">CVectorSString</a>& NLMISC::CWordsDictionary::getWords </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06754.html#l00078">78</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>. +<p> +References <a class="el" href="a06754.html#l00091">_Words</a>. +<p> +<div class="fragment"><pre>00078 { <span class="keywordflow">return</span> <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya4" doxytag="NLMISC::CWordsDictionary::getWordsKey" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03435.html">CSString</a> NLMISC::CWordsDictionary::getWordsKey </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>resultStr</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return the key contained in the provided string returned by <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya6">lookup()</a> (without extension). +<p> + +<p> +Definition at line <a class="el" href="a06753.html#l00214">214</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>. +<p> +References <a class="el" href="a06431.html#l00133">NLMISC::CSString::splitTo()</a>. +<p> +<div class="fragment"><pre>00215 { +00216 <span class="keywordflow">return</span> resultStr.splitTo( <span class="charliteral">':'</span> ); +00217 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya5" doxytag="NLMISC::CWordsDictionary::init" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CWordsDictionary::init </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>configFileName</em> = "words_dic.cfg" </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Load the config file and the related words files. Return false in case of failure. Config file variables:<ul> +<li>WordsPath: where to find *_words_.txt</li><li>LanguageCode: language code (ex: en for English)</li><li>Utf8: results are in UTF8, otherwise in ANSI string</li></ul> + +<p> +Definition at line <a class="el" href="a06753.html#l00052">52</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>. +<p> +References <a class="el" href="a06754.html#l00091">_Words</a>, <a class="el" href="a05635.html#l00104">STRING_MANAGER::TWorksheet::begin()</a>, <a class="el" href="a05635.html#l00109">STRING_MANAGER::TWorksheet::end()</a>, <a class="el" href="a05635.html#l00209">STRING_MANAGER::TWorksheet::findCol()</a>, <a class="el" href="a05635.html#l00193">STRING_MANAGER::TWorksheet::findId()</a>, <a class="el" href="a05597.html#l00441">NLMISC::CConfigFile::getVarPtr()</a>, <a class="el" href="a05597.html#l00244">NLMISC::CConfigFile::load()</a>, <a class="el" href="a05634.html#l00558">STRING_MANAGER::loadExcelSheet()</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a06229.html#l02652">NLMISC::toString()</a>, <a class="el" href="a05635.html#l00094">STRING_MANAGER::TWorksheet::TRow</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05646.html#l00237">v</a>. +<p> +<div class="fragment"><pre>00053 { +00054 <span class="comment">// Read config file</span> +00055 <span class="keywordtype">bool</span> cfFound = <span class="keyword">false</span>; +00056 CConfigFile cf; +00057 <span class="keywordflow">try</span> +00058 { +00059 cf.load( configFileName ); +00060 cfFound = <span class="keyword">true</span>; +00061 } +00062 <span class="keywordflow">catch</span> ( EConfigFile& e ) +00063 { +00064 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: %s"</span>, e.what() ); +00065 } +00066 string wordsPath, languageCode; +00067 <span class="keywordtype">bool</span> utf8 = <span class="keyword">false</span>; +00068 <span class="keywordflow">if</span> ( cfFound ) +00069 { +00070 <a class="code" href="a02402.html">CConfigFile::CVar</a> *<a class="code" href="a04223.html#a576">v</a> = cf.getVarPtr( <span class="stringliteral">"WordsPath"</span> ); +00071 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a576">v</a> ) +00072 { +00073 wordsPath = <a class="code" href="a04223.html#a576">v</a>->asString(); +00074 <span class="comment">/*if ( (!wordsPath.empty()) && (wordsPath[wordsPath.size()-1]!='/') )</span> +00075 <span class="comment"> wordsPath += '/';*/</span> +00076 } +00077 <a class="code" href="a04223.html#a576">v</a> = cf.getVarPtr( <span class="stringliteral">"LanguageCode"</span> ); +00078 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a576">v</a> ) +00079 languageCode = <a class="code" href="a04223.html#a576">v</a>->asString(); +00080 <a class="code" href="a04223.html#a576">v</a> = cf.getVarPtr( <span class="stringliteral">"Utf8"</span> ); +00081 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a576">v</a> ) +00082 utf8 = (<a class="code" href="a04223.html#a576">v</a>->asInt() == 1); +00083 } +00084 <span class="keywordflow">if</span> ( languageCode.empty() ) +00085 languageCode = <span class="stringliteral">"en"</span>; +00086 +00087 <span class="comment">// Load all found words files</span> +00088 <span class="keyword">const</span> string ext = <span class="stringliteral">".txt"</span>; +00089 vector<string> fileList; +00090 CPath::getPathContent( wordsPath, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">true</span>, fileList ); +00091 <span class="keywordflow">for</span> ( vector<string>::const_iterator ifl=fileList.begin(); ifl!=fileList.end(); ++ifl ) +00092 { +00093 <span class="keyword">const</span> string& <a class="code" href="a05377.html#a2">filename</a> = (*ifl); +00094 string::size_type p; +00095 <span class="keywordflow">if</span> ( (p = <a class="code" href="a05377.html#a2">filename</a>.find( string(<span class="stringliteral">"_words_"</span>) + languageCode + ext )) != string::npos ) +00096 { +00097 <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"WD: Loading %s"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str() ); +00098 string::size_type origSize = <a class="code" href="a05377.html#a2">filename</a>.size() - ext.size(); +00099 <span class="keyword">const</span> string truncFilename = CFile::getFilenameWithoutExtension( filename ); +00100 <span class="keyword">const</span> string wordType = truncFilename.substr( 0, p - (origSize - truncFilename.size()) ); +00101 +00102 <span class="comment">// Load Unicode Excel words file</span> +00103 <a class="code" href="a03919.html">STRING_MANAGER::TWorksheet</a> worksheet; +00104 <a class="code" href="a05383.html#a11">STRING_MANAGER::loadExcelSheet</a>( filename, worksheet ); +00105 <a class="code" href="a04558.html#a15">uint</a> ck, cw; +00106 <span class="keywordflow">if</span> ( worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta8">findId</a>( ck ) && worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta7">findCol</a>( <a class="code" href="a03924.html">ucstring</a>(<span class="stringliteral">"name"</span>), cw ) ) <span class="comment">// => </span> +00107 { +00108 <span class="keywordflow">for</span> ( std::vector<STRING_MANAGER::TWorksheet::TRow>::iterator ip = worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta2">begin</a>(); ip!=worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta4">end</a>(); ++ip ) +00109 { +00110 <span class="keywordflow">if</span> ( ip == worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta2">begin</a>() ) <span class="comment">// skip first row</span> +00111 <span class="keywordflow">continue</span>; +00112 <a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheetw1">STRING_MANAGER::TWorksheet::TRow</a>& row = *ip; +00113 <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.push_back( row[ck].<a class="code" href="a05378.html#a244">toString</a>() ); +00114 string word = utf8 ? row[cw].toUtf8() : row[cw].<a class="code" href="a05378.html#a244">toString</a>(); +00115 <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.push_back( word ); +00116 } +00117 } +00118 <span class="keywordflow">else</span> +00119 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: %s ID or name not found in %s"</span>, wordType.c_str(), <a class="code" href="a05377.html#a2">filename</a>.c_str() ); +00120 } +00121 } +00122 +00123 <span class="keywordflow">if</span> ( <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.empty() ) +00124 { +00125 <span class="keywordflow">if</span> ( wordsPath.empty() ) +00126 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: WordsPath missing in config file %s"</span>, configFileName.c_str() ); +00127 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: *_words_%s.txt not found"</span>, languageCode.c_str() ); +00128 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00129 } +00130 <span class="keywordflow">else</span> +00131 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00132 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionarya6" doxytag="NLMISC::CWordsDictionary::lookup" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CWordsDictionary::lookup </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> & </td> + <td class="mdname" nowrap> <em>inputStr</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03670.html">CVectorSString</a> & </td> + <td class="mdname" nowrap> <em>resultVec</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Set the result vector with strings corresponding to the input string:<ul> +<li>If inputStr is partially or completely found in the keys, all the matching <key,words> are returned;</li><li>If inputStr is partially or completely in the words, all the matching <key, words> are returned. The following tags can modify the behaviour of the search algorithm:</li><li>^mystring returns mystring only if it is at the beginning of a key or word</li><li>mystring$ returns mystring only if it is at the end of a key or word All returned words are in UTF8 string or ANSI string, depending of the config file.</li></ul> + +<p> +Definition at line <a class="el" href="a06753.html#l00144">144</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>. +<p> +References <a class="el" href="a06754.html#l00091">_Words</a>, <a class="el" href="a06431.html#l00506">NLMISC::CSString::find()</a>, <a class="el" href="a06753.html#l00204">makeResult()</a>, and <a class="el" href="a06431.html#l00111">NLMISC::CSString::rightCrop()</a>. +<p> +<div class="fragment"><pre>00145 { +00146 <span class="comment">// Prepare search string</span> +00147 <span class="keywordflow">if</span> ( inputStr.empty() ) +00148 <span class="keywordflow">return</span>; +00149 +00150 CSString searchStr = inputStr; +00151 <span class="keywordtype">bool</span> findAtBeginning = <span class="keyword">false</span>, findAtEnd = <span class="keyword">false</span>; +00152 <span class="keywordflow">if</span> ( searchStr[0] == <span class="charliteral">'^'</span> ) +00153 { +00154 searchStr = searchStr.substr( 1 ); +00155 findAtBeginning = <span class="keyword">true</span>; +00156 } +00157 <span class="keywordflow">if</span> ( searchStr[searchStr.size()-1] == <span class="charliteral">'$'</span> ) +00158 { +00159 searchStr = searchStr.rightCrop( 1 ); +00160 findAtEnd = <span class="keyword">true</span>; +00161 } +00162 +00163 <span class="comment">// Search</span> +00164 <span class="keywordflow">for</span> ( CVectorSString::const_iterator ivs=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin(); ivs!=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.end(); ++ivs ) +00165 { +00166 <span class="keyword">const</span> CSString& key = *ivs; +00167 string::size_type p; +00168 <span class="keywordflow">if</span> ( (p = key.find( searchStr.c_str() )) != string::npos ) +00169 { +00170 <span class="keywordflow">if</span> ( ((!findAtBeginning) || (p==0)) && ((!findAtEnd) || (p==key.size()-searchStr.size())) ) +00171 resultVec.push_back( <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryb0">makeResult</a>( key, _Words[ivs-<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin()] ) ); +00172 } +00173 } +00174 <span class="keywordflow">for</span> ( CVectorSString::const_iterator ivs=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.begin(); ivs!=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.end(); ++ivs ) +00175 { +00176 <span class="keyword">const</span> CSString& word = *ivs; +00177 string::size_type p; +00178 <span class="keywordflow">if</span> ( (p = word.find( searchStr.c_str() )) != string::npos ) +00179 { +00180 <span class="keywordflow">if</span> ( ((!findAtBeginning) || (p==0)) && ((!findAtEnd) || (p==word.size()-searchStr.size())) ) +00181 resultVec.push_back( <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryb0">makeResult</a>( _Keys[ivs-<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.begin()], word ) ); +00182 } +00183 } +00184 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionaryb0" doxytag="NLMISC::CWordsDictionary::makeResult" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03435.html">CSString</a> NLMISC::CWordsDictionary::makeResult </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> </td> + <td class="mdname" nowrap> <em>key</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03435.html">CSString</a> </td> + <td class="mdname" nowrap> <em>word</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [inline, protected]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Make a result string. +<p> + +<p> +Definition at line <a class="el" href="a06753.html#l00204">204</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>. +<p> +References <a class="el" href="a05646.html#l01119">res</a>. +<p> +Referenced by <a class="el" href="a06753.html#l00144">lookup()</a>. +<p> +<div class="fragment"><pre>00205 { +00206 CSString <a class="code" href="a04223.html#a643">res</a> = key + CSString(<span class="stringliteral">": "</span>) + word; +00207 <span class="keywordflow">return</span> <a class="code" href="a04223.html#a643">res</a>; +00208 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLMISC_1_1CWordsDictionaryr0" doxytag="NLMISC::CWordsDictionary::_Keys" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03670.html">CVectorSString</a> <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">NLMISC::CWordsDictionary::_Keys</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Keys (same indices as in _Words). +<p> + +<p> +Definition at line <a class="el" href="a06754.html#l00088">88</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CWordsDictionaryr1" doxytag="NLMISC::CWordsDictionary::_Words" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03670.html">CVectorSString</a> <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">NLMISC::CWordsDictionary::_Words</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Words (same indices as in _Keys). +<p> + +<p> +Definition at line <a class="el" href="a06754.html#l00091">91</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>. +<p> +Referenced by <a class="el" href="a06753.html#l00190">exactLookupByKey()</a>, <a class="el" href="a06754.html#l00078">getWords()</a>, <a class="el" href="a06753.html#l00052">init()</a>, and <a class="el" href="a06753.html#l00144">lookup()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a06754.html">words_dictionary.h</a><li><a class="el" href="a06753.html">words_dictionary.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:43:30 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |