diff options
Diffstat (limited to 'c++/src/cpplus_RM/create_8cpp-example.html')
-rw-r--r-- | c++/src/cpplus_RM/create_8cpp-example.html | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/c++/src/cpplus_RM/create_8cpp-example.html b/c++/src/cpplus_RM/create_8cpp-example.html new file mode 100644 index 0000000..2e6654c --- /dev/null +++ b/c++/src/cpplus_RM/create_8cpp-example.html @@ -0,0 +1,226 @@ +<!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"/> +<meta name="generator" content="Doxygen 1.8.5"/> +<title>HDF5 C++ API: create.cpp</title> +<link href="tabs.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="jquery.js"></script> +<script type="text/javascript" src="dynsections.js"></script> +<link href="search/search.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="search/search.js"></script> +<script type="text/javascript"> + $(document).ready(function() { searchBox.OnSelectItem(0); }); +</script> +<link href="doxygen.css" rel="stylesheet" type="text/css" /> +</head> +<body> +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> +<div id="titlearea"> +<table cellspacing="0" cellpadding="0"> + <tbody> + <tr style="height: 56px;"> + <td id="projectlogo"><img alt="Logo" src="hdf_logo.jpg"/></td> + <td style="padding-left: 0.5em;"> + <div id="projectname">HDF5 C++ API +  <span id="projectnumber">1.8.13</span> + </div> + </td> + </tr> + </tbody> +</table> +</div> +<!-- end header part --> +<!-- Generated by Doxygen 1.8.5 --> +<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="annotated.html"><span>Classes</span></a></li> + <li><a href="examples.html"><span>Examples</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><!-- top --> +<!-- 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><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Pages</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">create.cpp</div> </div> +</div><!--header--> +<div class="contents"> +<p>This example shows how to create datasets. </p> +<dl class="section user"><dt></dt><dd></dd></dl> +<div class="fragment"><div class="line"><span class="comment">/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *</span></div> +<div class="line"><span class="comment"> * Copyright by The HDF Group. *</span></div> +<div class="line"><span class="comment"> * Copyright by the Board of Trustees of the University of Illinois. *</span></div> +<div class="line"><span class="comment"> * All rights reserved. *</span></div> +<div class="line"><span class="comment"> * *</span></div> +<div class="line"><span class="comment"> * This file is part of HDF5. The full HDF5 copyright notice, including *</span></div> +<div class="line"><span class="comment"> * terms governing use, modification, and redistribution, is contained in *</span></div> +<div class="line"><span class="comment"> * the files COPYING and Copyright.html. COPYING can be found at the root *</span></div> +<div class="line"><span class="comment"> * of the source code distribution tree; Copyright.html can be found at the *</span></div> +<div class="line"><span class="comment"> * root level of an installed copy of the electronic HDF5 document set and *</span></div> +<div class="line"><span class="comment"> * is linked from the top-level documents page. It can also be found at *</span></div> +<div class="line"><span class="comment"> * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *</span></div> +<div class="line"><span class="comment"> * access to either file, you may request a copy from help@hdfgroup.org. *</span></div> +<div class="line"><span class="comment"> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */</span></div> +<div class="line"></div> +<div class="line"><span class="comment">/*</span></div> +<div class="line"><span class="comment"> * This example writes a dataset to a new HDF5 file.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"></div> +<div class="line"><span class="preprocessor">#ifdef OLD_HEADER_FILENAME</span></div> +<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include <iostream.h></span></div> +<div class="line"><span class="preprocessor">#else</span></div> +<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include <iostream></span></div> +<div class="line"><span class="preprocessor">#endif</span></div> +<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include <string></span></div> +<div class="line"></div> +<div class="line"><span class="preprocessor">#include "H5Cpp.h"</span></div> +<div class="line"></div> +<div class="line"><span class="preprocessor">#ifndef H5_NO_NAMESPACE</span></div> +<div class="line"><span class="preprocessor"></span> <span class="keyword">using namespace </span>H5;</div> +<div class="line"><span class="preprocessor">#endif</span></div> +<div class="line"><span class="preprocessor"></span></div> +<div class="line"><span class="keyword">const</span> H5std_string FILE_NAME( <span class="stringliteral">"SDS.h5"</span> );</div> +<div class="line"><span class="keyword">const</span> H5std_string DATASET_NAME( <span class="stringliteral">"IntArray"</span> );</div> +<div class="line"><span class="keyword">const</span> <span class="keywordtype">int</span> NX = 5; <span class="comment">// dataset dimensions</span></div> +<div class="line"><span class="keyword">const</span> <span class="keywordtype">int</span> NY = 6;</div> +<div class="line"><span class="keyword">const</span> <span class="keywordtype">int</span> RANK = 2;</div> +<div class="line"></div> +<div class="line"><span class="keywordtype">int</span> main (<span class="keywordtype">void</span>)</div> +<div class="line">{</div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Data initialization.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> <span class="keywordtype">int</span> i, j;</div> +<div class="line"> <span class="keywordtype">int</span> data[NX][NY]; <span class="comment">// buffer for data to write</span></div> +<div class="line"> <span class="keywordflow">for</span> (j = 0; j < NX; j++)</div> +<div class="line"> {</div> +<div class="line"> <span class="keywordflow">for</span> (i = 0; i < NY; i++)</div> +<div class="line"> data[j][i] = i + j;</div> +<div class="line"> }</div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * 0 1 2 3 4 5</span></div> +<div class="line"><span class="comment"> * 1 2 3 4 5 6</span></div> +<div class="line"><span class="comment"> * 2 3 4 5 6 7</span></div> +<div class="line"><span class="comment"> * 3 4 5 6 7 8</span></div> +<div class="line"><span class="comment"> * 4 5 6 7 8 9</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"></div> +<div class="line"> <span class="comment">// Try block to detect exceptions raised by any of the calls inside it</span></div> +<div class="line"> <span class="keywordflow">try</span></div> +<div class="line"> {</div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Turn off the auto-printing when failure occurs so that we can</span></div> +<div class="line"><span class="comment"> * handle the errors appropriately</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> <a name="a0"></a><a class="code" href="class_h5_1_1_exception.html#ad49f16300979996c094c2e4f57868414">Exception::dontPrint</a>();</div> +<div class="line"></div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Create a new file using H5F_ACC_TRUNC access,</span></div> +<div class="line"><span class="comment"> * default file creation properties, and default file</span></div> +<div class="line"><span class="comment"> * access properties.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> <a name="_a1"></a><a class="code" href="class_h5_1_1_h5_file.html">H5File</a> file( FILE_NAME, H5F_ACC_TRUNC );</div> +<div class="line"></div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Define the size of the array and create the data space for fixed</span></div> +<div class="line"><span class="comment"> * size dataset.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> hsize_t dimsf[2]; <span class="comment">// dataset dimensions</span></div> +<div class="line"> dimsf[0] = NX;</div> +<div class="line"> dimsf[1] = NY;</div> +<div class="line"> <a name="_a2"></a><a class="code" href="class_h5_1_1_data_space.html">DataSpace</a> dataspace( RANK, dimsf );</div> +<div class="line"></div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Define datatype for the data in the file.</span></div> +<div class="line"><span class="comment"> * We will store little endian INT numbers.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> <a name="_a3"></a><a class="code" href="class_h5_1_1_int_type.html">IntType</a> datatype( <a name="a4"></a><a class="code" href="class_h5_1_1_pred_type.html#a3308bcd537696a8d728cd3b443f2fc7b">PredType::NATIVE_INT</a> );</div> +<div class="line"> datatype.setOrder( H5T_ORDER_LE );</div> +<div class="line"></div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Create a new dataset within the file using defined dataspace and</span></div> +<div class="line"><span class="comment"> * datatype and default dataset creation properties.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> <a name="_a5"></a><a class="code" href="class_h5_1_1_data_set.html">DataSet</a> dataset = file.createDataSet( DATASET_NAME, datatype, dataspace );</div> +<div class="line"></div> +<div class="line"> <span class="comment">/*</span></div> +<div class="line"><span class="comment"> * Write the data to the dataset using default memory space, file</span></div> +<div class="line"><span class="comment"> * space, and transfer properties.</span></div> +<div class="line"><span class="comment"> */</span></div> +<div class="line"> dataset.<a name="a6"></a><a class="code" href="class_h5_1_1_data_set.html#a3ce98e7a626fd32a23d1bcc41537326f">write</a>( data, <a class="code" href="class_h5_1_1_pred_type.html#a3308bcd537696a8d728cd3b443f2fc7b">PredType::NATIVE_INT</a> );</div> +<div class="line"> } <span class="comment">// end of try block</span></div> +<div class="line"></div> +<div class="line"> <span class="comment">// catch failure caused by the H5File operations</span></div> +<div class="line"> <span class="keywordflow">catch</span>( <a name="_a7"></a><a class="code" href="class_h5_1_1_file_i_exception.html">FileIException</a> error )</div> +<div class="line"> {</div> +<div class="line"> error.<a name="a8"></a><a class="code" href="class_h5_1_1_exception.html#ad5bf0f93b4156d6366110dd5e08342a2">printError</a>();</div> +<div class="line"> <span class="keywordflow">return</span> -1;</div> +<div class="line"> }</div> +<div class="line"></div> +<div class="line"> <span class="comment">// catch failure caused by the DataSet operations</span></div> +<div class="line"> <span class="keywordflow">catch</span>( <a name="_a9"></a><a class="code" href="class_h5_1_1_data_set_i_exception.html">DataSetIException</a> error )</div> +<div class="line"> {</div> +<div class="line"> error.<a class="code" href="class_h5_1_1_exception.html#ad5bf0f93b4156d6366110dd5e08342a2">printError</a>();</div> +<div class="line"> <span class="keywordflow">return</span> -1;</div> +<div class="line"> }</div> +<div class="line"></div> +<div class="line"> <span class="comment">// catch failure caused by the DataSpace operations</span></div> +<div class="line"> <span class="keywordflow">catch</span>( <a name="_a10"></a><a class="code" href="class_h5_1_1_data_space_i_exception.html">DataSpaceIException</a> error )</div> +<div class="line"> {</div> +<div class="line"> error.<a class="code" href="class_h5_1_1_exception.html#ad5bf0f93b4156d6366110dd5e08342a2">printError</a>();</div> +<div class="line"> <span class="keywordflow">return</span> -1;</div> +<div class="line"> }</div> +<div class="line"></div> +<div class="line"> <span class="comment">// catch failure caused by the DataSpace operations</span></div> +<div class="line"> <span class="keywordflow">catch</span>( <a name="_a11"></a><a class="code" href="class_h5_1_1_data_type_i_exception.html">DataTypeIException</a> error )</div> +<div class="line"> {</div> +<div class="line"> error.<a class="code" href="class_h5_1_1_exception.html#ad5bf0f93b4156d6366110dd5e08342a2">printError</a>();</div> +<div class="line"> <span class="keywordflow">return</span> -1;</div> +<div class="line"> }</div> +<div class="line"></div> +<div class="line"> <span class="keywordflow">return</span> 0; <span class="comment">// successfully terminated</span></div> +<div class="line">}</div> +<div class="line"></div> +</div><!-- fragment --> </div><!-- contents --> +<!-- start footer part --> +<hr class="footer"/><address class="footer"><small> +Generated on Mon Jul 21 2014 10:58:44 for HDF5 C++ API by  <a href="http://www.doxygen.org/index.html"> +<img class="footer" src="doxygen.png" alt="doxygen"/> +</a> 1.8.5 +</small></address> +</body> +</html> |