-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_container.h
More file actions
45 lines (30 loc) · 1000 Bytes
/
string_container.h
File metadata and controls
45 lines (30 loc) · 1000 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
35
36
37
38
39
40
41
42
43
44
45
#ifndef WEBASSEMBLY_STRING_CONTAINER_H
#define WEBASSEMBLY_STRING_CONTAINER_H
#include <stddef.h>
#include <string>
class StringContainer
{
public:
// Initializes data_, size_ and offset_ with some default values.
StringContainer();
// Assigns a value to the testString_.
void loadData();
// Serializes testString_ into data_ using memcpy operation.
char* serialize();
// Deserializes testString_ from data_ using memcpy operation.
void deserialize(char* data, int size);
// Getter for size_.
int getSerializedSize() const;
// Getter for testString_.
const std::string& getString() const;
private:
// Variable, which stores serialized data.
char* data_;
// Serialized data size.
size_t size_;
// Variable to store current data offset during serialization and deserialization.
size_t offset_;
// String being serialized and deserialized.
std::string testString_;
};
#endif //WEBASSEMBLY_STRING_CONTAINER_H