DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
DataParsingFunctions.hpp
Go to the documentation of this file.
1/*
2 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// DataParsingFunctions.hpp - Header file for the data-parsing functions.
22/// Oct 1, 2021
23/// https://discordcoreapi.com
24/// \file DataParsingFunctions.hpp
25
26#pragma once
27
28#include <simdjson.h>
29#include <map>
30
31namespace DiscordCoreAPI {
32
33 struct DiscordCoreAPI_Dll ObjectReturnData {
34 simdjson::ondemand::value object{};
35 bool didItSucceed{};
36 };
37
38 struct DiscordCoreAPI_Dll ArrayReturnData {
39 simdjson::ondemand::array arrayValue{};
40 bool didItSucceed{};
41 };
42
43 bool getObject(simdjson::ondemand::value& object, const char* key, simdjson::ondemand::value jsonObjectData);
44
45 bool getArray(simdjson::ondemand::array& array, const char* key, simdjson::ondemand::value jsonObjectData);
46
47 bool getArray(simdjson::ondemand::array& array, simdjson::ondemand::value jsonObjectData);
48
49 Snowflake getId(simdjson::ondemand::value jsonObjectData, const char* key);
50
51 Snowflake getId(simdjson::ondemand::value jsonObjectData);
52
53 int64_t getInt64(simdjson::ondemand::value jsonData, const char* key);
54
55 int32_t getInt32(simdjson::ondemand::value jsonData, const char* key);
56
57 int16_t getInt16(simdjson::ondemand::value jsonData, const char* key);
58
59 int8_t getInt8(simdjson::ondemand::value jsonData, const char* key);
60
61 uint64_t getUint64(simdjson::ondemand::value jsonData, const char* key);
62
63 uint32_t getUint32(simdjson::ondemand::value jsonData, const char* key);
64
65 uint16_t getUint16(simdjson::ondemand::value jsonData, const char* key);
66
67 uint8_t getUint8(simdjson::ondemand::value jsonData, const char* key);
68
69 double getFloat(simdjson::ondemand::value jsonData, const char* key);
70
71 bool getBool(simdjson::ondemand::value jsonData, const char* key);
72
73 std::string getString(simdjson::ondemand::value jsonData, const char* key);
74
75 std::string getString(ObjectReturnData jsonData, const char* key);
76
77 std::string getString(simdjson::ondemand::value jsonData);
78
79 ObjectReturnData getObject(simdjson::ondemand::value jsonObjectData, const char* objectName);
80
81 ObjectReturnData getObject(ObjectReturnData jsonObjectData, const char* objectName);
82
83 ObjectReturnData getObject(ArrayReturnData jsonObjectData, uint64_t objectIndex);
84
85 ArrayReturnData getArray(simdjson::ondemand::value jsonObjectData, const char* arrayName);
86
87 ArrayReturnData getArray(ObjectReturnData jsonObjectData, const char* arrayName);
88
89};
The main namespace for this library.