载入中...
搜索中...
未找到
DataModule.h
浏览该文件的文档.
1#pragma once
2
3#include "CompressedData.h"
4#include "Compressor.h"
5#include "HashFunction.h"
6#include "DataView.h"
7#include "ByteData.h"
8#include "JsonDocument.h"
9#include "XmlDocument.h"
10
11#include "common/Module.h"
12
13#include <string>
14
15namespace eve
16{
17namespace data
18{
19
26
38CompressedData *compress(std::string format, const char *rawbytes, size_t rawsize, int level = -1);
39
47char *decompress(CompressedData *data, size_t &decompressedsize);
48
60char *decompress(std::string format, const char *cbytes, size_t compressedsize, size_t &rawsize);
61
62char *encode(std::string format, const char *src, size_t srclen, size_t &dstlen, size_t linelen = 0);
63char *decode(std::string format, const char *src, size_t srclen, size_t &dstlen);
64
73std::string hash(std::string function, Data *input);
74std::string hash(std::string function, const char *input, uint64_t size);
75void hash(std::string function, Data *input, HashFunction::Value &output);
76void hash(std::string function, const char *input, uint64_t size, HashFunction::Value &output);
77
78
79
80class DataModule : public Module
81{
82public:
84 DataModule();
85 virtual ~DataModule();
86
87 DataView *newDataView(Data *data, size_t offset, size_t size);
88 ByteData *newByteData(size_t size);
89 ByteData *newByteData(const void *d, size_t size);
90 ByteData *newByteData(void *d, size_t size, bool own);
91
93 JsonDocument *decodeJson(const std::string &text);
94 JsonDocument *decodeJson(const std::string &text, std::string *error);
95 JsonDocument *decodeJson(Data *data, std::string *error = nullptr);
96 std::string encodeJson(JsonDocument *doc, bool pretty = false);
97 ByteData * encodeJsonData(JsonDocument *doc, bool pretty = false);
98
100 XmlDocument *decodeXml(const std::string &text);
101 XmlDocument *decodeXml(const std::string &text, std::string *error);
102 XmlDocument *decodeXml(Data *data, std::string *error = nullptr);
103 std::string encodeXml(XmlDocument *doc, bool pretty = false);
104 ByteData * encodeXmlData(XmlDocument *doc, bool pretty = false);
105
106}; // DataModule
107
108} // data
109} // eve
std::string error
Light2D::Data * data
int d
In-memory byte buffer implementing eve::Data (ref-counted).
Definition ByteData.h:11
ByteData * encodeXmlData(XmlDocument *doc, bool pretty=false)
ByteData * encodeJsonData(JsonDocument *doc, bool pretty=false)
DataView * newDataView(Data *data, size_t offset, size_t size)
ByteData * newByteData(size_t size)
std::string encodeXml(XmlDocument *doc, bool pretty=false)
JsonDocument * decodeJson(const std::string &text)
XmlDocument * decodeXml(const std::string &text)
XmlDocument * newXmlDocument()
Module_REG(DataModule)
JsonDocument * newJsonDocument()
std::string encodeJson(JsonDocument *doc, bool pretty=false)
Contains a reference to a subsection of an existing Data object.
Definition DataView.h:16
Thin RAII wrapper over a Poco JSON value (object/array/scalar).
Thin RAII wrapper over a Poco XML DOM document.
Definition XmlDocument.h:10
CompressedData * compress(std::string format, const char *rawbytes, size_t rawsize, int level)
Compresses a block of memory using the given compression format.
char * decompress(CompressedData *data, size_t &decompressedsize)
Decompresses existing compressed data into raw bytes.
char * decode(std::string format, const char *src, size_t srclen, size_t &dstlen)
@ CONTAINER_MAX_ENUM
Definition DataModule.h:24
@ CONTAINER_DATA
Definition DataModule.h:22
@ CONTAINER_STRING
Definition DataModule.h:23
char * encode(std::string format, const char *src, size_t srclen, size_t &dstlen, size_t linelen)
std::string hash(std::string function, Data *input)
Hash the input, producing an set of bytes as output.
Definition Build.cpp:11