/usr/share/doc/libitpp-dev/html/itfile.html is in libitpp-doc 4.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Welcome to IT++!</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div style="width: 100%; height: 40px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
<a href="http://itpp.sourceforge.net"><img src="itpp_logo.png" alt="IT++ Logo" style="float: left; border: 0;"></a>
</div>
<!-- Generated by Doxygen 1.7.4 -->
<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 class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="dirs.html"><span>Directories</span></a></li>
<li id="searchli">
<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>
<div class="header">
<div class="headertitle">
<div class="title">Writing and reading data from files </div> </div>
</div>
<div class="contents">
<div class="textblock"><p>Here we will use the <code>it_file</code> class to store some data. The program <code>write_it_file.cpp</code> looks as follows:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include <<a class="code" href="itcomm_8h.html" title="Include file for the IT++ communications module.">itpp/itcomm.h</a>></span>
<span class="keyword">using namespace </span>itpp;
<span class="keywordtype">int</span> main()
{
<span class="comment">// Declare the it_file class</span>
<a class="code" href="classitpp_1_1it__file.html" title="The IT++ file format reading and writing class.">it_file</a> ff;
<span class="comment">// Open a file with the name "it_file_test.it"</span>
ff.<a class="code" href="classitpp_1_1it__file.html#a549f27e6830fa68fc964041b79733168" title="Open a file for reading and writing.">open</a>(<span class="stringliteral">"it_file_test.it"</span>);
<span class="comment">// Create some data to put into the file</span>
vec a = <a class="code" href="group__specmat.html#gae5632baa525e231b015f3d45f3503cac" title="Linspace (works in the same way as the matlab version)">linspace</a>(1, 20, 20);
<span class="comment">// Put the variable a into the file. The Name("a") tells the file class</span>
<span class="comment">// that the next variable shall be named "a".</span>
ff << <a class="code" href="classitpp_1_1Name.html" title="Automatic naming when savingAn easy way to give a variable a name and optionally description when sav...">Name</a>(<span class="stringliteral">"a"</span>) << a;
<span class="comment">// Force the file to be written to disc. This is useful when performing</span>
<span class="comment">// iterations and ensures that the information is not stored in any cache</span>
<span class="comment">// memory. In this simple example it is not necessary to flush the file.</span>
ff.<a class="code" href="classitpp_1_1it__file.html#a1ca5957bb8c2d18112b758b0993b2f2a" title="Flush the data to disk.">flush</a>();
<span class="comment">// Close the file</span>
ff.<a class="code" href="classitpp_1_1it__file.html#a6e7217f36b35d6ea866e5fa8148009fa" title="Close the file.">close</a>();
<span class="comment">// Exit program</span>
<span class="keywordflow">return</span> 0;
}
</pre></div><p>When you run this program you will obtain a file called <code>it_file_test.it</code> in your current directory. You can read the file into Matlab/Octave to view the data by using the following commands:</p>
<div class="fragment"><pre class="fragment">itload(<span class="stringliteral">'it_file_test.it'</span>)
figure(1); clf;
plot(a)
</pre></div><p>Note: Make sure that <code>$PREFIX/share/itpp</code> is in your Matlab/Octave path and that you run the code above from the directory where <code>it_file_test.it</code> is located (<code>$PREFIX</code> is the IT++ installation prefix; <code>/usr/local</code> by default).</p>
<p>The IT++ program <code>read_it_file.cpp</code> that reads the file and prints its content can look like this:</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include <<a class="code" href="itcomm_8h.html" title="Include file for the IT++ communications module.">itpp/itcomm.h</a>></span>
<span class="keyword">using namespace </span>itpp;
<span class="keywordtype">int</span> main()
{
<span class="comment">// Declare the it_file class</span>
<a class="code" href="classitpp_1_1it__file.html" title="The IT++ file format reading and writing class.">it_file</a> ff;
<span class="comment">// Open the file "it_file_test.it" for reading</span>
ff.<a class="code" href="classitpp_1_1it__file.html#a549f27e6830fa68fc964041b79733168" title="Open a file for reading and writing.">open</a>(<span class="stringliteral">"it_file_test.it"</span>);
<span class="comment">// Read the variable a from the file. Put result in vector a.</span>
vec a;
ff >> <a class="code" href="classitpp_1_1Name.html" title="Automatic naming when savingAn easy way to give a variable a name and optionally description when sav...">Name</a>(<span class="stringliteral">"a"</span>) >> a;
<span class="comment">// Print the result</span>
std::cout << <span class="stringliteral">"a = "</span> << a << std::endl;
<span class="comment">// Exit the program</span>
<span class="keywordflow">return</span> 0;
}
</pre></div><p>Here is the output of the program:</p>
<div class="fragment"><pre class="fragment">
a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
</pre></div> </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>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</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 style="clear: both; width: 100%; height: 31px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=37044&type=1" alt="SourceForge Logo" style="float: right; border: 0;"></a>
<p style="padding-left: 10px; font-size: 85%;">Generated on Wed Jul 27 2011 16:27:06 for IT++ by <a href="http://www.doxygen.org/index.html">Doxygen</a> 1.7.4</p>
</div>
</body>
</html>
|