VsUtils.h 2.33 KB
Newer Older
1
/**
2
 * @file VsUtils.h
3
 *
4 5
 * @class VsUtils
 * @brief Some useful routines for HDF5 handling.
6 7 8 9
 *
 * Copyright © 2008 by Tech-X Corporation
 */

10 11
#include <hdf5.h>

apletzer's avatar
apletzer committed
12 13
#ifndef VS_UTILS_H
#define VS_UTILS_H
14 15 16 17 18

#include <string>
#include <vector>

// Get dimensions of a dataset or attribute
19
//void getDims(hid_t id, bool isDataset, std::vector<int>& dims);
20

apletzer's avatar
apletzer committed
21 22 23 24 25 26
/**
 * Create fully qualified name from an object name
 * @param name object name
 * @return object name without leading "/"
 */
std::string makeCanonicalName(const std::string& name);
27

apletzer's avatar
apletzer committed
28 29 30 31 32 33 34 35
/** 
 * Create fully qualified name from object path and name,
 * @param path
 * @param name
 * @return path + "/" + name (without leading "/")
 */
std::string makeCanonicalName(const std::string& path, 
                              const std::string& name);
36 37

// Compare two object names to a target name
apletzer's avatar
apletzer committed
38 39 40
// @return the name that is "closest" to the target
// @note If the two object names are identical, will return the first
//std::string getClosestName(const std::string& name1, const std::string& name2, const std::string& target);
41

42 43 44 45 46
/**
 * Check data type
 * @param dataType HDF5 data type
 * @return true if type is double
 */
47
bool isDoubleType(hid_t dataType);
48 49 50 51 52 53

/**
 * Check data type
 * @param dataType HDF5 data type
 * @return true if type is float
 */
54
bool isFloatType(hid_t dataType);
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

/**
 * Check data type
 * @param dataType HDF5 data type
 * @return true if type is int
 */
bool isIntType(hid_t dataType);

/**
 * Check data type
 * @param dataType HDF5 data type
 * @return true if type is short
 */
bool isShortType(hid_t dataType);

/**
 * Check data type
 * @param dataType HDF5 data type
 * @return true if type is char
 */
bool isCharType(hid_t dataType);

/**
 * Check data type
 * @param dataType HDF5 data type
 * @return true if type is unsigned char
 */
bool isUnsignedCharType(hid_t dataType);

84 85 86
void printType(hid_t dataType);

// Break a string into pieces
apletzer's avatar
apletzer committed
87 88 89
void tokenize(const std::string& text, 
              char separator, std::vector<std::string>& tokens);

90

apletzer's avatar
apletzer committed
91 92 93 94 95 96
void adjustSize_hsize_t(hsize_t* dims, unsigned int rank, 
                        const std::vector<int>& stride, 
                        int before, int after);
void adjustSize_vector(std::vector<int>* dims, int rank, 
                       const std::vector<int>& stride, 
                       int before, int after);
97

apletzer's avatar
apletzer committed
98
#endif // VS_UTILS_H
99