diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-09-30 14:27:10 (GMT) |
commit | b2d661b508a7fc7a2592c13bc6bdc175551f075d (patch) | |
tree | 13baeb0d83a7c2a4c6299993c182b1227c2f6114 /hl/c++/src | |
parent | 29ab58b58dce556639ea3154e262895773a8a8df (diff) | |
download | hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2 |
Clang-format of source files
Diffstat (limited to 'hl/c++/src')
-rw-r--r-- | hl/c++/src/H5PacketTable.cpp | 512 | ||||
-rw-r--r-- | hl/c++/src/H5PacketTable.h | 52 |
2 files changed, 286 insertions, 278 deletions
diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp index 544df0b..1409048 100644 --- a/hl/c++/src/H5PacketTable.cpp +++ b/hl/c++/src/H5PacketTable.cpp @@ -24,257 +24,265 @@ #include "H5PacketTable.h" - /********************************/ - /* PacketTable superclass */ - /********************************/ - - /* "Open" Constructor - * Opens an existing packet table, which can contain either fixed-length or - * variable-length packets. - */ - PacketTable::PacketTable(hid_t fileID, const char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable::PacketTable(hid_t fileID, char* name) - { - table_id = H5PTopen( fileID, name); - } - - /* Destructor - * Cleans up the packet table - */ - PacketTable::~PacketTable() - { - H5PTclose( table_id); - } - - /* IsValid - * Returns true if this packet table is valid, false otherwise. - * Use this after the constructor to ensure HDF did not have - * any trouble making or opening the packet table. - */ - bool PacketTable::IsValid() - { - if (H5PTis_valid(table_id) == 0) - return true; - else - return false; - } - - /* IsVariableLength - * Return 1 if this packet table uses variable-length datatype, - * and 0, otherwise. Returns -1 if the table is invalid (not open). - */ - int PacketTable::IsVariableLength() - { - return H5PTis_varlen(table_id); - } - - /* ResetIndex - * Sets the index to point to the first packet in the packet table - */ - void PacketTable::ResetIndex() - { - H5PTcreate_index(table_id); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - int PacketTable::SetIndex(hsize_t index) - { - return H5PTset_index(table_id, index); - } - - /* SetIndex - * Sets the index to point to the packet specified by index. - * Returns 0 on success, negative on failure (if index is out of bounds) - */ - hsize_t PacketTable::GetIndex(int &error) - { - hsize_t index; - - error = H5PTget_index(table_id, &index); - if(error < 0) - return 0; - else - return index; - } - - /* GetPacketCount - * Returns the number of packets in the packet table. Error - * is set to 0 on success. On failure, returns 0 and - * error is set to negative. - */ - hsize_t PacketTable::GetPacketCount(int& error) - { - hsize_t npackets; - - error = H5PTget_num_packets(table_id, &npackets); - return npackets; - } - - /* GetTableId - * Returns the identifier of the packet table - */ - hid_t PacketTable::GetTableId() - { - return table_id; - } - - /* GetDatatype - * Returns the datatype identifier used by the packet table, on success, - * or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDatatype() - { - return H5PTget_type(table_id); - } - - /* GetDataset - * Returns the dataset identifier associated with the packet table, on - * success, or H5I_INVALID_HID, on failure. - * Note: it is best to avoid using this identifier in applications, unless - * the desired functionality cannot be performed via the packet table ID. - */ - hid_t PacketTable::GetDataset() - { - return H5PTget_dataset(table_id); - } - - /* FreeBuff - * Frees the buffers created when variable-length packets are read. - * Takes the number of hvl_t structs to be freed and a pointer to their - * location in memory. - * Returns 0 on success, negative on error. - */ - int PacketTable::FreeBuff(size_t numStructs, hvl_t * buffer) - { - return H5PTfree_vlen_buff( table_id, numStructs, buffer); - } - - - /********************************/ - /* Fixed-Length Packet Table */ - /********************************/ - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize, hid_t plistID) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - deprecated - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the ID of - * the property list to specify compression, the name of the packet table, - * the ID of the datatype, and the size of a memory chunk used in chunking. - * Note: The above constructor has a better prototype, which allows default - * values to be used. This constructor was only released in 1.10.0. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char* name, hid_t dtypeID, hsize_t chunkSize) - { - table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); - } - - /* Constructor - * Creates a packet table to store either fixed- or variable-length packets. - * Takes the ID of the file the packet table will be created in, the name of - * the packet table, the ID of the datatype of the set, and the size - * of a memory chunk used in chunking. - * Note: this overload will be deprecated in favor of the constructor above. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression) - { - table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); - } - - /* "Open" Constructor - * Opens an existing fixed-length packet table. - * Fails if the packet table specified is variable-length. - */ - FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name) : PacketTable(fileID, name) {} - - /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name) {} - - /* AppendPacket - * Adds a single packet to the packet table. Takes a pointer - * to the location of the data in memory. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::AppendPacket(void * data) - { - return H5PTappend(table_id, 1, data); - } - - /* AppendPackets (multiple packets) - * Adds multiple packets to the packet table. Takes the number of packets - * to be added and a pointer to their location in memory. - * Returns 0 on success, -1 on failure. - */ - int FL_PacketTable::AppendPackets(size_t numPackets, void * data) - { - return H5PTappend(table_id, numPackets, data); - } - - /* GetPacket (indexed) - * Gets a single packet from the packet table. Takes the index - * of the packet (with 0 being the first packet) and a pointer - * to memory where the data should be stored. - * Returns 0 on success, negative on failure - */ - int FL_PacketTable::GetPacket(hsize_t index, void * data) - { - return H5PTread_packets(table_id, index, 1, data); - } - - /* GetPackets (multiple packets) - * Gets multiple packets at once, all packets between - * startIndex and endIndex inclusive. Also takes a pointer to - * the memory where these packets should be stored. - * Returns 0 on success, negative on failure. - */ - int FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void * data) - { - // Make sure the range of indexes is valid - if (startIndex > endIndex) - return -1; - - return H5PTread_packets(table_id, startIndex, (size_t)(endIndex-startIndex+1), data); - } - - /* GetNextPacket (single packet) - * Gets the next packet in the packet table. Takes a pointer to - * memory where the packet should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced to the next packet on failure. - */ - int FL_PacketTable::GetNextPacket(void * data) - { - return H5PTget_next(table_id, 1, data); - } - - /* GetNextPackets (multiple packets) - * Gets the next numPackets packets in the packet table. Takes a - * pointer to memory where these packets should be stored. - * Returns 0 on success, negative on failure. Index - * is not advanced on failure. - */ - int FL_PacketTable::GetNextPackets(size_t numPackets, void * data) - { - return H5PTget_next(table_id, numPackets, data); - } +/********************************/ +/* PacketTable superclass */ +/********************************/ + +/* "Open" Constructor + * Opens an existing packet table, which can contain either fixed-length or + * variable-length packets. + */ +PacketTable::PacketTable(hid_t fileID, const char *name) { table_id = H5PTopen(fileID, name); } + +/* "Open" Constructor - will be deprecated because of char* name */ +PacketTable::PacketTable(hid_t fileID, char *name) { table_id = H5PTopen(fileID, name); } + +/* Destructor + * Cleans up the packet table + */ +PacketTable::~PacketTable() { H5PTclose(table_id); } + +/* IsValid + * Returns true if this packet table is valid, false otherwise. + * Use this after the constructor to ensure HDF did not have + * any trouble making or opening the packet table. + */ +bool +PacketTable::IsValid() +{ + if (H5PTis_valid(table_id) == 0) + return true; + else + return false; +} + +/* IsVariableLength + * Return 1 if this packet table uses variable-length datatype, + * and 0, otherwise. Returns -1 if the table is invalid (not open). + */ +int +PacketTable::IsVariableLength() +{ + return H5PTis_varlen(table_id); +} + +/* ResetIndex + * Sets the index to point to the first packet in the packet table + */ +void +PacketTable::ResetIndex() +{ + H5PTcreate_index(table_id); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +int +PacketTable::SetIndex(hsize_t index) +{ + return H5PTset_index(table_id, index); +} + +/* SetIndex + * Sets the index to point to the packet specified by index. + * Returns 0 on success, negative on failure (if index is out of bounds) + */ +hsize_t +PacketTable::GetIndex(int &error) +{ + hsize_t index; + + error = H5PTget_index(table_id, &index); + if (error < 0) + return 0; + else + return index; +} + +/* GetPacketCount + * Returns the number of packets in the packet table. Error + * is set to 0 on success. On failure, returns 0 and + * error is set to negative. + */ +hsize_t +PacketTable::GetPacketCount(int &error) +{ + hsize_t npackets; + + error = H5PTget_num_packets(table_id, &npackets); + return npackets; +} + +/* GetTableId + * Returns the identifier of the packet table + */ +hid_t +PacketTable::GetTableId() +{ + return table_id; +} + +/* GetDatatype + * Returns the datatype identifier used by the packet table, on success, + * or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDatatype() +{ + return H5PTget_type(table_id); +} + +/* GetDataset + * Returns the dataset identifier associated with the packet table, on + * success, or H5I_INVALID_HID, on failure. + * Note: it is best to avoid using this identifier in applications, unless + * the desired functionality cannot be performed via the packet table ID. + */ +hid_t +PacketTable::GetDataset() +{ + return H5PTget_dataset(table_id); +} + +/* FreeBuff + * Frees the buffers created when variable-length packets are read. + * Takes the number of hvl_t structs to be freed and a pointer to their + * location in memory. + * Returns 0 on success, negative on error. + */ +int +PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer) +{ + return H5PTfree_vlen_buff(table_id, numStructs, buffer); +} + +/********************************/ +/* Fixed-Length Packet Table */ +/********************************/ + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize, + hid_t plistID) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor - deprecated + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the ID of + * the property list to specify compression, the name of the packet table, + * the ID of the datatype, and the size of a memory chunk used in chunking. + * Note: The above constructor has a better prototype, which allows default + * values to be used. This constructor was only released in 1.10.0. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plistID, const char *name, hid_t dtypeID, + hsize_t chunkSize) +{ + table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plistID); +} + +/* Constructor + * Creates a packet table to store either fixed- or variable-length packets. + * Takes the ID of the file the packet table will be created in, the name of + * the packet table, the ID of the datatype of the set, and the size + * of a memory chunk used in chunking. + * Note: this overload will be deprecated in favor of the constructor above. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression) +{ + table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression); +} + +/* "Open" Constructor + * Opens an existing fixed-length packet table. + * Fails if the packet table specified is variable-length. + */ +FL_PacketTable::FL_PacketTable(hid_t fileID, const char *name) : PacketTable(fileID, name) {} + +/* "Open" Constructor - will be deprecated because of char* name */ +FL_PacketTable::FL_PacketTable(hid_t fileID, char *name) : PacketTable(fileID, name) {} + +/* AppendPacket + * Adds a single packet to the packet table. Takes a pointer + * to the location of the data in memory. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::AppendPacket(void *data) +{ + return H5PTappend(table_id, 1, data); +} + +/* AppendPackets (multiple packets) + * Adds multiple packets to the packet table. Takes the number of packets + * to be added and a pointer to their location in memory. + * Returns 0 on success, -1 on failure. + */ +int +FL_PacketTable::AppendPackets(size_t numPackets, void *data) +{ + return H5PTappend(table_id, numPackets, data); +} + +/* GetPacket (indexed) + * Gets a single packet from the packet table. Takes the index + * of the packet (with 0 being the first packet) and a pointer + * to memory where the data should be stored. + * Returns 0 on success, negative on failure + */ +int +FL_PacketTable::GetPacket(hsize_t index, void *data) +{ + return H5PTread_packets(table_id, index, 1, data); +} + +/* GetPackets (multiple packets) + * Gets multiple packets at once, all packets between + * startIndex and endIndex inclusive. Also takes a pointer to + * the memory where these packets should be stored. + * Returns 0 on success, negative on failure. + */ +int +FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void *data) +{ + // Make sure the range of indexes is valid + if (startIndex > endIndex) + return -1; + + return H5PTread_packets(table_id, startIndex, (size_t)(endIndex - startIndex + 1), data); +} + +/* GetNextPacket (single packet) + * Gets the next packet in the packet table. Takes a pointer to + * memory where the packet should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced to the next packet on failure. + */ +int +FL_PacketTable::GetNextPacket(void *data) +{ + return H5PTget_next(table_id, 1, data); +} + +/* GetNextPackets (multiple packets) + * Gets the next numPackets packets in the packet table. Takes a + * pointer to memory where these packets should be stored. + * Returns 0 on success, negative on failure. Index + * is not advanced on failure. + */ +int +FL_PacketTable::GetNextPackets(size_t numPackets, void *data) +{ + return H5PTget_next(table_id, numPackets, data); +} /* Removed "ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h index 2665984..400ea52 100644 --- a/hl/c++/src/H5PacketTable.h +++ b/hl/c++/src/H5PacketTable.h @@ -28,22 +28,21 @@ #include "H5PTpublic.h" #include "H5api_adpt.h" -class H5_HLCPPDLL PacketTable -{ -public: +class H5_HLCPPDLL PacketTable { + public: /* Null constructor * Sets table_id to "invalid" */ - PacketTable() {table_id = H5I_BADID;} + PacketTable() { table_id = H5I_BADID; } /* "Open" Constructor * Opens an existing packet table, which can contain either fixed-length or * variable-length packets. */ - PacketTable(hid_t fileID, const char* name); + PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - PacketTable(hid_t fileID, char* name); + PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table @@ -80,16 +79,17 @@ public: * Returns the position of the current packet. * On failure, returns 0 and error is set to negative. */ - hsize_t GetIndex(int& error); + hsize_t GetIndex(int &error); /* GetPacketCount * Returns the number of packets in the packet table. Error * is set to 0 on success. On failure, returns 0 and * error is set to negative. */ - hsize_t GetPacketCount(int& error); + hsize_t GetPacketCount(int &error); - hsize_t GetPacketCount() + hsize_t + GetPacketCount() { int ignoreError; return GetPacketCount(ignoreError); @@ -122,22 +122,22 @@ public: * location in memory. * Returns 0 on success, negative on error. */ - int FreeBuff(size_t numStructs, hvl_t * buffer); + int FreeBuff(size_t numStructs, hvl_t *buffer); -protected: + protected: hid_t table_id; }; -class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable -{ -public: +class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable { + public: /* Constructor * Creates a packet table to store either fixed- or variable-length packets. * Takes the ID of the file the packet table will be created in, the ID of * the property list to specify compression, the name of the packet table, * the ID of the datatype, and the size of a memory chunk used in chunking. */ - FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize = 0, hid_t plistID = H5P_DEFAULT); + FL_PacketTable(hid_t fileID, const char *name, hid_t dtypeID, hsize_t chunkSize = 0, + hid_t plistID = H5P_DEFAULT); /* Constructors - deprecated * Creates a packet table in which to store fixed length packets. @@ -148,36 +148,36 @@ public: * Note: these overloaded constructors will be deprecated in favor of the * constructor above. */ - FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize); - FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); + FL_PacketTable(hid_t fileID, hid_t plist_id, const char *name, hid_t dtypeID, hsize_t chunkSize); + FL_PacketTable(hid_t fileID, char *name, hid_t dtypeID, hsize_t chunkSize, int compression = 0); /* "Open" Constructor * Opens an existing fixed-length packet table. * Fails if the packet table specified is variable-length. */ - FL_PacketTable(hid_t fileID, const char* name); + FL_PacketTable(hid_t fileID, const char *name); /* "Open" Constructor - will be deprecated because of char* name */ - FL_PacketTable(hid_t fileID, char* name); + FL_PacketTable(hid_t fileID, char *name); /* Destructor * Cleans up the packet table */ - virtual ~FL_PacketTable() {}; + virtual ~FL_PacketTable(){}; /* AppendPacket * Adds a single packet to the packet table. Takes a pointer * to the location of the data in memory. * Returns 0 on success, negative on failure */ - int AppendPacket(void * data); + int AppendPacket(void *data); /* AppendPackets (multiple packets) * Adds multiple packets to the packet table. Takes the number of packets * to be added and a pointer to their location in memory. * Returns 0 on success, -1 on failure. */ - int AppendPackets(size_t numPackets, void * data); + int AppendPackets(size_t numPackets, void *data); /* GetPacket (indexed) * Gets a single packet from the packet table. Takes the index @@ -185,7 +185,7 @@ public: * to memory where the data should be stored. * Returns 0 on success, negative on failure */ - int GetPacket(hsize_t index, void * data); + int GetPacket(hsize_t index, void *data); /* GetPackets (multiple packets) * Gets multiple packets at once, all packets between @@ -193,7 +193,7 @@ public: * the memory where these packets should be stored. * Returns 0 on success, negative on failure. */ - int GetPackets(hsize_t startIndex, hsize_t endIndex, void * data); + int GetPackets(hsize_t startIndex, hsize_t endIndex, void *data); /* GetNextPacket (single packet) * Gets the next packet in the packet table. Takes a pointer to @@ -201,7 +201,7 @@ public: * Returns 0 on success, negative on failure. Index * is not advanced to the next packet on failure. */ - int GetNextPacket(void * data); + int GetNextPacket(void *data); /* GetNextPackets (multiple packets) * Gets the next numPackets packets in the packet table. Takes a @@ -209,7 +209,7 @@ public: * Returns 0 on success, negative on failure. Index * is not advanced on failure. */ - int GetNextPackets(size_t numPackets, void * data); + int GetNextPackets(size_t numPackets, void *data); }; /* Removed "#ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */ |