-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce namespaces: cista::offset and cista::raw
namespaced deserialize functions, unchecked_deserialize
- Loading branch information
1 parent
c829cd0
commit 8ef0536
Showing
18 changed files
with
419 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include "cista/containers/string.h" | ||
#include "cista/containers/unique_ptr.h" | ||
#include "cista/containers/vector.h" | ||
|
||
// Helper macro to prevent copy&paste. | ||
#define CISTA_DEFINITIONS \ | ||
template <typename T> \ | ||
using unique_ptr = cista::basic_unique_ptr<T, ptr<T>>; \ | ||
\ | ||
template <typename T> \ | ||
using vector = cista::basic_vector<T, ptr<T>>; \ | ||
\ | ||
using string = cista::basic_string<ptr<char const>>; \ | ||
\ | ||
template <typename T, typename... Args> \ | ||
unique_ptr<T> make_unique(Args&&... args) { \ | ||
return unique_ptr<T>{new T{std::forward<Args>(args)...}, true}; \ | ||
} | ||
|
||
namespace cista { | ||
|
||
// ============================================================================= | ||
// Offset based data structures: | ||
// [+] can be read without any deserialization step | ||
// [+] suitable for shared memory applications | ||
// [-] slower at runtime (pointers needs to be resolved using on more add) | ||
// ----------------------------------------------------------------------------- | ||
namespace offset { | ||
|
||
template <typename T> | ||
using ptr = cista::offset_ptr<T>; | ||
|
||
CISTA_DEFINITIONS | ||
} // namespace offset | ||
|
||
// ============================================================================= | ||
// Raw data structures: | ||
// [-] deserialize step takes time (but still very fast also for GBs of data) | ||
// [-] the buffer containing the serialized data needs to be modified | ||
// [+] fast runtime access (raw access) | ||
// ----------------------------------------------------------------------------- | ||
namespace raw { | ||
|
||
template <typename T> | ||
using ptr = T*; | ||
|
||
CISTA_DEFINITIONS | ||
} // namespace raw | ||
|
||
} // namespace cista |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.