forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTWString.cpp
More file actions
34 lines (27 loc) · 1006 Bytes
/
TWString.cpp
File metadata and controls
34 lines (27 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright © 2017-2020 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#include <TrustWalletCore/TWString.h>
#include <string>
TWString *_Nonnull TWStringCreateWithUTF8Bytes(const char *_Nonnull bytes) {
auto s = new std::string(bytes);
return s;
}
size_t TWStringSize(TWString *_Nonnull string) {
auto s = reinterpret_cast<const std::string*>(string);
return s->size();
}
char TWStringGet(TWString *_Nonnull string, size_t index) {
auto s = reinterpret_cast<const std::string*>(string);
return (*s)[index];
}
const char *_Nonnull TWStringUTF8Bytes(TWString *_Nonnull string) {
auto s = reinterpret_cast<const std::string*>(string);
return s->data();
}
void TWStringDelete(TWString *_Nonnull string) {
auto s = reinterpret_cast<const std::string*>(string);
delete s;
}