CPP-TOOLBOX
Loading...
Searching...
No Matches
meta_utils::MetaInclude Class Reference

Represents an include directive for C++ source code, providing control over whether it is a system or local include. More...

#include <meta_utils.hpp>

Public Types

enum class  Type { Local , System }
 Distinguishes between local and system include types. More...
 

Public Member Functions

 MetaInclude (std::string project_relative_path, Type type=Type::Local)
 Constructs a MetaInclude with the given path and type.
 
std::string str (const std::filesystem::path &base=".") const
 Converts the MetaInclude into a valid C++ #include directive string.
 

Detailed Description

Represents an include directive for C++ source code, providing control over whether it is a system or local include.

The MetaInclude class is used to generate standardized C++ include statements. It supports both system includes (#include <...>) and local includes (#include "...") depending on the specified type.

Member Enumeration Documentation

◆ Type

enum class meta_utils::MetaInclude::Type
strong

Distinguishes between local and system include types.

Enumerator
Local 

Include file from the project directory (uses quotes: "...")

System 

Include file from system paths (uses angle brackets: <...>)

Constructor & Destructor Documentation

◆ MetaInclude()

meta_utils::MetaInclude::MetaInclude ( std::string project_relative_path,
Type type = Type::Local )
inline

Constructs a MetaInclude with the given path and type.

Parameters
project_relative_pathThe path to the header file, relative to the project root.
typeThe type of include (Local or System). Defaults to Local.

Example usage:

// Local include example (uses quotes)
MetaInclude local_inc("src/utility/glm_meta_types/glm_meta_types.hpp");
std::cout << local_inc.str() << std::endl;
// Output: #include "src/utility/glm_meta_types/glm_meta_types.hpp"
// System include example (uses angle brackets)
MetaInclude system_inc("vector", MetaInclude::Type::System);
std::cout << system_inc.str() << std::endl;
// Output: #include <vector>
// Relative include example (base path stripping)
MetaInclude relative_inc("project/src/utility/math.hpp");
std::cout << relative_inc.str("project") << std::endl;
// Output: #include "src/utility/math.hpp"
@ System
Include file from system paths (uses angle brackets: <...>)
Definition meta_utils.hpp:39
MetaInclude(std::string project_relative_path, Type type=Type::Local)
Constructs a MetaInclude with the given path and type.
Definition meta_utils.hpp:66

Member Function Documentation

◆ str()

std::string meta_utils::MetaInclude::str ( const std::filesystem::path & base = ".") const
inline

Converts the MetaInclude into a valid C++ #include directive string.

Parameters
baseThe base directory to which the path should be made relative. Defaults to the current directory (".").
Returns
A formatted include directive as a string.

The documentation for this class was generated from the following file: