File tree Expand file tree Collapse file tree 3 files changed +43
-28
lines changed
Expand file tree Collapse file tree 3 files changed +43
-28
lines changed Original file line number Diff line number Diff line change 88 class Uuid
99 {
1010 public:
11- Uuid ()
12- {
13- UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator;
14- this ->id = uuidGenerator.getUUID ();
15- }
16- Uuid (std::string id)
17- {
18- this ->id = UUIDv4::UUID (id);
19- }
20- std::string Get ()
21- {
22- return this ->id .str ();
23- }
11+ Uuid ();
12+ Uuid (std::string id);
13+ std::string Get ();
2414 private:
2515 UUIDv4::UUID id;
2616 };
3222 class Uuid
3323 {
3424 public:
35- Uuid ()
36- {
37- uuid_generate (this ->id );
38- }
39- Uuid (std::string id)
40- {
41- uuid_parse (id.c_str (), this ->id );
42- }
43- std::string Get ()
44- {
45- char str_id[37 ] = {0 };
46- uuid_unparse (this ->id , str_id);
47- return std::string (str_id);
48- }
25+ Uuid ();
26+ Uuid (std::string id);
27+ std::string Get ();
4928 private:
5029 uuid_t id;
5130 };
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ libecs_cpp_la_CXXFLAGS = -std=c++20 -I../include -Werror -Wall -Wno-psabi ${UUID
2121libecs_cpp_la_LIBADD = ${UUID_LIBS}
2222endif
2323
24- libecs_cpp_la_SOURCES = Manager.cpp Container.cpp System.cpp Component.cpp Entity.cpp
24+ libecs_cpp_la_SOURCES = Manager.cpp Container.cpp System.cpp Component.cpp Entity.cpp Uuid.cpp
2525libecs_cpp_la_LDFLAGS = -no-undefined -pthread
2626
2727bin_PROGRAMS = example
Original file line number Diff line number Diff line change 1+ #include < libecs-cpp/ecs.hpp>
2+
3+ #ifndef DISABLE_BUILTIN_UUID
4+ ecs::Uuid::Uuid ()
5+ {
6+ UUIDv4::UUIDGenerator<std::mt19937_64> uuidGenerator;
7+ this ->id = uuidGenerator.getUUID ();
8+ }
9+
10+ ecs::Uuid::Uuid (std::string id)
11+ {
12+ this ->id = UUIDv4::UUID (id);
13+ }
14+
15+ std::string ecs::Uuid::Get ()
16+ {
17+ return this ->id .str ();
18+ }
19+ #else
20+ ecs::Uuid::Uuid ()
21+ {
22+ uuid_generate (this ->id );
23+ }
24+
25+ ecs::Uuid::Uuid (std::string id)
26+ {
27+ uuid_parse (id.c_str (), this ->id );
28+ }
29+
30+ std::string ecs::Uuid::Get ()
31+ {
32+ char str_id[37 ] = {0 };
33+ uuid_unparse (this ->id , str_id); // 36 characters + 1 for null terminator
34+ return std::string (str_id);
35+ }
36+ #endif
You can’t perform that action at this time.
0 commit comments