Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb_id.h
1 // ================================================================================
2 // == This file is a part of Turbo Badger. (C) 2011-2014, Emil SegerÃ¥s ==
3 // == See tb_core.h for more information. ==
4 // ================================================================================
5 
6 #ifndef TB_ID_H
7 #define TB_ID_H
8 
9 #include "tb_types.h"
10 #include "tb_hash.h"
11 #include "tb_str.h"
12 
13 namespace tb {
14 
18 class TBID
19 {
20 public:
21  TBID(uint32_t id_ = 0) { Set(id_); }
22  TBID(const char *string) { Set(string); }
23  TBID(const TBID &id_) { Set(id_); }
24  TBID(const TBStr &id_) { Set((const char *)id_); }
25 
26 #ifdef TB_RUNTIME_DEBUG_INFO
27  void Set(uint32_t newid);
28  void Set(const char *string);
29  void Set(const TBID &newid);
30  void Set(const TBStr &str) { Set((const char *)str); }
31 #else
32  void Set(uint32_t newid) { id = newid; }
33  void Set(const char *string) { id = TBGetHash(string); }
34  void Set(const TBID &newid) { id = newid; }
35  void Set(const TBStr &str) { id = TBGetHash((const char *)str); }
36 #endif
37 
38  operator uint32_t () const { return id; }
39  const TBID& operator = (const TBID &id) { Set(id); return *this; }
40 private:
41  uint32_t id;
42 public:
45 #ifdef TB_RUNTIME_DEBUG_INFO
46  friend class TBLanguage;
47  const char * c_str() const;
48  mutable TBStr debug_string;
49 #endif
50 };
51 
52 } // namespace tb
53 
54 #endif // TB_ID_H
TBID is a wrapper for a uint32_t to be used as ID.
Definition: tb_id.h:18
TBStr is a simple string class.
Definition: tb_str.h:62
TBLanguage is a basic language string manager.
Definition: tb_language.h:27