-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate core source files to C++. Add yaml-cpp project as dependency (#…
…2207) By updating to this commit, Linux users have to regenerate Makefiles by re-running the configure script. * Added yaml-cpp project as a 3rdparty library * Migrated source files core to C++ * Updated configure scripts * Make Linux installations compile *.cpp files * Made server components' main source file C++ * Also made headers CPP-aware. * Added basic C wrapper for yaml-cpp library * YAML-node path is delimited by periods. * Basic integer types and string are supported. * Strings returned from this wrapper have to be freed with malloc.h::aFree * Arrays (sequence) is supported with iterator wrapper. * Remember to free every wrapper you create! * Add yaml-cpp as dependency of common project * Made the repo not ignore *.yml files Thanks to @aleos89 and @Lemongrass3110.
- Loading branch information
1 parent
e804970
commit 4a2574c
Showing
172 changed files
with
12,109 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ Thumbs.db | |
/*.suo | ||
*.o | ||
*.a | ||
*.yml | ||
*.vcxproj.user | ||
/char-server | ||
/config.log | ||
/config.status | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
YAML_CPP_OBJ = $(shell find * -type f -name "*.cpp" | sed -e "s/\.cpp/\.o/g") | ||
YAML_CPP_DIR_OBJ = $(YAML_CPP_OBJ:%=obj/%) | ||
YAML_CPP_H = $(shell find * -type f -name "*.h") | ||
YAML_CPP_AR = obj/yaml-cpp.a | ||
|
||
CXXFLAG =-std=c++11 | ||
INC=-Iinclude | ||
|
||
@SET_MAKE@ | ||
|
||
##################################################################### | ||
.PHONY : all clean help yaml-cpp | ||
|
||
all: yaml-cpp | ||
|
||
clean: | ||
@echo " CLEAN yaml-cpp" | ||
@rm -rf obj *.o | ||
|
||
help: | ||
@echo "possible targets are 'all' 'clean' 'help'" | ||
@echo "'yaml-cpp' - build $(YAML_CPP_AR) | ||
@echo "'all' - builds $(YAML_CPP_DIR_OBJ)" | ||
@echo "'clean' - deletes $(YAML_CPP_DIR_OBJ)" | ||
@echo "'help' - outputs this message" | ||
|
||
##################################################################### | ||
|
||
obj: | ||
@echo " MKDIR obj/src/contrib" | ||
@mkdir -p obj/src/contrib | ||
|
||
obj/%.o: %.cpp $(YAML_CPP_H) | ||
@echo " CXX $<" | ||
@@CXX@ $(CXXFLAG) @CFLAGS_AR@ @CPPFLAGS@ -g $(INC) -c $(OUTPUT_OPTION) $< | ||
|
||
yaml-cpp: obj $(YAML_CPP_DIR_OBJ) $(YAML_CPP_AR) | ||
|
||
$(YAML_CPP_AR): $(YAML_CPP_DIR_OBJ) | ||
@echo " AR $@" | ||
@@AR@ rcs obj/yaml-cpp.a $(YAML_CPP_DIR_OBJ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include <cstddef> | ||
|
||
namespace YAML { | ||
typedef std::size_t anchor_t; | ||
const anchor_t NullAnchor = 0; | ||
} | ||
|
||
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "yaml-cpp/dll.h" | ||
|
||
namespace YAML { | ||
YAML_CPP_API std::string EncodeBase64(const unsigned char *data, | ||
std::size_t size); | ||
YAML_CPP_API std::vector<unsigned char> DecodeBase64(const std::string &input); | ||
|
||
class YAML_CPP_API Binary { | ||
public: | ||
Binary() : m_unownedData(0), m_unownedSize(0) {} | ||
Binary(const unsigned char *data_, std::size_t size_) | ||
: m_unownedData(data_), m_unownedSize(size_) {} | ||
|
||
bool owned() const { return !m_unownedData; } | ||
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } | ||
const unsigned char *data() const { | ||
return owned() ? &m_data[0] : m_unownedData; | ||
} | ||
|
||
void swap(std::vector<unsigned char> &rhs) { | ||
if (m_unownedData) { | ||
m_data.swap(rhs); | ||
rhs.clear(); | ||
rhs.resize(m_unownedSize); | ||
std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); | ||
m_unownedData = 0; | ||
m_unownedSize = 0; | ||
} else { | ||
m_data.swap(rhs); | ||
} | ||
} | ||
|
||
bool operator==(const Binary &rhs) const { | ||
const std::size_t s = size(); | ||
if (s != rhs.size()) | ||
return false; | ||
const unsigned char *d1 = data(); | ||
const unsigned char *d2 = rhs.data(); | ||
for (std::size_t i = 0; i < s; i++) { | ||
if (*d1++ != *d2++) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool operator!=(const Binary &rhs) const { return !(*this == rhs); } | ||
|
||
private: | ||
std::vector<unsigned char> m_data; | ||
const unsigned char *m_unownedData; | ||
std::size_t m_unownedSize; | ||
}; | ||
} | ||
|
||
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include <vector> | ||
|
||
#include "../anchor.h" | ||
|
||
namespace YAML { | ||
/** | ||
* An object that stores and retrieves values correlating to {@link anchor_t} | ||
* values. | ||
* | ||
* <p>Efficient implementation that can make assumptions about how | ||
* {@code anchor_t} values are assigned by the {@link Parser} class. | ||
*/ | ||
template <class T> | ||
class AnchorDict { | ||
public: | ||
void Register(anchor_t anchor, T value) { | ||
if (anchor > m_data.size()) { | ||
m_data.resize(anchor); | ||
} | ||
m_data[anchor - 1] = value; | ||
} | ||
|
||
T Get(anchor_t anchor) const { return m_data[anchor - 1]; } | ||
|
||
private: | ||
std::vector<T> m_data; | ||
}; | ||
} | ||
|
||
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
147 changes: 147 additions & 0 deletions
147
3rdparty/yaml-cpp/include/yaml-cpp/contrib/graphbuilder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include "yaml-cpp/mark.h" | ||
#include <string> | ||
|
||
namespace YAML { | ||
class Parser; | ||
|
||
// GraphBuilderInterface | ||
// . Abstraction of node creation | ||
// . pParentNode is always NULL or the return value of one of the NewXXX() | ||
// functions. | ||
class GraphBuilderInterface { | ||
public: | ||
// Create and return a new node with a null value. | ||
virtual void *NewNull(const Mark &mark, void *pParentNode) = 0; | ||
|
||
// Create and return a new node with the given tag and value. | ||
virtual void *NewScalar(const Mark &mark, const std::string &tag, | ||
void *pParentNode, const std::string &value) = 0; | ||
|
||
// Create and return a new sequence node | ||
virtual void *NewSequence(const Mark &mark, const std::string &tag, | ||
void *pParentNode) = 0; | ||
|
||
// Add pNode to pSequence. pNode was created with one of the NewXxx() | ||
// functions and pSequence with NewSequence(). | ||
virtual void AppendToSequence(void *pSequence, void *pNode) = 0; | ||
|
||
// Note that no moew entries will be added to pSequence | ||
virtual void SequenceComplete(void *pSequence) { (void)pSequence; } | ||
|
||
// Create and return a new map node | ||
virtual void *NewMap(const Mark &mark, const std::string &tag, | ||
void *pParentNode) = 0; | ||
|
||
// Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode | ||
// were created with one of the NewXxx() methods and pMap with NewMap(). | ||
virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0; | ||
|
||
// Note that no more assignments will be made in pMap | ||
virtual void MapComplete(void *pMap) { (void)pMap; } | ||
|
||
// Return the node that should be used in place of an alias referencing | ||
// pNode (pNode by default) | ||
virtual void *AnchorReference(const Mark &mark, void *pNode) { | ||
(void)mark; | ||
return pNode; | ||
} | ||
}; | ||
|
||
// Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines | ||
// Node, Sequence, and Map types. Sequence and Map must derive from Node | ||
// (unless Node is defined as void). Impl must also implement function with | ||
// all of the same names as the virtual functions in GraphBuilderInterface | ||
// -- including the ones with default implementations -- but with the | ||
// prototypes changed to accept an explicit Node*, Sequence*, or Map* where | ||
// appropriate. | ||
template <class Impl> | ||
class GraphBuilder : public GraphBuilderInterface { | ||
public: | ||
typedef typename Impl::Node Node; | ||
typedef typename Impl::Sequence Sequence; | ||
typedef typename Impl::Map Map; | ||
|
||
GraphBuilder(Impl &impl) : m_impl(impl) { | ||
Map *pMap = NULL; | ||
Sequence *pSeq = NULL; | ||
Node *pNode = NULL; | ||
|
||
// Type consistency checks | ||
pNode = pMap; | ||
pNode = pSeq; | ||
} | ||
|
||
GraphBuilderInterface &AsBuilderInterface() { return *this; } | ||
|
||
virtual void *NewNull(const Mark &mark, void *pParentNode) { | ||
return CheckType<Node>(m_impl.NewNull(mark, AsNode(pParentNode))); | ||
} | ||
|
||
virtual void *NewScalar(const Mark &mark, const std::string &tag, | ||
void *pParentNode, const std::string &value) { | ||
return CheckType<Node>( | ||
m_impl.NewScalar(mark, tag, AsNode(pParentNode), value)); | ||
} | ||
|
||
virtual void *NewSequence(const Mark &mark, const std::string &tag, | ||
void *pParentNode) { | ||
return CheckType<Sequence>( | ||
m_impl.NewSequence(mark, tag, AsNode(pParentNode))); | ||
} | ||
virtual void AppendToSequence(void *pSequence, void *pNode) { | ||
m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode)); | ||
} | ||
virtual void SequenceComplete(void *pSequence) { | ||
m_impl.SequenceComplete(AsSequence(pSequence)); | ||
} | ||
|
||
virtual void *NewMap(const Mark &mark, const std::string &tag, | ||
void *pParentNode) { | ||
return CheckType<Map>(m_impl.NewMap(mark, tag, AsNode(pParentNode))); | ||
} | ||
virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) { | ||
m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode)); | ||
} | ||
virtual void MapComplete(void *pMap) { m_impl.MapComplete(AsMap(pMap)); } | ||
|
||
virtual void *AnchorReference(const Mark &mark, void *pNode) { | ||
return CheckType<Node>(m_impl.AnchorReference(mark, AsNode(pNode))); | ||
} | ||
|
||
private: | ||
Impl &m_impl; | ||
|
||
// Static check for pointer to T | ||
template <class T, class U> | ||
static T *CheckType(U *p) { | ||
return p; | ||
} | ||
|
||
static Node *AsNode(void *pNode) { return static_cast<Node *>(pNode); } | ||
static Sequence *AsSequence(void *pSeq) { | ||
return static_cast<Sequence *>(pSeq); | ||
} | ||
static Map *AsMap(void *pMap) { return static_cast<Map *>(pMap); } | ||
}; | ||
|
||
void *BuildGraphOfNextDocument(Parser &parser, | ||
GraphBuilderInterface &graphBuilder); | ||
|
||
template <class Impl> | ||
typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) { | ||
GraphBuilder<Impl> graphBuilder(impl); | ||
return static_cast<typename Impl::Node *>( | ||
BuildGraphOfNextDocument(parser, graphBuilder)); | ||
} | ||
} | ||
|
||
#endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
// The following ifdef block is the standard way of creating macros which make | ||
// exporting from a DLL simpler. All files within this DLL are compiled with the | ||
// yaml_cpp_EXPORTS symbol defined on the command line. This symbol should not | ||
// be defined on any project that uses this DLL. This way any other project | ||
// whose source files include this file see YAML_CPP_API functions as being | ||
// imported from a DLL, whereas this DLL sees symbols defined with this macro as | ||
// being exported. | ||
#undef YAML_CPP_API | ||
|
||
#ifdef YAML_CPP_DLL // Using or Building YAML-CPP DLL (definition defined | ||
// manually) | ||
#ifdef yaml_cpp_EXPORTS // Building YAML-CPP DLL (definition created by CMake | ||
// or defined manually) | ||
// #pragma message( "Defining YAML_CPP_API for DLL export" ) | ||
#define YAML_CPP_API __declspec(dllexport) | ||
#else // yaml_cpp_EXPORTS | ||
// #pragma message( "Defining YAML_CPP_API for DLL import" ) | ||
#define YAML_CPP_API __declspec(dllimport) | ||
#endif // yaml_cpp_EXPORTS | ||
#else // YAML_CPP_DLL | ||
#define YAML_CPP_API | ||
#endif // YAML_CPP_DLL | ||
|
||
#endif // DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
Oops, something went wrong.