]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/BamAux.h
Cleaned up intra-API includes & moved version numbers to 2.0.0
[bamtools.git] / src / api / BamAux.h
index 610b3fccd8ed019343097c51de00f47f2507134a..f4511259ea67136934e736a3cebf0846353d65ed 100644 (file)
@@ -2,7 +2,7 @@
 // BamAux.h (c) 2009 Derek Barnett, Michael Str�mberg\r
 // Marth Lab, Department of Biology, Boston College\r
 // ---------------------------------------------------------------------------\r
-// Last modified: 8 October 2011 (DB)\r
+// Last modified: 10 October 2011 (DB)\r
 // ---------------------------------------------------------------------------\r
 // Provides data structures & utility methods that are used throughout the API.\r
 // ***************************************************************************\r
@@ -10,7 +10,7 @@
 #ifndef BAMAUX_H\r
 #define BAMAUX_H\r
 \r
-#include <api/api_global.h>\r
+#include "api/api_global.h"\r
 #include <fstream> \r
 #include <iostream>\r
 #include <string>\r
@@ -20,6 +20,7 @@
 \r
     Provides data structures & utility methods that are used throughout the API.\r
 */\r
+\r
 /*! \namespace BamTools\r
     \brief Contains all BamTools classes & methods.\r
 \r
@@ -34,11 +35,11 @@ namespace BamTools {
 /*! \struct BamTools::CigarOp\r
     \brief Represents a CIGAR alignment operation.\r
 \r
-    \sa http://samtools.sourceforge.net/SAM-1.3.pdf for more details on using CIGAR operations.\r
+    \sa \samSpecURL for more details on using CIGAR operations.\r
 */\r
 struct API_EXPORT CigarOp {\r
   \r
-    char     Type;   //!< CIGAR operation type (MIDNSHP)\r
+    char     Type;   //!< CIGAR operation type (MIDNSHPX=)\r
     uint32_t Length; //!< CIGAR operation length (number of bases)\r
     \r
     //! constructor\r
@@ -81,10 +82,7 @@ typedef std::vector<RefData> RefVector;
 \r
     \warning BamRegion now represents a zero-based, HALF-OPEN interval.\r
     In previous versions of BamTools (0.x & 1.x) all intervals were treated\r
-    as zero-based, CLOSED. I whole-heartedly apologize for any inconsistencies this\r
-    may have caused if you assumed that BT was always half-open; full aplogies also\r
-    to those who recognized that BamTools originally used a closed interval, but may\r
-    need to update their code to reflect this new change.\r
+    as zero-based, CLOSED.\r
 */\r
 struct API_EXPORT BamRegion {\r
   \r
@@ -138,11 +136,7 @@ struct API_EXPORT BamRegion {
 // General utility methods\r
 \r
 /*! \fn bool FileExists(const std::string& filename)\r
-    \brief checks if file exists\r
-\r
-    Attempts to open file in a read-only mode.\r
-\r
-    \return \c true if file can be opened successfully\r
+    \brief returns true if the file exists\r
 */\r
 API_EXPORT inline bool FileExists(const std::string& filename) {\r
     std::ifstream f(filename.c_str(), std::ifstream::in);\r
@@ -151,8 +145,6 @@ API_EXPORT inline bool FileExists(const std::string& filename) {
 \r
 /*! \fn void SwapEndian_16(int16_t& x)\r
     \brief swaps endianness of signed 16-bit integer, in place\r
-\r
-    Swaps endian representation of value in \a x.\r
 */\r
 API_EXPORT inline void SwapEndian_16(int16_t& x) {\r
     x = ((x >> 8) | (x << 8));\r
@@ -160,8 +152,6 @@ API_EXPORT inline void SwapEndian_16(int16_t& x) {
 \r
 /*! \fn void SwapEndian_16(uint16_t& x)\r
     \brief swaps endianness of unsigned 16-bit integer, in place\r
-\r
-    Swaps endian representation of value in \a x.\r
 */\r
 API_EXPORT inline void SwapEndian_16(uint16_t& x) {\r
     x = ((x >> 8) | (x << 8));\r
@@ -169,8 +159,6 @@ API_EXPORT inline void SwapEndian_16(uint16_t& x) {
 \r
 /*! \fn void SwapEndian_32(int32_t& x)\r
     \brief swaps endianness of signed 32-bit integer, in place\r
-\r
-    Swaps endian representation of value in \a x.\r
 */\r
 API_EXPORT inline void SwapEndian_32(int32_t& x) {\r
     x = ( (x >> 24) | \r
@@ -182,8 +170,6 @@ API_EXPORT inline void SwapEndian_32(int32_t& x) {
 \r
 /*! \fn void SwapEndian_32(uint32_t& x)\r
     \brief swaps endianness of unsigned 32-bit integer, in place\r
-\r
-    Swaps endian representation of value in \a x.\r
 */\r
 API_EXPORT inline void SwapEndian_32(uint32_t& x) {\r
     x = ( (x >> 24) | \r
@@ -195,8 +181,6 @@ API_EXPORT inline void SwapEndian_32(uint32_t& x) {
 \r
 /*! \fn void SwapEndian_64(int64_t& x)\r
     \brief swaps endianness of signed 64-bit integer, in place\r
-\r
-    Swaps endian representation of value in \a x.\r
 */\r
 API_EXPORT inline void SwapEndian_64(int64_t& x) {\r
     x = ( (x >> 56) | \r
@@ -212,8 +196,6 @@ API_EXPORT inline void SwapEndian_64(int64_t& x) {
 \r
 /*! \fn void SwapEndian_64(uint64_t& x)\r
     \brief swaps endianness of unsigned 64-bit integer, in place\r
-\r
-    Swaps endian representation of value in \a x.\r
 */\r
 API_EXPORT inline void SwapEndian_64(uint64_t& x) {\r
     x = ( (x >> 56) | \r
@@ -229,8 +211,6 @@ API_EXPORT inline void SwapEndian_64(uint64_t& x) {
 \r
 /*! \fn void SwapEndian_16p(char* data)\r
     \brief swaps endianness of the next 2 bytes in a buffer, in place\r
-\r
-    Swaps endian representation the next 2 bytes in \a data.\r
 */\r
 API_EXPORT inline void SwapEndian_16p(char* data) {\r
     uint16_t& value = (uint16_t&)*data; \r
@@ -239,8 +219,6 @@ API_EXPORT inline void SwapEndian_16p(char* data) {
 \r
 /*! \fn void SwapEndian_32p(char* data)\r
     \brief swaps endianness of the next 4 bytes in a buffer, in place\r
-\r
-    Swaps endian representation the next 4 bytes in \a data.\r
 */\r
 API_EXPORT inline void SwapEndian_32p(char* data) {\r
     uint32_t& value = (uint32_t&)*data; \r
@@ -249,8 +227,6 @@ API_EXPORT inline void SwapEndian_32p(char* data) {
 \r
 /*! \fn void SwapEndian_64p(char* data)\r
     \brief swaps endianness of the next 8 bytes in a buffer, in place\r
-\r
-    Swaps endian representation the next 8 bytes in \a data.\r
 */\r
 API_EXPORT inline void SwapEndian_64p(char* data) {\r
     uint64_t& value = (uint64_t&)*data; \r
@@ -269,8 +245,8 @@ API_EXPORT inline bool SystemIsBigEndian(void) {
 /*! \fn void PackUnsignedInt(char* buffer, unsigned int value)\r
     \brief stores unsigned integer value in a byte buffer\r
 \r
-    \param buffer destination buffer\r
-    \param value  unsigned integer to 'pack' in buffer\r
+    \param[out] buffer destination buffer\r
+    \param[in]  value  value to 'pack' in buffer\r
 */\r
 API_EXPORT inline void PackUnsignedInt(char* buffer, unsigned int value) {\r
     buffer[0] = (char)value;\r
@@ -282,8 +258,8 @@ API_EXPORT inline void PackUnsignedInt(char* buffer, unsigned int value) {
 /*! \fn void PackUnsignedShort(char* buffer, unsigned short value)\r
     \brief stores unsigned short integer value in a byte buffer\r
 \r
-    \param buffer destination buffer\r
-    \param value  unsigned short integer to 'pack' in buffer\r
+    \param[out] buffer destination buffer\r
+    \param[in]  value  value to 'pack' in buffer\r
 */\r
 API_EXPORT inline void PackUnsignedShort(char* buffer, unsigned short value) {\r
     buffer[0] = (char)value;\r
@@ -293,7 +269,7 @@ API_EXPORT inline void PackUnsignedShort(char* buffer, unsigned short value) {
 /*! \fn double UnpackDouble(const char* buffer)\r
     \brief reads a double value from byte buffer\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (double) value read from the buffer\r
 */\r
 API_EXPORT inline double UnpackDouble(const char* buffer) {\r
@@ -315,7 +291,7 @@ API_EXPORT inline double UnpackDouble(const char* buffer) {
 \r
     This is an overloaded function.\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (double) value read from the buffer\r
 */\r
 API_EXPORT inline double UnpackDouble(char* buffer) {\r
@@ -325,7 +301,7 @@ API_EXPORT inline double UnpackDouble(char* buffer) {
 /*! \fn double UnpackFloat(const char* buffer)\r
     \brief reads a float value from byte buffer\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (float) value read from the buffer\r
 */\r
 API_EXPORT inline float UnpackFloat(const char* buffer) {\r
@@ -343,7 +319,7 @@ API_EXPORT inline float UnpackFloat(const char* buffer) {
 \r
     This is an overloaded function.\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (float) value read from the buffer\r
 */\r
 API_EXPORT inline float UnpackFloat(char* buffer) {\r
@@ -353,7 +329,7 @@ API_EXPORT inline float UnpackFloat(char* buffer) {
 /*! \fn signed int UnpackSignedInt(const char* buffer)\r
     \brief reads a signed integer value from byte buffer\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (signed int) value read from the buffer\r
 */\r
 API_EXPORT inline signed int UnpackSignedInt(const char* buffer) {\r
@@ -371,7 +347,7 @@ API_EXPORT inline signed int UnpackSignedInt(const char* buffer) {
 \r
     This is an overloaded function.\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (signed int) value read from the buffer\r
 */\r
 API_EXPORT inline signed int UnpackSignedInt(char* buffer) {\r
@@ -381,7 +357,7 @@ API_EXPORT inline signed int UnpackSignedInt(char* buffer) {
 /*! \fn signed short UnpackSignedShort(const char* buffer)\r
     \brief reads a signed short integer value from byte buffer\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (signed short) value read from the buffer\r
 */\r
 API_EXPORT inline signed short UnpackSignedShort(const char* buffer) {\r
@@ -397,7 +373,7 @@ API_EXPORT inline signed short UnpackSignedShort(const char* buffer) {
 \r
     This is an overloaded function.\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (signed short) value read from the buffer\r
 */\r
 API_EXPORT inline signed short UnpackSignedShort(char* buffer) {\r
@@ -407,7 +383,7 @@ API_EXPORT inline signed short UnpackSignedShort(char* buffer) {
 /*! \fn unsigned int UnpackUnsignedInt(const char* buffer)\r
     \brief reads an unsigned integer value from byte buffer\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (unsigned int) value read from the buffer\r
 */\r
 API_EXPORT inline unsigned int UnpackUnsignedInt(const char* buffer) {\r
@@ -425,7 +401,7 @@ API_EXPORT inline unsigned int UnpackUnsignedInt(const char* buffer) {
 \r
     This is an overloaded function.\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (unsigned int) value read from the buffer\r
 */\r
 API_EXPORT inline unsigned int UnpackUnsignedInt(char* buffer) {\r
@@ -435,7 +411,7 @@ API_EXPORT inline unsigned int UnpackUnsignedInt(char* buffer) {
 /*! \fn unsigned short UnpackUnsignedShort(const char* buffer)\r
     \brief reads an unsigned short integer value from byte buffer\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (unsigned short) value read from the buffer\r
 */\r
 API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) {\r
@@ -451,7 +427,7 @@ API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) {
 \r
     This is an overloaded function.\r
 \r
-    \param buffer source byte buffer\r
+    \param[in] buffer source byte buffer\r
     \return the (unsigned short) value read from the buffer\r
 */\r
 API_EXPORT inline unsigned short UnpackUnsignedShort(char* buffer) {\r
@@ -461,8 +437,11 @@ API_EXPORT inline unsigned short UnpackUnsignedShort(char* buffer) {
 // ----------------------------------------------------------------\r
 // 'internal' helper structs\r
 \r
+/*! \struct RaiiBuffer\r
+    \internal\r
+*/\r
 struct RaiiBuffer {\r
-    RaiiBuffer(const unsigned int n)\r
+    RaiiBuffer(const size_t n)\r
         : Buffer( new char[n]() )\r
     { }\r
     ~RaiiBuffer(void) {\r