summaryrefslogtreecommitdiff
path: root/src/pkstr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkstr.cpp')
-rw-r--r--src/pkstr.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pkstr.cpp b/src/pkstr.cpp
new file mode 100644
index 0000000..10e656c
--- /dev/null
+++ b/src/pkstr.cpp
@@ -0,0 +1,31 @@
+
+#include "pkstr.hpp"
+#include <cstring>
+
+pkstr to_pkstr(char *s) {
+ return pkstr {
+ .length = static_cast<int64_t>(strlen(s)),
+ .val = s,
+ };
+}
+
+pkstr to_pkstr(const cpkstr &s) {
+ return pkstr {
+ .length = s.length,
+ .val = const_cast<char *>(s.val),
+ };
+}
+
+cpkstr to_cpkstr(const char *s) {
+ return cpkstr {
+ .length = static_cast<int64_t>(strlen(s)),
+ .val = s,
+ };
+}
+
+cpkstr to_cpkstr(const pkstr &s) {
+ return cpkstr {
+ .length = s.length,
+ .val = s.val,
+ };
+}