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

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

OSCL API
Posting Version: OPENCORE_20090310