libIntegra
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
guid_helper.h
Go to the documentation of this file.
1 /* libIntegra modular audio framework
2  *
3  * Copyright (C) 2007 Birmingham City University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18  * USA.
19  */
20 
25 #ifndef INTEGRA_GUID_HELPER_H
26 #define INTEGRA_GUID_HELPER_H
27 
28 
29 #include <stdio.h>
30 
31 #include "common_typedefs.h"
32 #include "error.h"
33 
34 
35 namespace integra_api
36 {
45  class INTEGRA_API CGuidHelper
46  {
47  public:
48 
53  static size_t guid_to_hash( const GUID &guid );
54 
59  static string guid_to_string( const GUID &guid );
60 
66  static CError string_to_guid( const string &string, GUID &output );
67 
73  static bool guids_are_equal( const GUID &guid1, const GUID &guid2 );
74 
79  static bool guid_is_null( const GUID &guid );
80 
84  static const GUID null_guid;
85 
86  private:
87 
88  static unsigned long read_hex_chars( const string &input, unsigned int number_of_bytes, CError &error );
89  static CError read_hex_char( char input, unsigned char &output );
90  };
91 
92 
94  struct GuidHash
95  {
96  size_t operator()( const GUID &guid ) const { return CGuidHelper::guid_to_hash( guid ); }
97  };
98 
100  struct GuidCompare
101  {
102  bool operator()( const GUID &guid1, const GUID &guid2 ) const { return CGuidHelper::guids_are_equal( guid1, guid2 ); }
103  };
104 
106  typedef std::unordered_set<GUID, GuidHash, GuidCompare> guid_set;
107 
109  typedef std::vector<GUID> guid_array;
110 }
111 
112 
113 
114 
115 
116 #endif
static const GUID null_guid
Null guid. Assign guids to this value to mark them as null.
Definition: guid_helper.h:84
static bool guids_are_equal(const GUID &guid1, const GUID &guid2)
Compare guids.
Defines class CError.
Definition: common_typedefs.h:45
Defines a comparison operator so that guids can be keys of standard library maps and sets...
Definition: guid_helper.h:100
Represents an enumeration of error codes.
Definition: error.h:40
static size_t guid_to_hash(const GUID &guid)
Guid hash function.
Common guid routines.
Definition: guid_helper.h:45
Defines a hash operator so that guids can be keys of standard library maps and sets. Internal use only.
Definition: guid_helper.h:94
#defines and typedefs used throughout the application