sP2P c++ STL *nix API  1.2
NAT traversal and peer-to-peer networking API providing all utilities needed to build peer-to-peer application straigth out of box
 All Classes Functions Variables Typedefs Enumerations Enumerator
Guid.h
1 /*
2 #################################################################################################
3 # sP2P NAT Traversal/Peer-To-Peer networking API
4 #
5 # This file is part of comercial product. You can not use it in any way, redistribute it
6 # in any way and/or modify it in any way unless you get right to do so.
7 #
8 # Use licence can only be acquired from:
9 # ---------------------------------------------------
10 # AS-CAL,raziskave in razvoj, d.o.o.
11 # Kongresni trg 9, 1000 Ljubljana - Slovenia
12 # Company ID: 3913147000
13 # ---------------------------------------------------
14 # , or product legal successor.
15 #
16 #################################################################################################
17 # Ivan Milic
18 # HOLEST Engineering
19 # www.holest.com
20 # Belgrade, Serbia
21 # January, 2013
22 ##################################################################################################
23 */
24 
25 
26 
27 #ifndef _GUID_H
28 #define _GUID_H
29 
30 #include "Common.h"
31 #include <string>
32 
33 namespace sp2plib{
34 
36 class SP2P_API Guid{
37 public:
38 
40  Guid();
41 
44  Guid(const char* strValue);
45 
49  Guid(unsigned char* arrbytes,int startIndex);
50 
52  ~Guid();
53 
56  static Guid &Empty();
59  static Guid NewGuid();
60 
64  static Guid ParseGuid(const char* strValue);
65 
68  void Parse(const char* strValue);
69 
73  void ParseFromBytes(unsigned char* arrbytes,int startIndex = 0);
74 
76  ::std::string ToString();
77 
80  unsigned char* ToByteArray();
81 
85  void WriteToByteArray(unsigned char* bArray, int startIndex = 0);
86 
90  bool Equals(const Guid &other);
91 
95  Guid& operator=(const Guid &rhs);
96 
100  Guid& operator=(const sp2plib::UInt128 &rhs);
101 
105  bool operator==(const Guid &other) const;
106 
110  bool operator!=(const Guid &other) const;
111 
115  bool operator> (const Guid &other) const;
116 
120  bool operator<= (const Guid &other) const;
121 
125  bool operator< (const Guid &other) const;
126 
130  bool operator>= (const Guid &other) const;
131 
135  void regenerate();
136 
138  void set0();
139 
140 private:
141  static Guid _Empty;
142  unsigned char bytes[16];
143  Guid(unsigned char byte);
144  void randomSeq(unsigned char *arr);
145  static sp2plib::UInt32 _LOCAL_RAND_CORRECTION;
146 };
147 
148 }
149 
150 #endif