Skip to content

Commit

Permalink
Use json forward-declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Desour committed Apr 27, 2023
1 parent 8b73743 commit 7f6b09d
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/client/client.cpp
Expand Up @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <sstream>
#include <cmath>
#include <IFileSystem.h>
#include <json/json.h>
#include "client.h"
#include "network/clientopcodes.h"
#include "network/connection.h"
Expand Down
1 change: 1 addition & 0 deletions src/cmake_config.h.in
Expand Up @@ -27,6 +27,7 @@
#cmakedefine01 USE_PROMETHEUS
#cmakedefine01 USE_SPATIAL
#cmakedefine01 USE_SYSTEM_GMP
#cmakedefine01 USE_SYSTEM_JSONCPP
#cmakedefine01 USE_REDIS
#cmakedefine01 HAVE_ENDIAN_H
#cmakedefine01 CURSES_HAVE_CURSES_H
Expand Down
2 changes: 1 addition & 1 deletion src/content/mods.h
Expand Up @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <vector>
#include <string>
#include <map>
#include <json/json.h>
#include "json-forwards.h"
#include <unordered_set>
#include "util/basic_macros.h"
#include "config.h"
Expand Down
6 changes: 4 additions & 2 deletions src/convert_json.cpp
Expand Up @@ -17,12 +17,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "convert_json.h"

#include <json/json.h>

#include <iostream>
#include <sstream>
#include <memory>

#include "convert_json.h"

void fastWriteJson(const Json::Value &value, std::ostream &to)
{
Json::StreamWriterBuilder builder;
Expand Down
2 changes: 1 addition & 1 deletion src/convert_json.h
Expand Up @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#pragma once

#include <json/json.h>
#include "json-forwards.h"
#include <ostream>

void fastWriteJson(const Json::Value &value, std::ostream &to);
Expand Down
4 changes: 2 additions & 2 deletions src/database/database-files.cpp
Expand Up @@ -17,15 +17,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <cassert>
#include "convert_json.h"
#include "database-files.h"
#include "convert_json.h"
#include "remoteplayer.h"
#include "settings.h"
#include "porting.h"
#include "filesys.h"
#include "server/player_sao.h"
#include "util/string.h"
#include <cassert>

// !!! WARNING !!!
// This backend is intended to be used on Minetest 0.4.16 only for the transition backend
Expand Down
2 changes: 1 addition & 1 deletion src/database/database-files.h
Expand Up @@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "database.h"
#include <unordered_map>
#include <unordered_set>
#include <json/json.h>
#include <json/json.h> // for Json::Value

class PlayerDatabaseFiles : public PlayerDatabase
{
Expand Down
31 changes: 31 additions & 0 deletions src/json-forwards.h
@@ -0,0 +1,31 @@
/*
Minetest
Copyright (C) 2023 DS
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program 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. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#pragma once

#include "config.h"

#if USE_SYSTEM_JSONCPP
#include <json/version.h>
#include <json/allocator.h>
#include <json/config.h>
#include <json/forwards.h>
#else
#include <json/json-forwards.h>
#endif
1 change: 1 addition & 0 deletions src/serverenvironment.cpp
Expand Up @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/

#include <algorithm>
#include <stack>
#include "serverenvironment.h"
#include "settings.h"
#include "log.h"
Expand Down
4 changes: 2 additions & 2 deletions src/serverlist.h
Expand Up @@ -17,10 +17,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <iostream>
#include "config.h"
#include "content/mods.h"
#include <json/json.h>
#include "json-forwards.h"
#include <iostream>

#pragma once

Expand Down
1 change: 1 addition & 0 deletions src/tool.cpp
Expand Up @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "convert_json.h"
#include "util/serialize.h"
#include "util/numeric.h"
#include <json/json.h>

void ToolGroupCap::toJson(Json::Value &object) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/tool.h
Expand Up @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string>
#include <iostream>
#include "itemgroup.h"
#include <json/json.h>
#include "json-forwards.h"

struct ItemDefinition;

Expand Down

0 comments on commit 7f6b09d

Please sign in to comment.