root/doc/html/group__parser.html @ 353

Revision 353, 6.1 kB (checked in by smidl, 16 years ago)

doc

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: Argument Parser</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.8 -->
8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="modules.html"><span>Modules</span></a></li>
55      <li><a href="annotated.html"><span>Classes</span></a></li>
56      <li><a href="files.html"><span>Files</span></a></li>
57    </ul>
58  </div>
59</div>
60<div class="contents">
61<h1>Argument Parser<br>
62<small>
63[<a class="el" href="group__base.html">Base Module</a>]</small>
64</h1>Argument <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a>
65<a href="#_details">More...</a>
66<p>
67<table border="0" cellpadding="0" cellspacing="0">
68<tr><td></td></tr>
69<tr><td colspan="2"><br><h2>Classes</h2></td></tr>
70<tr><td class="memItemLeft" nowrap align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classitpp_1_1Parser.html">itpp::Parser</a></td></tr>
71
72<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Argument <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a> Class.  <a href="classitpp_1_1Parser.html#_details">More...</a><br></td></tr>
73</table>
74<hr><a name="_details"></a><h2>Detailed Description</h2>
75Argument <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a>.
76<p>
77<dl class="author" compact><dt><b>Author:</b></dt><dd>Thomas Eriksson and Pal Frenger (Thanks to Svante Signell for valuable input), modifications by Johan Bergman</dd></dl>
78This class parses strings to variables. The syntax is compatible with Matlab and Octave. It can be used in several different ways. The following test program and test data file gives several examples:<p>
79<ul>
80<li>
81Use the <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a> class on a parameter file  </li>
82<li>
83Use the <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a> class on the command line input  </li>
84<li>
85Use the <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a> class on a char pointer (usually the command line input)  </li>
86<li>
87Use the <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a> class on a parameter file and a char pointer  </li>
88<li>
89Use the <a class="el" href="classitpp_1_1Parser.html" title="Argument Parser Class.">Parser</a> class on an <a class="el" href="classitpp_1_1Array.html" title="General array class.">Array</a> of strings  </li>
90<li>
91Use the <a class="el" href="classitpp_1_1Parser.html#e9d251acac7dbb48e60f614105d047cf" title="Get variable value if name can be found (and return true), otherwise keep old value...">Parser::get()</a> method on a parameter file  </li>
92<li>
93Use the <a class="el" href="classitpp_1_1Parser.html#c0045afbb4d7003f282f810774eb7c4c" title="Check is name exists in the file. Returns true if the name is found and false otherwise...">Parser::exist()</a> method to check if variables exist  </li>
94</ul>
95<p>
96The test program looks as follows: <div class="fragment"><pre class="fragment"></pre></div><p>
97The data file <code>parser_test_data.txt</code> looks as follows: <div class="fragment"><pre class="fragment"></pre></div><p>
98Beside the type-specific get methods, like get_int(), there is a templated get method called get(), that can handle all variable types that have an istream operator defined, e.g. Arrays. The get() method takes the variable value as an input/output parameter. If the variable name cannot be found, the old value is kept. Here is an example:<p>
99<div class="fragment"><pre class="fragment">  <span class="comment">// Declare and initialize a variable</span>
100  Array&lt;ivec&gt; var;
101  set_array(var, <span class="stringliteral">"{[1] [2 3] [4 5 6]}"</span>);
102
103  <span class="comment">// Let the Parser p get the variable named my_var_name</span>
104  <span class="keywordtype">bool</span> my_var_name_was_found = p.get(var, <span class="stringliteral">"my_var_name"</span>);
105</pre></div><p>
106In the above example, if <code>my_var_name</code> was not found, <code>var</code> keeps its old value {[1] [2 3] [4 5 6]}. In non-silent mode, the get() method echoes the variable values to the standard output in Matlab/Octave m-file style. </div>
107<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:14 2009 for mixpp by&nbsp;
108<a href="http://www.doxygen.org/index.html">
109<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
110</body>
111</html>
Note: See TracBrowser for help on using the browser.