diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:29:28 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:29:28 +0200 |
commit | 75c07011b7c4d06acd7b45dabdcd60ab9d80f385 (patch) | |
tree | 8853c3978dd152ef377e652239448b1352320206 /zenxml/doc/bind_8h_source.html | |
parent | 5.22 (diff) | |
download | FreeFileSync-75c07011b7c4d06acd7b45dabdcd60ab9d80f385.tar.gz FreeFileSync-75c07011b7c4d06acd7b45dabdcd60ab9d80f385.tar.bz2 FreeFileSync-75c07011b7c4d06acd7b45dabdcd60ab9d80f385.zip |
5.23
Diffstat (limited to 'zenxml/doc/bind_8h_source.html')
-rw-r--r-- | zenxml/doc/bind_8h_source.html | 319 |
1 files changed, 319 insertions, 0 deletions
diff --git a/zenxml/doc/bind_8h_source.html b/zenxml/doc/bind_8h_source.html new file mode 100644 index 00000000..300a10aa --- /dev/null +++ b/zenxml/doc/bind_8h_source.html @@ -0,0 +1,319 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> +<meta http-equiv="X-UA-Compatible" content="IE=9"/> +<title>zen::Xml: bind.h Source File</title> + +<link href="tabs.css" rel="stylesheet" type="text/css"/> +<link href="doxygen.css" rel="stylesheet" type="text/css" /> + +<link href="search/search.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="jquery.js"></script> +<script type="text/javascript" src="search/search.js"></script> +<script type="text/javascript"> + $(document).ready(function() { searchBox.OnSelectItem(0); }); +</script> + +</head> +<body> +<div id="top"><!-- do not remove this div! --> + + +<div id="titlearea"> +<table cellspacing="0" cellpadding="0"> + <tbody> + <tr style="height: 56px;"> + + <td id="projectlogo"><img alt="Logo" src="zenXml.png"/></td> + + + <td style="padding-left: 0.5em;"> + <div id="projectname">zen::Xml + + </div> + <div id="projectbrief">Simple C++ XML Processing</div> + </td> + + + + </tr> + </tbody> +</table> +</div> + +<!-- Generated by Doxygen 1.8.0 --> +<script type="text/javascript"> +var searchBox = new SearchBox("searchBox", "search",false,'Search'); +</script> + <div id="navrow1" class="tabs"> + <ul class="tablist"> + <li><a href="index.html"><span>Main Page</span></a></li> + <li><a href="namespaces.html"><span>Namespaces</span></a></li> + <li><a href="annotated.html"><span>Classes</span></a></li> + <li class="current"><a href="files.html"><span>Files</span></a></li> + <li> + <div id="MSearchBox" class="MSearchBoxInactive"> + <span class="left"> + <img id="MSearchSelect" src="search/mag_sel.png" + onmouseover="return searchBox.OnSearchSelectShow()" + onmouseout="return searchBox.OnSearchSelectHide()" + alt=""/> + <input type="text" id="MSearchField" value="Search" accesskey="S" + onfocus="searchBox.OnSearchFieldFocus(true)" + onblur="searchBox.OnSearchFieldFocus(false)" + onkeyup="searchBox.OnSearchFieldChange(event)"/> + </span><span class="right"> + <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> + </span> + </div> + </li> + </ul> + </div> + <div id="navrow2" class="tabs2"> + <ul class="tablist"> + <li><a href="files.html"><span>File List</span></a></li> + </ul> + </div> +</div> +<!-- window showing the filter options --> +<div id="MSearchSelectWindow" + onmouseover="return searchBox.OnSearchSelectShow()" + onmouseout="return searchBox.OnSearchSelectHide()" + onkeydown="return searchBox.OnSearchSelectKey(event)"> +<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a></div> + +<!-- iframe showing the search results (closed by default) --> +<div id="MSearchResultsWindow"> +<iframe src="javascript:void(0)" frameborder="0" + name="MSearchResults" id="MSearchResults"> +</iframe> +</div> + +<div class="header"> + <div class="headertitle"> +<div class="title">bind.h</div> </div> +</div><!--header--> +<div class="contents"> +<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// **************************************************************************</span> +<a name="l00002"></a>00002 <span class="comment">// * This file is part of the zen::Xml project. It is distributed under the *</span> +<a name="l00003"></a>00003 <span class="comment">// * Boost Software License: http://www.boost.org/LICENSE_1_0.txt *</span> +<a name="l00004"></a>00004 <span class="comment">// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *</span> +<a name="l00005"></a>00005 <span class="comment">// **************************************************************************</span> +<a name="l00006"></a>00006 +<a name="l00007"></a>00007 <span class="preprocessor">#ifndef ZEN_XML_BIND_HEADER_9081740816593478258435</span> +<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#define ZEN_XML_BIND_HEADER_9081740816593478258435</span> +<a name="l00009"></a>00009 <span class="preprocessor"></span> +<a name="l00010"></a>00010 <span class="preprocessor">#include <set></span> +<a name="l00011"></a>00011 <span class="preprocessor">#include "cvrt_struc.h"</span> +<a name="l00012"></a>00012 <span class="preprocessor">#include "parser.h"</span> +<a name="l00013"></a>00013 <span class="preprocessor">#include "io.h"</span> +<a name="l00014"></a>00014 +<a name="l00015"></a><a class="code" href="namespacezen.html">00015</a> <span class="keyword">namespace </span>zen +<a name="l00016"></a>00016 { +<a name="l00022"></a>00022 +<a name="l00023"></a>00023 +<a name="l00032"></a>00032 <span class="keyword">template</span> <<span class="keyword">class</span> String> <span class="keyword">inline</span> +<a name="l00033"></a><a class="code" href="namespacezen.html#a900c1fb290f0eedc24354c487145dbee">00033</a> <span class="keywordtype">void</span> <a class="code" href="namespacezen.html#a900c1fb290f0eedc24354c487145dbee" title="Load XML document from a file.">load</a>(<span class="keyword">const</span> String& filename, <a class="code" href="classzen_1_1_xml_doc.html" title="The complete XML document.">XmlDoc</a>& doc) <span class="comment">//throw XmlFileError, XmlParsingError</span> +<a name="l00034"></a>00034 { +<a name="l00035"></a>00035 std::string stream = <a class="code" href="namespacezen.html#a04fe23c3bd9b7d03309620b5ea763607" title="Load byte stream from a file.">loadStream</a>(filename); <span class="comment">//throw XmlFileError</span> +<a name="l00036"></a>00036 <a class="code" href="namespacezen.html#a6cf1ec0b57fc1ae9aa95761800e67ec7" title="Load XML document from a byte stream.">parse</a>(stream, doc); <span class="comment">//throw XmlParsingError</span> +<a name="l00037"></a>00037 } +<a name="l00038"></a>00038 +<a name="l00039"></a>00039 +<a name="l00041"></a>00041 +<a name="l00051"></a>00051 <span class="keyword">template</span> <<span class="keyword">class</span> String> <span class="keyword">inline</span> +<a name="l00052"></a><a class="code" href="namespacezen.html#adeeb6b2318097382ae47aa939fc15d4d">00052</a> <span class="keywordtype">void</span> <a class="code" href="namespacezen.html#adeeb6b2318097382ae47aa939fc15d4d" title="Save XML document to a file.">save</a>(<span class="keyword">const</span> <a class="code" href="classzen_1_1_xml_doc.html" title="The complete XML document.">XmlDoc</a>& doc, +<a name="l00053"></a>00053 <span class="keyword">const</span> String& filename, +<a name="l00054"></a>00054 <span class="keyword">const</span> std::string& lineBreak = <span class="stringliteral">"\r\n"</span>, +<a name="l00055"></a>00055 <span class="keyword">const</span> std::string& indent = <span class="stringliteral">" "</span>) <span class="comment">//throw XmlFileError</span> +<a name="l00056"></a>00056 { +<a name="l00057"></a>00057 std::string stream = <a class="code" href="namespacezen.html#afaa4920e275078e6c8009fbdf58b57ee" title="Save XML document as a byte stream.">serialize</a>(doc, lineBreak, indent); <span class="comment">//throw ()</span> +<a name="l00058"></a>00058 <a class="code" href="namespacezen.html#a4ba7bbaa14a787b07fc13da9145aabe2" title="Save byte stream to a file.">saveStream</a>(stream, filename); <span class="comment">//throw XmlFileError</span> +<a name="l00059"></a>00059 } +<a name="l00060"></a>00060 +<a name="l00061"></a>00061 +<a name="l00063"></a><a class="code" href="classzen_1_1_xml_out.html">00063</a> <span class="keyword">class </span><a class="code" href="classzen_1_1_xml_out.html" title="Proxy class to conveniently convert user data into XML structure.">XmlOut</a> +<a name="l00064"></a>00064 { +<a name="l00065"></a>00065 <span class="keyword">public</span>: +<a name="l00067"></a>00067 +<a name="l00088"></a><a class="code" href="classzen_1_1_xml_out.html#ad8b1ccb8f3d4e7b0ab2598597ea50bcc">00088</a> <a class="code" href="classzen_1_1_xml_out.html#ad8b1ccb8f3d4e7b0ab2598597ea50bcc" title="Construct an output proxy for an XML document.">XmlOut</a>(<a class="code" href="classzen_1_1_xml_doc.html" title="The complete XML document.">XmlDoc</a>& doc) : ref_(&doc.root()) {} +<a name="l00090"></a>00090 +<a name="l00093"></a><a class="code" href="classzen_1_1_xml_out.html#aa80be3a56f70a58d2730a763166088c0">00093</a> <a class="code" href="classzen_1_1_xml_out.html#aa80be3a56f70a58d2730a763166088c0" title="Construct an output proxy for a single XML element.">XmlOut</a>(<a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>& element) : ref_(&element) {} +<a name="l00094"></a>00094 +<a name="l00096"></a>00096 +<a name="l00101"></a>00101 <span class="keyword">template</span> <<span class="keyword">class</span> String> +<a name="l00102"></a><a class="code" href="classzen_1_1_xml_out.html#a00f883d3f9d60535b06b5ae609dc8831">00102</a> <a class="code" href="classzen_1_1_xml_out.html" title="Proxy class to conveniently convert user data into XML structure.">XmlOut</a> <a class="code" href="classzen_1_1_xml_out.html#a00f883d3f9d60535b06b5ae609dc8831" title="Retrieve a handle to an XML child element for writing.">operator[]</a>(<span class="keyword">const</span> String& name)<span class="keyword"> const</span> +<a name="l00103"></a>00103 <span class="keyword"> </span>{ +<a name="l00104"></a>00104 <span class="keyword">const</span> std::string utf8name = utfCvrtTo<std::string>(name); +<a name="l00105"></a>00105 <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>* child = ref_-><a class="code" href="classzen_1_1_xml_element.html#a3ab82b1720460487f4afabcd115d0c7e" title="Retrieve a child element with the given name.">getChild</a>(utf8name); +<a name="l00106"></a>00106 <span class="keywordflow">return</span> child ? *child : ref_-><a class="code" href="classzen_1_1_xml_element.html#a653caffa6fad89db7d14f67f987ad0f9" title="Create a new child element and return a reference to it.">addChild</a>(utf8name); +<a name="l00107"></a>00107 } +<a name="l00108"></a>00108 +<a name="l00110"></a>00110 +<a name="l00114"></a>00114 <span class="keyword">template</span> <<span class="keyword">class</span> T> +<a name="l00115"></a><a class="code" href="classzen_1_1_xml_out.html#a09ca9144515e3c109b36062b0475c8eb">00115</a> <span class="keywordtype">void</span> <a class="code" href="classzen_1_1_xml_out.html#a09ca9144515e3c109b36062b0475c8eb" title="Write user data to the underlying XML element.">operator()</a>(<span class="keyword">const</span> T& value) { <a class="code" href="namespacezen.html#a29ddb823fe0a195f19a64448881b8bf6" title="Convert structured user data into an XML element.">writeStruc</a>(value, *ref_); } +<a name="l00116"></a>00116 +<a name="l00118"></a>00118 +<a name="l00142"></a>00142 <span class="keyword">template</span> <<span class="keyword">class</span> String, <span class="keyword">class</span> T> +<a name="l00143"></a><a class="code" href="classzen_1_1_xml_out.html#acaf9b71fe1d907dd63dd4b91e2e03805">00143</a> <span class="keywordtype">void</span> <a class="code" href="classzen_1_1_xml_out.html#acaf9b71fe1d907dd63dd4b91e2e03805" title="Write user data to an XML attribute.">attribute</a>(<span class="keyword">const</span> String& name, <span class="keyword">const</span> T& value) { ref_-><a class="code" href="classzen_1_1_xml_element.html#a211a6f037c22a54d3facb7a8347a8421" title="Create or update an XML attribute.">setAttribute</a>(name, value); } +<a name="l00144"></a>00144 +<a name="l00146"></a><a class="code" href="classzen_1_1_xml_out.html#aec117344e8a534382e8d5e76711f97b2">00146</a> <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>& <a class="code" href="classzen_1_1_xml_out.html#aec117344e8a534382e8d5e76711f97b2" title="Return a reference to the underlying Xml element.">ref</a>() { <span class="keywordflow">return</span> *ref_; } +<a name="l00147"></a>00147 +<a name="l00148"></a>00148 <span class="keyword">private</span>: +<a name="l00149"></a>00149 <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>* ref_; <span class="comment">//always bound!</span> +<a name="l00150"></a>00150 }; +<a name="l00151"></a>00151 +<a name="l00152"></a>00152 +<a name="l00154"></a><a class="code" href="classzen_1_1_xml_in.html">00154</a> <span class="keyword">class </span><a class="code" href="classzen_1_1_xml_in.html" title="Proxy class to conveniently convert XML structure to user data.">XmlIn</a> +<a name="l00155"></a>00155 { +<a name="l00156"></a>00156 <span class="keyword">class </span>ErrorLog; +<a name="l00157"></a>00157 <span class="keyword">struct </span>ConversionToBool { <span class="keywordtype">int</span> dummy; }; +<a name="l00158"></a>00158 +<a name="l00159"></a>00159 <span class="keyword">public</span>: +<a name="l00161"></a>00161 +<a name="l00171"></a><a class="code" href="classzen_1_1_xml_in.html#a5b48c9848e6c631a04cec2477ff85c0f">00171</a> <a class="code" href="classzen_1_1_xml_in.html#a5b48c9848e6c631a04cec2477ff85c0f" title="Construct an input proxy for an XML document.">XmlIn</a>(<span class="keyword">const</span> <a class="code" href="classzen_1_1_xml_doc.html" title="The complete XML document.">XmlDoc</a>& doc) : refIndex(0), log(std::make_shared<ErrorLog>()) { refList.push_back(&doc.<a class="code" href="classzen_1_1_xml_doc.html#ad4a9594d93885fc1a12db28e8246648d" title="Get a const reference to the document's root element.">root</a>()); } +<a name="l00173"></a>00173 +<a name="l00176"></a><a class="code" href="classzen_1_1_xml_in.html#ae072660cde71fd4695c04d074098b430">00176</a> <a class="code" href="classzen_1_1_xml_in.html#ae072660cde71fd4695c04d074098b430" title="Construct an input proxy for a single XML element, may be nullptr.">XmlIn</a>(<span class="keyword">const</span> <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>* element) : refIndex(0), log(std::make_shared<ErrorLog>()) { refList.push_back(element); } +<a name="l00178"></a>00178 +<a name="l00181"></a><a class="code" href="classzen_1_1_xml_in.html#a33de75412df69cb25e0fd8b3bc70c9f8">00181</a> <a class="code" href="classzen_1_1_xml_in.html#a33de75412df69cb25e0fd8b3bc70c9f8" title="Construct an input proxy for a single XML element.">XmlIn</a>(<span class="keyword">const</span> <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>& element) : refIndex(0), log(std::make_shared<ErrorLog>()) { refList.push_back(&element); } +<a name="l00182"></a>00182 +<a name="l00184"></a>00184 +<a name="l00189"></a>00189 <span class="keyword">template</span> <<span class="keyword">class</span> String> +<a name="l00190"></a><a class="code" href="classzen_1_1_xml_in.html#a9b38167835a28eac9a2297f35f51e53d">00190</a> <a class="code" href="classzen_1_1_xml_in.html" title="Proxy class to conveniently convert XML structure to user data.">XmlIn</a> <a class="code" href="classzen_1_1_xml_in.html#a9b38167835a28eac9a2297f35f51e53d" title="Retrieve a handle to an XML child element for reading.">operator[]</a>(<span class="keyword">const</span> String& name)<span class="keyword"> const</span> +<a name="l00191"></a>00191 <span class="keyword"> </span>{ +<a name="l00192"></a>00192 std::vector<const XmlElement*> childList; +<a name="l00193"></a>00193 +<a name="l00194"></a>00194 <span class="keywordflow">if</span> (refIndex < refList.size()) +<a name="l00195"></a>00195 { +<a name="l00196"></a>00196 <span class="keyword">auto</span> iterPair = refList[refIndex]->getChildren(name); +<a name="l00197"></a>00197 std::for_each(iterPair.first, iterPair.second, +<a name="l00198"></a>00198 [&](<span class="keyword">const</span> <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>& child) { childList.push_back(&child); }); +<a name="l00199"></a>00199 } +<a name="l00200"></a>00200 +<a name="l00201"></a>00201 <span class="keywordflow">return</span> <a class="code" href="classzen_1_1_xml_in.html#a5b48c9848e6c631a04cec2477ff85c0f" title="Construct an input proxy for an XML document.">XmlIn</a>(childList, childList.empty() ? getChildNameFormatted(name) : std::string(), log); +<a name="l00202"></a>00202 } +<a name="l00203"></a>00203 +<a name="l00205"></a>00205 +<a name="l00225"></a><a class="code" href="classzen_1_1_xml_in.html#a60cf2678c989621545d27745dcafa4a4">00225</a> <span class="keywordtype">void</span> <a class="code" href="classzen_1_1_xml_in.html#a60cf2678c989621545d27745dcafa4a4" title="Refer to next sibling element with the same name.">next</a>() { ++refIndex; } +<a name="l00226"></a>00226 +<a name="l00228"></a>00228 +<a name="l00233"></a>00233 <span class="keyword">template</span> <<span class="keyword">class</span> T> +<a name="l00234"></a><a class="code" href="classzen_1_1_xml_in.html#a98cc59f687c89549381e76105f8fb506">00234</a> <span class="keywordtype">bool</span> operator()(T& value)<span class="keyword"> const</span> +<a name="l00235"></a>00235 <span class="keyword"> </span>{ +<a name="l00236"></a>00236 <span class="keywordflow">if</span> (refIndex < refList.size()) +<a name="l00237"></a>00237 { +<a name="l00238"></a>00238 <span class="keywordtype">bool</span> success = <a class="code" href="namespacezen.html#a2bdcecfe7435ef11cedbce47d4e72ee1" title="Convert XML element to structured user data.">readStruc</a>(*refList[refIndex], value); +<a name="l00239"></a>00239 <span class="keywordflow">if</span> (!success) +<a name="l00240"></a>00240 log->notifyConversionError(getNameFormatted()); +<a name="l00241"></a>00241 <span class="keywordflow">return</span> success; +<a name="l00242"></a>00242 } +<a name="l00243"></a>00243 <span class="keywordflow">else</span> +<a name="l00244"></a>00244 { +<a name="l00245"></a>00245 log->notifyMissingElement(getNameFormatted()); +<a name="l00246"></a>00246 <span class="keywordflow">return</span> <span class="keyword">false</span>; +<a name="l00247"></a>00247 } +<a name="l00248"></a>00248 } +<a name="l00249"></a>00249 +<a name="l00251"></a>00251 +<a name="l00268"></a>00268 <span class="keyword">template</span> <<span class="keyword">class</span> String, <span class="keyword">class</span> T> +<a name="l00269"></a><a class="code" href="classzen_1_1_xml_in.html#a971cd7054c551c4460d5220f6ec5cf01">00269</a> <span class="keywordtype">bool</span> attribute(<span class="keyword">const</span> String& name, T& value)<span class="keyword"> const</span> +<a name="l00270"></a>00270 <span class="keyword"> </span>{ +<a name="l00271"></a>00271 <span class="keywordflow">if</span> (refIndex < refList.size()) +<a name="l00272"></a>00272 { +<a name="l00273"></a>00273 <span class="keywordtype">bool</span> success = refList[refIndex]->getAttribute(name, value); +<a name="l00274"></a>00274 <span class="keywordflow">if</span> (!success) +<a name="l00275"></a>00275 log->notifyMissingAttribute(getNameFormatted(), utfCvrtTo<std::string>(name)); +<a name="l00276"></a>00276 <span class="keywordflow">return</span> success; +<a name="l00277"></a>00277 } +<a name="l00278"></a>00278 <span class="keywordflow">else</span> +<a name="l00279"></a>00279 { +<a name="l00280"></a>00280 log->notifyMissingElement(getNameFormatted()); +<a name="l00281"></a>00281 <span class="keywordflow">return</span> <span class="keyword">false</span>; +<a name="l00282"></a>00282 } +<a name="l00283"></a>00283 } +<a name="l00284"></a>00284 +<a name="l00286"></a><a class="code" href="classzen_1_1_xml_in.html#a647b468b7c6c95b25f2e43627184177f">00286</a> <span class="keyword">const</span> <a class="code" href="classzen_1_1_xml_element.html" title="An XML element.">XmlElement</a>* <span class="keyword">get</span>() <span class="keyword">const</span> { <span class="keywordflow">return</span> refIndex < refList.size() ? refList[refIndex] : <span class="keyword">nullptr</span>; } +<a name="l00287"></a>00287 +<a name="l00289"></a>00289 +<a name="l00298"></a><a class="code" href="classzen_1_1_xml_in.html#a954950849b52557369932ab2a8b4ad72">00298</a> operator int ConversionToBool::* ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">get</span>() ? &ConversionToBool::dummy : <span class="keyword">nullptr</span>; } +<a name="l00299"></a>00299 +<a name="l00301"></a>00301 +<a name="l00320"></a><a class="code" href="classzen_1_1_xml_in.html#a33b5dd504d3165aa3f923f6b33e9991a">00320</a> <span class="keywordtype">bool</span> <a class="code" href="classzen_1_1_xml_in.html#a33b5dd504d3165aa3f923f6b33e9991a" title="Notifies errors while mapping the XML to user data.">errorsOccured</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> !log->elementList().empty(); } +<a name="l00321"></a>00321 +<a name="l00323"></a>00323 +<a name="l00327"></a>00327 <span class="keyword">template</span> <<span class="keyword">class</span> String> +<a name="l00328"></a><a class="code" href="classzen_1_1_xml_in.html#a84bb497d3b3fc753d054e52c4823c05e">00328</a> std::vector<String> getErrorsAs()<span class="keyword"> const</span> +<a name="l00329"></a>00329 <span class="keyword"> </span>{ +<a name="l00330"></a>00330 std::vector<String> output; +<a name="l00331"></a>00331 <span class="keyword">const</span> <span class="keyword">auto</span>& elements = log->elementList(); +<a name="l00332"></a>00332 std::transform(elements.begin(), elements.end(), std::back_inserter(output), [](<span class="keyword">const</span> std::string& str) { <span class="keywordflow">return</span> utfCvrtTo<String>(str); }); +<a name="l00333"></a>00333 <span class="keywordflow">return</span> output; +<a name="l00334"></a>00334 } +<a name="l00335"></a>00335 +<a name="l00336"></a>00336 <span class="keyword">private</span>: +<a name="l00337"></a>00337 <a class="code" href="classzen_1_1_xml_in.html" title="Proxy class to conveniently convert XML structure to user data.">XmlIn</a>(<span class="keyword">const</span> std::vector<const XmlElement*>& siblingList, <span class="keyword">const</span> std::string& elementNameFmt, <span class="keyword">const</span> std::shared_ptr<ErrorLog>& sharedlog) : +<a name="l00338"></a>00338 refList(siblingList), refIndex(0), formattedName(elementNameFmt), log(sharedlog) +<a name="l00339"></a>00339 { assert((!siblingList.empty() && elementNameFmt.empty()) || (siblingList.empty() && !elementNameFmt.empty())); } +<a name="l00340"></a>00340 +<a name="l00341"></a>00341 <span class="keyword">static</span> std::string getNameFormatted(<span class="keyword">const</span> XmlElement& elem) <span class="comment">//"<Root> <Level1> <Level2>"</span> +<a name="l00342"></a>00342 { +<a name="l00343"></a>00343 <span class="keywordflow">return</span> (elem.parent() ? getNameFormatted(*elem.parent()) + <span class="stringliteral">" "</span> : std::string()) + <span class="stringliteral">"<"</span> + elem.getNameAs<std::string>() + <span class="stringliteral">">"</span>; +<a name="l00344"></a>00344 } +<a name="l00345"></a>00345 +<a name="l00346"></a>00346 std::string getNameFormatted()<span class="keyword"> const</span> +<a name="l00347"></a>00347 <span class="keyword"> </span>{ +<a name="l00348"></a>00348 <span class="keywordflow">if</span> (refIndex < refList.size()) +<a name="l00349"></a>00349 { +<a name="l00350"></a>00350 assert(formattedName.empty()); +<a name="l00351"></a>00351 <span class="keywordflow">return</span> getNameFormatted(*refList[refIndex]); +<a name="l00352"></a>00352 } +<a name="l00353"></a>00353 <span class="keywordflow">else</span> +<a name="l00354"></a>00354 <span class="keywordflow">return</span> formattedName; +<a name="l00355"></a>00355 } +<a name="l00356"></a>00356 +<a name="l00357"></a>00357 std::string getChildNameFormatted(<span class="keyword">const</span> std::string& childName)<span class="keyword"> const</span> +<a name="l00358"></a>00358 <span class="keyword"> </span>{ +<a name="l00359"></a>00359 std::string parentName = getNameFormatted(); +<a name="l00360"></a>00360 <span class="keywordflow">return</span> (parentName.empty() ? std::string() : (parentName + <span class="stringliteral">" "</span>)) + <span class="stringliteral">"<"</span> + childName + <span class="stringliteral">">"</span>; +<a name="l00361"></a>00361 } +<a name="l00362"></a>00362 +<a name="l00363"></a>00363 <span class="keyword">class </span>ErrorLog +<a name="l00364"></a>00364 { +<a name="l00365"></a>00365 <span class="keyword">public</span>: +<a name="l00366"></a>00366 <span class="keywordtype">void</span> notifyConversionError (<span class="keyword">const</span> std::string& formattedName) { insert(formattedName); } +<a name="l00367"></a>00367 <span class="keywordtype">void</span> notifyMissingElement (<span class="keyword">const</span> std::string& formattedName) { insert(formattedName); } +<a name="l00368"></a>00368 <span class="keywordtype">void</span> notifyMissingAttribute(<span class="keyword">const</span> std::string& formattedName, <span class="keyword">const</span> std::string& attribName) { insert(formattedName + <span class="stringliteral">" @"</span> + attribName); } +<a name="l00369"></a>00369 +<a name="l00370"></a>00370 <span class="keyword">const</span> std::vector<std::string>& elementList()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> failedElements; } +<a name="l00371"></a>00371 +<a name="l00372"></a>00372 <span class="keyword">private</span>: +<a name="l00373"></a>00373 <span class="keywordtype">void</span> insert(<span class="keyword">const</span> std::string& newVal) +<a name="l00374"></a>00374 { +<a name="l00375"></a>00375 <span class="keywordflow">if</span> (usedElements.insert(newVal).second) +<a name="l00376"></a>00376 failedElements.push_back(newVal); +<a name="l00377"></a>00377 } +<a name="l00378"></a>00378 +<a name="l00379"></a>00379 std::vector<std::string> failedElements; <span class="comment">//unique list of failed elements</span> +<a name="l00380"></a>00380 std::set<std::string> usedElements; +<a name="l00381"></a>00381 }; +<a name="l00382"></a>00382 +<a name="l00383"></a>00383 std::vector<const XmlElement*> refList; <span class="comment">//all sibling elements with same name (all pointers bound!)</span> +<a name="l00384"></a>00384 <span class="keywordtype">size_t</span> refIndex; <span class="comment">//this sibling's index in refList</span> +<a name="l00385"></a>00385 std::string formattedName; <span class="comment">//contains full and formatted element name if (and only if) refList is empty</span> +<a name="l00386"></a>00386 std::shared_ptr<ErrorLog> log; <span class="comment">//always bound</span> +<a name="l00387"></a>00387 }; +<a name="l00388"></a>00388 } +<a name="l00389"></a>00389 +<a name="l00390"></a>00390 <span class="preprocessor">#endif //ZEN_XML_BIND_HEADER_9081740816593478258435</span> +</pre></div></div><!-- contents --> + + +<hr class="footer"/><address class="footer"><small> +Generated by  <a href="http://www.doxygen.org/index.html"> +<img class="footer" src="doxygen.png" alt="doxygen"/> +</a> 1.8.0 +</small></address> + +</body> +</html> |