Ver Fonte

changes in the readme

Patrik Kovacs há 7 anos atrás
pai
commit
22fc93eb7f
1 ficheiros alterados com 74 adições e 8 exclusões
  1. 74 8
      README.md

+ 74 - 8
README.md

@@ -6,14 +6,14 @@ The HDF4CPP library is a wrapper library of the hdf4 C interfaces.
 The target was to create a common c++ api to read and write hdf scientific data.
 The target was to create a common c++ api to read and write hdf scientific data.
 The only supports the reading of the data at the moment.
 The only supports the reading of the data at the moment.
 
 
-## Api overview
+## API overview
 
 
 ### The idea
 ### The idea
 
 
 The idea is to use objects and their methods to do the operations.
 The idea is to use objects and their methods to do the operations.
 These classes are representing different kind of data,
 These classes are representing different kind of data,
 so the operation functions are separated. 
 so the operation functions are separated. 
-It is easy to decide which object's method I have to call.
+Only reading is supported right now.
 
 
 ### Classes and objects
 ### Classes and objects
 
 
@@ -28,6 +28,13 @@ It is easy to decide which object's method I have to call.
 
 
 ## How does it work?
 ## How does it work?
 
 
+### Include the library
+
+You have to include a single file.
+```cpp
+#include <hdf4cpp/hdf.h>
+```
+
 ### Open an file
 ### Open an file
 
 
 ```cpp
 ```cpp
@@ -74,24 +81,83 @@ for every reading procedure.
 The first parameter is a vector in every case, 
 The first parameter is a vector in every case, 
 in which the data will be stored.
 in which the data will be stored.
 
 
-Check example codes for data specific read instructions.
+#### Reading SData
+
+You have two possibilities.
+
+1. You can read the entire data.
+
+```cpp
+std::vector<int> vec;
+item.read(vec);
+```
+2. You can read the data in a specific range.
+
+```cpp
+std::vector<int> vec;
+std::vector<hdf4cpp::Range> ranges;
+// We have to specify the range for every dimension
+for(size_t i = 0; i < number_of_dimensions; ++i) {
+    ranges.push_back(hdf4cpp::Range(begin, quantity, stride));
+    // begin - the first index which is included in the range
+    // quantity - the number of value to be read
+    // stride - reading pattern (1 : every element, 2 : every second element, ...)
+    // stride has a default value (1 : every element)
+}
+item.read(vec, ranges);
+```
+
+#### Reading VData
+
+You have to specify:
+* which field do you want to read
+* how many records do you want to read
 
 
-Note: The library does a type size check, and throws exception 
+1. Reading scalar data
+
+The data can be scalar: a field has only one value for every record.
+
+```cpp
+std::vector<int> vec;
+item.read(vec, "field_name", number_of_records);
+```
+
+2. Reading array data
+
+The data can be array: a field has multiple values for every record.
+For example: if a field's type is string, it is considered that 
+every record has multiple character values (character array).
+
+```cpp
+// Reading string field
+std::vector<std::vector<char> > vec;
+item.read(vec, "field_name"); // the number_of_records it can be eliminated if I want to read all the records
+// Getting the string vector
+std::vector<std::string> string_vec;
+for(const auto& char_vec : vec) {
+    string_vec.push_back(char_vec.data());
+}
+```
+
+Note: The library does a type size check, and throws an exception 
 in case of missmatch.
 in case of missmatch.
 
 
 ### Reading attribute data
 ### Reading attribute data
 
 
-Reading attribute data is much more easier than reading the item's data.
-That's because all the attribute data has an array structure.
 The **HdfAttribute** objects have a read function which receives a vector reference.
 The **HdfAttribute** objects have a read function which receives a vector reference.
 Here will be the data stored.
 Here will be the data stored.
 
 
-Note: The library does a type size check, and throws exception 
+```cpp
+std::vector<short> vec;
+attribute.get(vec);
+```
+
+Note: The library does a type size check, and throws an exception 
 in case of missmatch.
 in case of missmatch.
 
 
 ## Exception mechanism
 ## Exception mechanism
 
 
-The library throws **HdfException**.
+The library throws an **HdfException** on any errors.
 This specific exception has **getType** and **getClassType** methods, 
 This specific exception has **getType** and **getClassType** methods, 
 just to get information about the thrower object.
 just to get information about the thrower object.
 Has a **getExceptionType** which returns information about the type
 Has a **getExceptionType** which returns information about the type