Phasor  01.00.10.059
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
api_readers.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <string>
5 #include "../Phasor/Halo/Game/Game.h"
6 #include "../Phasor/Halo/Server/Server.h"
7 #include "PhasorAPI.h"
8 
9 // Raises an invalid player error
10 void RaisePlayerError(Manager::CallHandler& handler, int player_id);
11 
12 // Reads the message argument and parses it, replacing {x} with player x's
13 // name and splitting the message into a new one at each \n
14 std::vector<std::wstring> ReadString(Common::Object& obj);
15 
16 // Don't apply any processing like in ReadString
17 std::string ReadRawString(Common::Object& obj);
18 
19 // Read the player, if strict is true an error is raised if the player doesn't
20 // exist.
21 halo::s_player* ReadPlayer(Manager::CallHandler& handler, Common::Object& playerObj, bool strict);
22 
23 // Reads an object id and validates it
24 void* ReadHaloObject(Manager::CallHandler& handler, const Common::Object& obj,
25  bool allow_invalid, halo::ident& objid);
26 
27 // Reads an tag id and validates it
29  halo::ident& tagid);
30 
31 // Read number of specified type.
32 template <typename T> T ReadNumber(const Common::Object& obj)
33 {
34  const Common::ObjNumber* num = (const Common::ObjNumber*)&obj;
35  return (T)num->GetValue();
36 }
37 
38 // Reads a boolean
39 bool ReadBoolean(const Common::Object& obj);
40 
41 
43 void AddResultString(const std::string& str, Common::Object::unique_list& results);
44 void AddResultString(const std::wstring& str, Common::Object::unique_list& results);
45 void AddResultNumber(double value, Common::Object::unique_list& results);
46 void AddResultBool(bool b, Common::Object::unique_list& results);
47 void AddResultPtr(void* ptr, Common::Object::unique_list& result);
48 void AddResultTable(const std::vector<std::string>& data, Common::Object::unique_list& result);