(svn r27985) -Codechange: Convert VA2 switches into ones with non-overlapping ranges...
[openttd.git] / src / script / api / script_admin.hpp
blob48126eac0bfb4a97ee5ea63c18a6053ee49367b7
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file script_admin.hpp Everything to communicate with the AdminPort. */
12 #ifndef SCRIPT_ADMIN_HPP
13 #define SCRIPT_ADMIN_HPP
15 #include <string>
16 #include "script_object.hpp"
18 /**
19 * Class that handles communication with the AdminPort.
20 * @api game
22 class ScriptAdmin : public ScriptObject {
23 public:
24 #ifndef DOXYGEN_API
25 /**
26 * Internal representation of the Send function.
28 static SQInteger Send(HSQUIRRELVM vm);
29 #else
30 /**
31 * Send information to the AdminPort. The information can be anything
32 * as long as it isn't a class or instance thereof.
33 * @param table The information to send, in a table. For example: { param = "param" }.
34 * @return True if and only if the data was successfully converted to JSON
35 * and send to the AdminPort.
36 * @note If the resulting JSON of your table is larger than 1450 bytes,
37 * nothing will be sent (and false will be returned).
39 static bool Send(void *table);
40 #endif /* DOXYGEN_API */
42 private:
43 /**
44 * Convert a Squirrel structure into a JSON string.
45 * @param vm The VM to operate on.
46 * @param index The index we are currently working for.
47 * @param max_depth The maximal depth to follow the squirrel struct.
48 * @param data The resulting json string.
50 static bool MakeJSON(HSQUIRRELVM vm, SQInteger index, int max_depth, std::string &data);
53 #endif /* SCRIPT_ADMIN_HPP */