Skip to content

Commit

Permalink
Merge pull request #10 from Sygmei/v1.0
Browse files Browse the repository at this point in the history
v1.0 update
  • Loading branch information
Sygmei authored May 5, 2020
2 parents ff0cce6 + a4489c7 commit afb6497
Show file tree
Hide file tree
Showing 30 changed files with 241 additions and 214 deletions.
30 changes: 13 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0015 NEW)
cmake_minimum_required(3.1)

project(vili)

include_directories(include/)
include_directories(include/vili)
file(GLOB PG_VILI
include/*.hpp
include/vili/*.hpp
)
file(GLOB HD_VILI
src/*.cpp
src/vili/*.cpp
)
file(GLOB VILI_HEADERS include/vili/*.hpp)
file(GLOB VILI_SOURCES src/*.cpp src/*.inl)

if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -O3")
endif()
add_library(vili ${VILI_HEADERS} ${VILI_SOURCES})

add_library(vili ${PG_VILI} ${HD_VILI})
target_include_directories(vili
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/vili>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_EXTENSIONS OFF)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_EXTENSIONS OFF)
22 changes: 0 additions & 22 deletions include/Vili.hpp

This file was deleted.

5 changes: 2 additions & 3 deletions include/vili/ArrayNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
#include <vector>
#include <memory>

#include "DataNode.hpp"
#include "ContainerNode.hpp"
#include <ContainerNode.hpp>
#include <DataNode.hpp>

namespace vili
{
/**
* \brief An ArrayNode is a Node that can contains multiple DataNodes with an index
* @Bind
*/
class ArrayNode : public ContainerNode
{
Expand Down
27 changes: 13 additions & 14 deletions include/vili/ComplexNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <memory>
#include <vector>

#include "DataNode.hpp"
#include "ContainerNode.hpp"
#include "ArrayNode.hpp"
#include "NodeIterator.hpp"
#include "NodeValidator.hpp"
#include <ArrayNode.hpp>
#include <ContainerNode.hpp>
#include <DataNode.hpp>
#include <NodeIterator.hpp>
#include <NodeValidator.hpp>

namespace vili
{
Expand All @@ -18,7 +18,6 @@ namespace vili

/**
* \brief A ComplexNode can contains every other Nodes (including itself) hence allowing a tree-like structure
* @Bind
*/
class ComplexNode : public ContainerNode
{
Expand Down Expand Up @@ -63,10 +62,10 @@ namespace vili
* \param heritTarget ComplexNode to herit from
*/
void heritage(ComplexNode* heritTarget);

/**
* \brief Access a ComplexNode child
* \param id Id of the ComplexNode child
* \param id Id of the ComplexNode child
* \return A reference to the ComplexNode child
*/
ComplexNode& operator[](const std::string& id) const;
Expand Down Expand Up @@ -259,15 +258,15 @@ namespace vili
LinkNode& createLinkNode(const std::string& id, const std::string& path);
/**
* \brief Pushes an existing LinkNode in the ComplexNode
* \param attribute Pointer to the LinkNode to push to the ComplexNode
* \param attribute Pointer to the LinkNode to push to the ComplexNode
* \return A reference to the newly pushed LinkNode
*/
LinkNode& pushLinkNode(LinkNode* attribute);

/**
* \brief Removes a child Node from the ComplexNode
* \param id Id of the Node to remove
* \param freeMemory If equals to true, the DataNode will be erased from memory\n
* \param freeMemory If equals to true, the DataNode will be erased from memory\n
* else it will juste remove the Tree from the tree while keeping the DataNode pointer valid
*/
void remove(const std::string& id);
Expand Down Expand Up @@ -371,10 +370,10 @@ namespace vili
return baseIterator.result();
}
NodeValidator<T> baseIterator;
for (Node* complex : getAll(NodeType::ComplexNode))
for (ComplexNode* complex : getAll<ComplexNode>())
{
if (!baseIterator.over())
getComplexNode(complex->getId()).walk<T>(walkFunction, baseIterator);
complex->walk<T>(walkFunction, baseIterator);
else
break;
}
Expand All @@ -389,10 +388,10 @@ namespace vili
template <class T>
void ComplexNode::walk(std::function<void(NodeValidator<T>&)> walkFunction, NodeValidator<T>& iterator)
{
for (Node* complex : getAll(NodeType::ComplexNode))
for (ComplexNode* complex : getAll<ComplexNode>())
{
if (!iterator.over())
getComplexNode(complex->getId()).walk<T>(walkFunction, iterator);
complex->walk<T>(walkFunction, iterator);
else
break;
}
Expand Down
5 changes: 2 additions & 3 deletions include/vili/ContainerNode.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#pragma once

#include "Node.hpp"
#include <Node.hpp>

namespace vili
{
/**
* \brief Abstract base class for ArrayNode and ComplexNode (A ContainerNode can contains other nodes)
* @Bind
*/
class ContainerNode : public Node
{
Expand All @@ -19,7 +18,7 @@ namespace vili
* \brief Creates a new ContainerNode (Abstract Class)
* \param parent Parent of the ContainedNode
* \param id Id of the ContainerNode
* \param type
* \param type Type of the Node
*/
ContainerNode(ContainerNode* parent, const std::string& id, const NodeType& type);
/**
Expand Down
7 changes: 3 additions & 4 deletions include/vili/DataNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

#include <variant>

#include "../ErrorHandler.hpp"
#include "Node.hpp"
#include <ErrorHandler.hpp>
#include <Node.hpp>

namespace vili
{
/**
* \brief A terminal Node that contains data (One of the types defined in vili::DataType)
* @Bind
*/
class DataNode : public Node
{
Expand Down Expand Up @@ -142,7 +141,7 @@ namespace vili
/**
* \brief Returns the Data contained in the DataNode casted to an unsigned int
*/
operator unsigned int() const;
operator unsigned int() const;
/**
* \brief Returns the Data contained in the DataNode casted to an int
*/
Expand Down
8 changes: 6 additions & 2 deletions include/ErrorHandler.hpp → include/vili/ErrorHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace aube
{
/**
* \brief An ErrorMessage Class
* @Bind
*/
class ErrorMessage
{
Expand Down Expand Up @@ -45,7 +44,6 @@ namespace aube

/**
* \brief Handles Errors in Vili
* @Bind
*/
class ErrorHandler
{
Expand All @@ -70,4 +68,10 @@ namespace aube

static void Warn(const std::string& errorId, const std::map<std::string, std::string>& parameters = {});
};

/**
* \brief Loads all Aube Errors located in the given path
* \param errorFile File where to load Aube Errors
*/
void LoadErrors(const std::string& errorFile);
}
File renamed without changes.
9 changes: 4 additions & 5 deletions include/vili/LinkNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

#include <string>

#include "DataNode.hpp"
#include "ComplexNode.hpp"
#include "ContainerNode.hpp"
#include "ArrayNode.hpp"
#include <ArrayNode.hpp>
#include <ComplexNode.hpp>
#include <ContainerNode.hpp>
#include <DataNode.hpp>

namespace vili
{
class ComplexNode;

/**
* \brief A Node that is linked to another one in the Tree
* @Bind
*/
class LinkNode : public Node
{
Expand Down
31 changes: 31 additions & 0 deletions include/vili/MultipleViliParser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <ComplexNode.hpp>
#include <NodeTemplate.hpp>

namespace vili
{
/**
* \brief A Class that can parse multiple .vili files and create a Node Tree
*/
class MultipleViliParser
{
private:
std::map<std::string, std::vector<std::string>> m_filemap;
public:
/**
* \brief Creates a ViliParser
*/
MultipleViliParser();
/**
* \brief Creates a ViliParser and parses the file at the given path
* \param file Path of the file to parse
*/
MultipleViliParser(std::string currentFile);
template <class... files>
MultipleViliParser(std::string currentFile, files... filepack);
MultipleViliParser(std::vector<std::string> files);

void writeFiles(bool verbose = false);
};
}
7 changes: 3 additions & 4 deletions include/vili/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

#include <string>

#include "Types.hpp"
#include <Types.hpp>

namespace vili
{
class ContainerNode;

/**
* \brief Base Class for every Node in the Tree
* @Bind
*/
class Node
{
Expand All @@ -21,10 +20,8 @@ namespace vili
ContainerNode* m_parent = nullptr;
bool m_visible = true;
virtual void removeParent(ContainerNode* currentParent);
virtual ContainerNode* getParent() const;
friend class ContainerNode;
friend class LinkNode;
friend void LoadErrors(const std::string& errorFile);
public:
/**
* \brief ClassType is redefined for every derived class
Expand All @@ -47,6 +44,8 @@ namespace vili
{
}

ContainerNode* getParent() const;

/**
* \brief Sets the Node annotation (Little Node description displayed when calling Node::getNodePath())
* \param annotation New Annotation to set
Expand Down
1 change: 0 additions & 1 deletion include/vili/NodeIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace vili

/**
* \brief A class that can be used in argument in the ComplexNode::walk function to walk through the whole tree
* @Bind
*/
class NodeIterator
{
Expand Down
4 changes: 1 addition & 3 deletions include/vili/NodeTemplate.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#pragma once

#include "LinkNode.hpp"
#include <LinkNode.hpp>

namespace vili
{
/**
* \brief Constraints a NodeTemplate parameter
* @Bind
*/
class NodeConstraintManager
{
Expand Down Expand Up @@ -44,7 +43,6 @@ namespace vili

/**
* \brief Transforms a Node Constructor to a ComplexNode
* @Bind
*/
class NodeTemplate
{
Expand Down
3 changes: 1 addition & 2 deletions include/vili/NodeValidator.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma once

#include "NodeIterator.hpp"
#include <NodeIterator.hpp>

namespace vili
{
/**
* \brief Almost like the NodeIterator except it should return a result
* \tparam T Type the NodeValidator should return (validate)
* @Bind
*/
template <class T>
class NodeValidator : public NodeIterator
Expand Down
14 changes: 14 additions & 0 deletions include/vili/Vili.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <ViliParser.hpp>
#include <LinkNode.hpp>

#include <ErrorHandler.hpp>
#include <Functions.hpp>

/**
* \brief A nice and readable data format language !
*/
namespace vili
{
}
Loading

0 comments on commit afb6497

Please sign in to comment.