mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-22 02:45:07 -04:00
htc: implement service channel parsing (ReceiveReadyPacket)
This commit is contained in:
parent
4e9bc617bb
commit
6fc24d8883
5 changed files with 322 additions and 0 deletions
50
libraries/libstratosphere/source/htclow/ctrl/htclow_json.hpp
Normal file
50
libraries/libstratosphere/source/htclow/ctrl/htclow_json.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::htclow::ctrl {
|
||||
|
||||
class JsonHandler : public rapidjson::BaseReaderHandler<rapidjson::UTF8<char>, JsonHandler>{
|
||||
private:
|
||||
enum class State {
|
||||
Begin = 0,
|
||||
ParseObject = 1,
|
||||
ParseServiceChannels = 2,
|
||||
ParseServiceChannelsArray = 3,
|
||||
ParseProtocolVersion = 4,
|
||||
End = 5,
|
||||
};
|
||||
private:
|
||||
State m_state;
|
||||
s16 *m_version;
|
||||
const char **m_strings;
|
||||
int *m_num_strings;
|
||||
int m_max_strings;
|
||||
public:
|
||||
JsonHandler(s16 *vers, const char **str, int *ns, int max) : m_state(State::Begin), m_version(vers), m_strings(str), m_num_strings(ns), m_max_strings(max) { /* ... */ }
|
||||
|
||||
bool Key(const Ch *str, rapidjson::SizeType len, bool copy);
|
||||
bool Uint(unsigned);
|
||||
bool String(const Ch *, rapidjson::SizeType, bool);
|
||||
|
||||
bool StartObject();
|
||||
bool EndObject(rapidjson::SizeType);
|
||||
bool StartArray();
|
||||
bool EndArray(rapidjson::SizeType);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue