foobar2000 SDK  2015-08-03
guid.h
Go to the documentation of this file.
1 #ifndef _PFC_GUID_H_
2 #define _PFC_GUID_H_
3 
4 namespace pfc {
5 
6  GUID GUID_from_text(const char * text);
7 
8  class print_guid
9  {
10  public:
11  print_guid(const GUID & p_guid);
12  inline operator const char * () const {return m_data;}
13  inline const char * get_ptr() {return m_data;}
14  private:
15  char m_data[64];
16  };
17 
18  inline int guid_compare(const GUID & g1,const GUID & g2) {return memcmp(&g1,&g2,sizeof(GUID));}
19 
20  inline bool guid_equal(const GUID & g1,const GUID & g2) {return (g1 == g2) ? true : false;}
21  template<> inline int compare_t<GUID,GUID>(const GUID & p_item1,const GUID & p_item2) {return guid_compare(p_item1,p_item2);}
22 
23  extern const GUID guid_null;
24 
25  void print_hex_raw(const void * buffer,unsigned bytes,char * p_out);
26 
27  inline GUID makeGUID(t_uint32 Data1, t_uint16 Data2, t_uint16 Data3, t_uint8 Data4_1, t_uint8 Data4_2, t_uint8 Data4_3, t_uint8 Data4_4, t_uint8 Data4_5, t_uint8 Data4_6, t_uint8 Data4_7, t_uint8 Data4_8) {
28  GUID guid = { Data1, Data2, Data3, {Data4_1, Data4_2, Data4_3, Data4_4, Data4_5, Data4_6, Data4_7, Data4_8 } };
29  return guid;
30  }
31  inline GUID xorGUID(const GUID & v1, const GUID & v2) {
32  GUID temp; memxor(&temp, &v1, &v2, sizeof(GUID)); return temp;
33  }
34 
36  public:
37  format_guid_cpp(const GUID & guid) {
38  *this << "{0x" << pfc::format_hex(guid.Data1,8) << ", 0x" << pfc::format_hex(guid.Data2, 4) << ", 0x" << pfc::format_hex(guid.Data3,4) << ", {0x" << pfc::format_hex(guid.Data4[0],2);
39  for(int n = 1; n < 8; ++n) {
40  *this << ", 0x" << pfc::format_hex(guid.Data4[n],2);
41  }
42  *this << "}}";
43  }
44  };
45 
46  GUID createGUID();
47 }
48 
49 
50 #endif
uint8_t t_uint8
Definition: int_types.h:9
GUID createGUID()
Definition: guid.cpp:161
Definition: pfc.h:71
const char * get_ptr()
Definition: guid.h:13
uint8_t Data4[8]
Definition: pfc.h:75
uint16_t Data3
Definition: pfc.h:74
GUID makeGUID(t_uint32 Data1, t_uint16 Data2, t_uint16 Data3, t_uint8 Data4_1, t_uint8 Data4_2, t_uint8 Data4_3, t_uint8 Data4_4, t_uint8 Data4_5, t_uint8 Data4_6, t_uint8 Data4_7, t_uint8 Data4_8)
Definition: guid.h:27
GUID GUID_from_text(const char *text)
Definition: guid.cpp:106
GUID xorGUID(const GUID &v1, const GUID &v2)
Definition: guid.h:31
print_guid(const GUID &p_guid)
Definition: guid.cpp:130
int guid_compare(const GUID &g1, const GUID &g2)
Definition: guid.h:18
static void memxor(void *target, const void *source1, const void *source2, t_size size)
Definition: primitives.h:658
char m_data[64]
Definition: guid.h:15
string8_fastalloc string_formatter
Definition: string_base.h:615
uint16_t t_uint16
Definition: int_types.h:7
bool guid_equal(const GUID &g1, const GUID &g2)
Definition: guid.h:20
int compare_t< GUID, GUID >(const GUID &p_item1, const GUID &p_item2)
Definition: guid.h:21
void print_hex_raw(const void *buffer, unsigned bytes, char *p_out)
Definition: guid.cpp:152
uint16_t Data2
Definition: pfc.h:73
const GUID guid_null
Definition: guid.cpp:175
uint32_t Data1
Definition: pfc.h:72
uint32_t t_uint32
Definition: int_types.h:5
format_guid_cpp(const GUID &guid)
Definition: guid.h:37