Skip to content

Commit

Permalink
Merge pull request #131 from fktn-k/feature/128_move_internal_impl
Browse files Browse the repository at this point in the history
#128 moved internal impl to detail dir/namespace
  • Loading branch information
fktn-k authored Oct 9, 2023
2 parents de6eabf + 7de23f8 commit e954b8a
Show file tree
Hide file tree
Showing 25 changed files with 584 additions and 512 deletions.
14 changes: 0 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ if(FK_YAML_CODE_COVERAGE)
set(FK_YAML_BUILD_TEST ON)
endif()

if(FK_YAML_RUN_CLANG_FORMAT OR FK_YAML_CI)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
endif()

if(FK_YAML_BUILD_TEST OR FK_YAML_BUILD_ALL_TEST)
set(CATCH2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/catch2")
if(NOT EXISTS ${CATCH2_ROOT_DIR}/CMakeLists.txt)
Expand Down Expand Up @@ -78,19 +74,9 @@ target_include_directories(
${FK_YAML_TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${FK_YAML_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:${FK_YAML_INCLUDE_INSTALL_DIR}>)

# configure clang-format if enabled.
if(FK_YAML_RUN_CLANG_FORMAT)
set(FK_YAML_ClangFormatTargetPrefix "run_clang_format_for_")
include(RunClangFormat)
run_clang_format(${FK_YAML_TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/include/fkYAML/*.hpp")
endif()

# Configure clang-tidy if enabled.
if(FK_YAML_RUN_CLANG_TIDY)
add_subdirectory(tool/clang_tidy)
if(FK_YAML_RUN_CLANG_FORMAT)
add_dependencies(ClangTidyHelper "${FK_YAML_ClangFormatTargetPrefix}${FK_YAML_TARGET_NAME}")
endif()
endif()

# Configure include-what-you-use if enabled.
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ all:

# pre-requisites: clang-format
clang-format:
cmake -B build_clang_format -S . -DFK_YAML_RUN_CLANG_FORMAT=ON
cmake --build build_clang_format --target run_clang_format
for FILE in $(SRCS) $(TEST_SRCS); do echo $$FILE; clang-format -i $$FILE; done

# pre-requisites: clang-tidy
clang-tidy:
Expand Down
27 changes: 0 additions & 27 deletions cmake/RunClangFormat.cmake

This file was deleted.

21 changes: 10 additions & 11 deletions include/fkYAML/deserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@
#include <cstdint>
#include <unordered_map>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/detail/version_macros.hpp"
#include "fkYAML/detail/lexical_analyzer.hpp"
#include "fkYAML/detail/type_traits.hpp"
#include "fkYAML/exception.hpp"
#include "fkYAML/lexical_analyzer.hpp"
#include "fkYAML/node.hpp"
#include "fkYAML/type_traits.hpp"

/**
* @namespace fkyaml
* @brief namespace for fkYAML library.
*/
FK_YAML_NAMESPACE_BEGIN

/**
* @class basic_deserializer
* @brief A class which provides the feature of deserializing YAML documents.
*/

/**
* @class basic_deserializer
* @brief A class which provides the feature of deserializing YAML documents.
Expand All @@ -42,7 +37,8 @@ FK_YAML_NAMESPACE_BEGIN
template <typename BasicNodeType = node>
class basic_deserializer
{
static_assert(is_basic_node<BasicNodeType>::value, "basic_deserializer only accepts (const) basic_node<...>");
static_assert(
detail::is_basic_node<BasicNodeType>::value, "basic_deserializer only accepts (const) basic_node<...>");

/** A type for sequence node value containers. */
using sequence_type = typename BasicNodeType::sequence_type;
Expand All @@ -57,7 +53,10 @@ class basic_deserializer
/** A type for string node values. */
using string_type = typename BasicNodeType::string_type;
/** A type for the lexical analyzer object used by this deserializer. */
using lexer_type = lexical_analyzer<BasicNodeType>;
using lexer_type = detail::lexical_analyzer<BasicNodeType>;

using lexical_token_t = detail::lexical_token_t;
using yaml_version_t = detail::yaml_version_t;

public:
/**
Expand Down Expand Up @@ -314,7 +313,7 @@ class basic_deserializer
private:
lexer_type m_lexer {}; /** A lexical analyzer object. */
BasicNodeType* m_current_node = nullptr; /** The currently focused YAML node. */
std::vector<BasicNodeType*> m_node_stack; /** The stack of YAML nodes. */
std::vector<BasicNodeType*> m_node_stack {}; /** The stack of YAML nodes. */
yaml_version_t m_yaml_version = yaml_version_t::VER_1_2; /** The YAML version specification type. */
uint32_t m_current_indent_width = 0; /** The current indentation width. */
bool m_needs_anchor_impl = false; /** A flag to determine the need for YAML anchor node implementation */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* @file
*/

#ifndef FK_YAML_ASSERT_HPP_
#define FK_YAML_ASSERT_HPP_
#ifndef FK_YAML_DETAIL_ASSERT_HPP_
#define FK_YAML_DETAIL_ASSERT_HPP_

// if FK_YAML_ASSERT is not user-defined. apply the default assert impl.
#ifndef FK_YAML_ASSERT
Expand All @@ -23,4 +23,4 @@
#endif
#endif

#endif /* FK_YAML_ASSERT_HPP_ */
#endif /* FK_YAML_DETAIL_ASSERT_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
* @file
*/

#ifndef FK_YAML_FROM_NODE_HPP_
#define FK_YAML_FROM_NODE_HPP_
#ifndef FK_YAML_DETAIL_FROM_NODE_HPP_
#define FK_YAML_DETAIL_FROM_NODE_HPP_

#include <limits>
#include <utility>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/detail/version_macros.hpp"
#include "fkYAML/detail/type_traits.hpp"
#include "fkYAML/detail/node_t.hpp"
#include "fkYAML/exception.hpp"
#include "fkYAML/node_t.hpp"
#include "fkYAML/type_traits.hpp"

/**
* @namespace fkyaml
Expand Down Expand Up @@ -280,4 +280,4 @@ FK_YAML_INLINE_VAR constexpr const auto& from_node = detail::static_const<detail

FK_YAML_NAMESPACE_END

#endif /* FK_YAML_FROM_NODE_HPP_ */
#endif /* FK_YAML_DETAIL_FROM_NODE_HPP_ */
21 changes: 15 additions & 6 deletions include/fkYAML/iterator.hpp → include/fkYAML/detail/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@
* @file
*/

#ifndef FK_YAML_ITERATOR_HPP_
#define FK_YAML_ITERATOR_HPP_
#ifndef FK_YAML_DETAIL_ITERATOR_HPP_
#define FK_YAML_DETAIL_ITERATOR_HPP_

#include <cstddef>
#include <iterator>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/detail/version_macros.hpp"
#include "fkYAML/detail/type_traits.hpp"
#include "fkYAML/exception.hpp"
#include "fkYAML/type_traits.hpp"

/**
* @namespace fkyaml
* @brief namespace for fkYAML library.
*/
FK_YAML_NAMESPACE_BEGIN

/**
* @namespace detail
* @brief namespace for internal implementations of fkYAML library.
*/
namespace detail
{

/**
* @struct sequence_iterator_tag
* @brief A tag which tells Iterator will contain sequence value iterator.
Expand Down Expand Up @@ -123,7 +130,7 @@ class iterator
/** A type of non-const version of iterated elements. */
using NonConstValueType = typename std::remove_const<ValueType>::type;

static_assert(is_basic_node<NonConstValueType>::value, "Iterator only accepts (const) BasicNode<...>");
static_assert(is_basic_node<NonConstValueType>::value, "Iterator only accepts basic_node<...>");

/**
* @struct iterator_holder
Expand Down Expand Up @@ -568,6 +575,8 @@ class iterator
mutable iterator_holder m_iterator_holder;
};

} // namespace detail

FK_YAML_NAMESPACE_END

#endif /* FK_YAML_ITERATOR_HPP_ */
#endif /* FK_YAML_DETAIL_ITERATOR_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* @file
*/

#ifndef FK_YAML_LEXICAL_ANALIZER_HPP_
#define FK_YAML_LEXICAL_ANALIZER_HPP_
#ifndef FK_YAML_DETAIL_LEXICAL_ANALIZER_HPP_
#define FK_YAML_DETAIL_LEXICAL_ANALIZER_HPP_

#include <cctype>
#include <cmath>
Expand All @@ -21,17 +21,24 @@
#include <string>
#include <vector>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/assert.hpp"
#include "fkYAML/detail/version_macros.hpp"
#include "fkYAML/detail/assert.hpp"
#include "fkYAML/detail/type_traits.hpp"
#include "fkYAML/exception.hpp"
#include "fkYAML/type_traits.hpp"

/**
* @namespace fkyaml
* @brief namespace for fkYAML library.
*/
FK_YAML_NAMESPACE_BEGIN

/**
* @namespace detail
* @brief namespace for internal implementations of fkYAML library.
*/
namespace detail
{

/**
* @enum lexical_token_t
* @brief Definition of lexical token types.
Expand Down Expand Up @@ -70,7 +77,7 @@ template <typename BasicNodeType>
class lexical_analyzer
{
private:
static_assert(is_basic_node<BasicNodeType>::value, "lexical_analyzer only accepts (const) BasicNode<...>");
static_assert(is_basic_node<BasicNodeType>::value, "lexical_analyzer only accepts basic_node<...>");

using char_traits_type = std::char_traits<char>;
using char_int_type = typename char_traits_type::int_type;
Expand Down Expand Up @@ -1273,6 +1280,8 @@ class lexical_analyzer
std::vector<uint32_t> m_indent_width_stack;
};

} // namespace detail

FK_YAML_NAMESPACE_END

#endif /* FK_YAML_LEXICAL_ANALIZER_HPP_ */
#endif /* FK_YAML_DETAIL_LEXICAL_ANALIZER_HPP_ */
17 changes: 13 additions & 4 deletions include/fkYAML/node_t.hpp → include/fkYAML/detail/node_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,26 @@
* @file
*/

#ifndef FK_YAML_NODE_TYPE_HPP_
#define FK_YAML_NODE_TYPE_HPP_
#ifndef FK_YAML_DETAIL_NODE_T_HPP_
#define FK_YAML_DETAIL_NODE_T_HPP_

#include <cstdint>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/detail/version_macros.hpp"

/**
* @namespace fkyaml
* @brief namespace for fkYAML library.
*/
FK_YAML_NAMESPACE_BEGIN

/**
* @namespace detail
* @brief namespace for internal implementations of fkYAML library.
*/
namespace detail
{

/**
* @enum node_t
* @brief Definition of node value types.
Expand All @@ -38,6 +45,8 @@ enum class node_t : std::uint32_t
STRING, //!< string value type
};

} // namespace detail

FK_YAML_NAMESPACE_END

#endif /* FK_YAML_NODE_TYPE_HPP_ */
#endif /* FK_YAML_DETAIL_NODE_T_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* @file
*/

#ifndef FK_YAML_STL_SUPPLEMENT_HPP_
#define FK_YAML_STL_SUPPLEMENT_HPP_
#ifndef FK_YAML_DETAIL_STL_SUPPLEMENT_HPP_
#define FK_YAML_DETAIL_STL_SUPPLEMENT_HPP_

#include <type_traits>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/detail/version_macros.hpp"

/**
* @namespace fkyaml
Expand Down Expand Up @@ -194,4 +194,4 @@ using std::remove_cvref_t;

FK_YAML_NAMESPACE_END

#endif /* FK_YAML_STL_SUPPLEMENT_HPP_ */
#endif /* FK_YAML_DETAIL_STL_SUPPLEMENT_HPP_ */
16 changes: 8 additions & 8 deletions include/fkYAML/to_node.hpp → include/fkYAML/detail/to_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
* @file
*/

#ifndef FK_YAML_TO_NODE_HPP_
#define FK_YAML_TO_NODE_HPP_
#ifndef FK_YAML_DETAIL_TO_NODE_HPP_
#define FK_YAML_DETAIL_TO_NODE_HPP_

#include <utility>

#include "fkYAML/version_macros.hpp"
#include "fkYAML/node_t.hpp"
#include "fkYAML/type_traits.hpp"
#include "fkYAML/detail/version_macros.hpp"
#include "fkYAML/detail/node_t.hpp"
#include "fkYAML/detail/type_traits.hpp"

/**
* @namespace fkyaml
Expand All @@ -44,9 +44,9 @@ namespace detail
* @warning All the specialization must call n.m_node_value.destroy(n.m_node_type) first in construct function to avoid
* memory leak.
*
* @tparam fkyaml::node_t The resulting YAMK node value type.
* @tparam node_t The resulting YAMK node value type.
*/
template <fkyaml::node_t>
template <node_t>
struct external_node_constructor;

/**
Expand Down Expand Up @@ -360,4 +360,4 @@ FK_YAML_INLINE_VAR constexpr const auto& to_node = detail::static_const<detail::

FK_YAML_NAMESPACE_END

#endif /* FK_YAML_TO_NODE_HPP_ */
#endif /* FK_YAML_DETAIL_TO_NODE_HPP_ */
Loading

0 comments on commit e954b8a

Please sign in to comment.