Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# oscl_uuid.h

Go to the documentation of this file.

    00001
    00007 #ifndef OSCL_UUID_H_INCLUDED
    00008 #define OSCL_UUID_H_INCLUDED
    00009
    00010 #ifndef OSCL_BASE_H_INCLUDED
    00011 #include "oscl_base.h"
    00012 #endif
    00013
    00014 #ifndef OSCL_MEM_BASIC_FUNCTIONS_H
    00015 #include "oscl_mem_basic_functions.h"
    00016 #endif
    00017
    00018 #ifndef OSCL_STRING_UTILS_H
    00019 #include "oscl_string_utils.h"
    00020 #endif
    00021
    00022 #ifndef OSCL_STDSTRING_H_INCLUDED
    00023 #include "oscl_stdstring.h"
    00024 #endif
    00025 // __cplusplus
    00026
    00027 #define EMPTY_UUID PVUuid(0,0,0,0,0,0,0,0,0,0,0)
    00028
    00029 typedef uint32 OsclUid32;
    00030 const char PV_CHAR_CLOSE_BRACKET = ')';
    00031 const char PV_CHAR_COMMA = ',';
    00035 struct OsclUuid
    00036 {
    00037 #define BYTES_IN_UUID_ARRAY 8
    00038
    00039     OsclUuid()
    00040     {
    00041         oscl_memset(this, 0, sizeof(OsclUuid));
    00042     }
    00043
    00044     OsclUuid(uint32 l, uint16 w1, uint16 w2, uint8 b1, uint8 b2, uint8 b3,
    00045              uint8 b4, uint8 b5, uint8 b6, uint8 b7, uint8 b8)
    00046     {
    00047         data1 = l;
    00048         data2 = w1;
    00049         data3 = w2;
    00050         data4[0] = b1;
    00051         data4[1] = b2;
    00052         data4[2] = b3;
    00053         data4[3] = b4;
    00054         data4[4] = b5;
    00055         data4[5] = b6;
    00056         data4[6] = b7;
    00057         data4[7] = b8;
    00058     }
    00059
    00060     //The OSCL UUID structure takes in a string parameter
    00061     //Expected string input for the OsclString should be like:
    00062     //(0xa054569c,0x24c5,0x452e,0x99,0x77,0x87,0x4b,0xca,0x79,0xd3,0xaf)
    00063
    00064     OsclUuid(const char* aUuidString)
    00065     {
    00066         //Initialize all data members to 0 to begin with
    00067         data1 = data2 = data3 = 0;
    00068
    00069         for (int ii = 0; ii < 8; ++ii)
    00070         {
    00071             data4[ii] = 0;
    00072         }
    00073
    00074         if (!aUuidString)
    00075         {
    00076             return;
    00077         }
    00078         int uuidStrLen = oscl_strlen(aUuidString);
    00079
    00080         if (uuidStrLen != 0)
    00081         {
    00082             const char* sptr = NULL, *eptr = NULL;
    00083             int commaval = 0;
    00084             sptr = aUuidString;
    00085             ++sptr; //Increment over the starting parantheses '('
    00086             eptr = sptr;
    00087             for (int i = 0; i < uuidStrLen - 1 ; ++i)
    00088             {
    00089                 if ((*eptr != PV_CHAR_COMMA) && (*eptr != PV_CHAR_CLOSE_BRACKET)) //Increment the pointer unless you get to the ","
    00090                 {                               //The comma signifies the beginning of the new OsclUuid parameter
    00091                     ++eptr;
    00092                 }
    00093                 else
    00094                 {
    00095                     sptr = sptr + 2;//Move over the 0x characters in the beginning of the hex value;
    00096                     ++commaval;
    00097                     switch (commaval)
    00098                     {
    00099                         case 1:
    00100                         {
    00101                             PV_atoi(sptr , 'x', eptr - sptr, data1);
    00102                             break;
    00103                         }
    00104                         case 2:
    00105                         {
    00106                             uint32 tempdata2 = 0;
    00107                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata2);
    00108                             data2 = (uint16)tempdata2;
    00109                             break;
    00110                         }
    00111                         case 3:
    00112                         {
    00113                             uint32 tempdata3 = 0;
    00114                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata3);
    00115                             data3 = (uint16)tempdata3;
    00116                             break;
    00117                         }
    00118                         case 4:
    00119                         {
    00120                             uint32 tempdata4_0 = 0;
    00121                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_0);
    00122                             data4[0] = (uint8)tempdata4_0;
    00123                             break;
    00124                         }
    00125                         case 5:
    00126                         {
    00127                             uint32 tempdata4_1 = 0;
    00128                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_1);
    00129                             data4[1] = (uint8)tempdata4_1;
    00130                             break;
    00131                         }
    00132                         case 6:
    00133                         {
    00134                             uint32 tempdata4_2 = 0;
    00135                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_2);
    00136                             data4[2] = (uint8)tempdata4_2;
    00137                             break;
    00138                         }
    00139                         case 7:
    00140                         {
    00141                             uint32 tempdata4_3 = 0;
    00142                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_3);
    00143                             data4[3] = (uint8)tempdata4_3;
    00144                             break;
    00145                         }
    00146                         case 8:
    00147                         {
    00148                             uint32 tempdata4_4 = 0;
    00149                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_4);
    00150                             data4[4] = (uint8)tempdata4_4;
    00151                             break;
    00152                         }
    00153                         case 9:
    00154                         {
    00155                             uint32 tempdata4_5 = 0;
    00156                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_5);
    00157                             data4[5] = (uint8)tempdata4_5;
    00158                             break;
    00159                         }
    00160                         case 10:
    00161                         {
    00162                             uint32 tempdata4_6 = 0;
    00163                             PV_atoi(sptr , 'x', (eptr - sptr), tempdata4_6);
    00164                             data4[6] = (uint8)tempdata4_6;
    00165                             break;
    00166                         }
    00167                         case 11:
    00168                         {
    00169                             uint32 tempdata4_7 = 0;
    00170                             PV_atoi(sptr, 'x', (eptr - sptr), tempdata4_7);
    00171                             data4[7] = (uint8)tempdata4_7;
    00172                             break;
    00173                         }
    00174                     }
    00175                     if (*eptr == PV_CHAR_CLOSE_BRACKET) //Break from the loop on finding
    00176                     {
    00177                         break;
    00178                     }
    00179                     ++eptr;
    00180                     sptr = eptr;
    00181                 }
    00182             }
    00183         }
    00184     }
    00185
    00186     OsclUuid(const OsclUuid &uuid)
    00187     {
    00188         oscl_memcpy(this, &uuid, sizeof(OsclUuid));
    00189     }
    00190
    00191     OsclUuid &operator=(const OsclUuid& src)
    00192     {
    00193         oscl_memcpy(this, &src, sizeof(OsclUuid));
    00194         return *this;
    00195     }
    00196
    00197     bool operator==(const OsclUuid& src) const
    00198     {
    00199         if (data1 != src.data1 || data2 != src.data2 || data3 != src.data3)
    00200         {
    00201             return false;
    00202         }
    00203
    00204         for (int ii = 0; ii < 8; ++ii)
    00205         {
    00206             if (data4[ii] != src.data4[ii])
    00207             {
    00208                 return false;
    00209             }
    00210         }
    00211
    00212         return true;
    00213     }
    00214
    00215     bool operator!=(const OsclUuid &src) const
    00216     {
    00217         return !(*this == src);
    00218     }
    00219
    00220     uint32  data1;
    00221     uint16  data2;
    00222     uint16  data3;
    00223     uint8   data4[BYTES_IN_UUID_ARRAY];
    00224 };
    00225
    00226 #endif
    00227