0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
clanguml::common::model::source_file Class Reference

Diagram element representing some file or directory. More...

Detailed Description

Diagram element representing some file or directory.

Definition at line 63 of file source_file.h.

#include <source_file.h>

Public Member Functions

 source_file ()=default
 
 source_file (const std::filesystem::path &p)
 
 source_file (const source_file &)=delete
 
 source_file (source_file &&)=default
 
source_fileoperator= (const source_file &)=delete
 
source_fileoperator= (source_file &&)=delete
 
bool operator== (const source_file &right) const
 
void set_path (const filesystem_path &p)
 
bool is_absolute () const
 
void set_type (source_file_t type)
 
source_file_t type () const
 
void set_system_header (bool is_system)
 
bool is_system_header () const
 
const filesystem_pathpath () const
 
std::string full_name (bool) const override
 
auto full_path () const
 
std::filesystem::path fs_path (const std::filesystem::path &base={}) const
 
inja::json context () const override
 
- Public Member Functions inherited from clanguml::common::model::diagram_element
 diagram_element ()
 
 ~diagram_element () override=default
 
const eid_tid () const
 Returns diagram element id.
 
void set_id (eid_t id)
 
std::optional< eid_tparent_element_id () const
 
void set_parent_element_id (eid_t id)
 
virtual std::string alias () const
 Return elements' diagram alias.
 
void set_name (const std::string &name)
 
std::string name () const
 
virtual std::string type_name () const
 
virtual std::string full_name (bool) const
 Return the elements fully qualified name.
 
std::vector< relationship > & relationships ()
 
const std::vector< relationship > & relationships () const
 
void add_relationship (relationship &&cr)
 
void append (const decorated_element &e)
 
virtual inja::json context () const
 
bool is_nested () const
 
void nested (bool nested)
 
bool complete () const
 
void complete (bool completed)
 
virtual void apply_filter (const diagram_filter &filter, const std::set< eid_t > &removed)
 
- Public Member Functions inherited from clanguml::common::model::decorated_element
virtual ~decorated_element ()=default
 
bool skip () const
 
bool skip_relationship () const
 
std::pair< relationship_t, std::string > get_relationship () const
 
std::string style_spec () const
 
const std::vector< std::shared_ptr< decorators::decorator > > & decorators () const
 
void add_decorators (const std::vector< std::shared_ptr< decorators::decorator > > &decorators)
 
void append (const decorated_element &de)
 
std::optional< comment_tcomment () const
 
void set_comment (const comment_t &c)
 
virtual std::optional< std::string > doxygen_link () const
 
- Public Member Functions inherited from clanguml::common::model::source_location
 source_location ()=default
 
 source_location (std::string f, unsigned int l)
 
const std::string & file () const
 
void set_file (const std::string &file)
 
const std::string & file_relative () const
 
void set_file_relative (const std::string &file)
 
const std::string & translation_unit () const
 
void set_translation_unit (const std::string &translation_unit)
 
unsigned int line () const
 
void set_line (const unsigned line)
 
unsigned int column () const
 
void set_column (const unsigned column)
 
unsigned int location_id () const
 
void set_location_id (unsigned int h)
 
- Public Member Functions inherited from clanguml::common::model::stylable_element
void set_style (const std::string &style)
 
std::optional< std::string > style () const
 
- Public Member Functions inherited from clanguml::common::model::nested_trait< common::model::source_file, filesystem_path >
 nested_trait ()=default
 
 nested_trait (const nested_trait &)=delete
 
 nested_trait (nested_trait &&) noexcept=default
 
nested_traitoperator= (const nested_trait &)=delete
 
nested_traitoperator= (nested_trait &&) noexcept=default
 
virtual ~nested_trait ()=default
 
bool add_element (std::unique_ptr< V > p)
 
bool add_element (const filesystem_path &path, std::unique_ptr< V > p)
 
auto get_element (const filesystem_path &path) const
 
auto get_element (const std::string &name) const
 
bool has_element (const std::string &name) const
 
bool all_of (F &&f) const
 
bool is_empty () const
 
auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 
auto cbegin () const
 
auto cend () const
 
void print_tree (const int level)
 
void remove (const std::set< eid_t > &element_ids)
 

Private Attributes

filesystem_path path_ {path_type::kFilesystem}
 
source_file_t type_ {source_file_t::kDirectory}
 
bool is_absolute_ {false}
 
bool is_system_header_ {false}
 

Constructor & Destructor Documentation

◆ source_file() [1/4]

clanguml::common::model::source_file::source_file ( )
default

◆ source_file() [2/4]

clanguml::common::model::source_file::source_file ( const std::filesystem::path &  p)
inlineexplicit

Definition at line 71 of file source_file.h.

72 {
73 auto preferred = p;
74 preferred.make_preferred();
75 set_path({preferred.parent_path().string(), path_type::kFilesystem});
76 set_name(preferred.filename().string());
77 is_absolute_ = preferred.is_absolute();
78 set_id(common::to_id(preferred));
79 }

◆ source_file() [3/4]

clanguml::common::model::source_file::source_file ( const source_file )
delete

◆ source_file() [4/4]

clanguml::common::model::source_file::source_file ( source_file &&  )
default

Member Function Documentation

◆ context()

inja::json clanguml::common::model::source_file::context ( ) const
inlineoverridevirtual

Return inja context for this element.

Returns
Inja context.

Reimplemented from clanguml::common::model::diagram_element.

Definition at line 187 of file source_file.h.

188 {
189 inja::json ctx = diagram_element::context();
190
191 std::filesystem::path fullNamePath{ctx["full_name"].get<std::string>()};
192 fullNamePath.make_preferred();
193 ctx["full_name"] = fullNamePath.string();
194
195 return ctx;
196 }

◆ fs_path()

std::filesystem::path clanguml::common::model::source_file::fs_path ( const std::filesystem::path &  base = {}) const
inline

Convert the source file path to std::filesystem::path, relative to base

Parameters
baseBase path
Returns
Filesystem path to the source file.

Definition at line 164 of file source_file.h.

164 {}) const
165 {
166 std::filesystem::path res;
167
168 for (const auto &path_element : path_) {
169 res /= path_element;
170 }
171
172 res /= name();
173
174 if (is_absolute_)
175 res = fs_path_sep::value / res;
176 else
177 res = base / res;
178
179 return res.lexically_normal();
180 }

◆ full_name()

std::string clanguml::common::model::source_file::full_name ( bool  ) const
inlineoverridevirtual

Return the full path string, i.e. parent path and elements name.

Returns
Full source file path as string.

Reimplemented from clanguml::common::model::diagram_element.

Definition at line 146 of file source_file.h.

147 {
148 return (path_ | name()).to_string();
149 }

◆ full_path()

auto clanguml::common::model::source_file::full_path ( ) const
inline

Return full path, i.e. parent path and elements name.

Returns
Full source file path.

Definition at line 156 of file source_file.h.

156{ return path() | name(); }

◆ is_absolute()

bool clanguml::common::model::source_file::is_absolute ( ) const
inline

Is the elements path absolute?

Returns
True if the elements path is absolute.

Definition at line 104 of file source_file.h.

104{ return is_absolute_; }

◆ is_system_header()

bool clanguml::common::model::source_file::is_system_header ( ) const
inline

Is the file a system header?

Returns
True, if the source file is a system header

Definition at line 132 of file source_file.h.

132{ return is_system_header_; }

◆ operator=() [1/2]

source_file & clanguml::common::model::source_file::operator= ( const source_file )
delete

◆ operator=() [2/2]

source_file & clanguml::common::model::source_file::operator= ( source_file &&  )
delete

◆ operator==()

bool clanguml::common::model::source_file::operator== ( const source_file right) const
inline

Definition at line 86 of file source_file.h.

87 {
88 return (path_ == right.path_) && (name() == right.name()) &&
89 (type_ == right.type_);
90 }

◆ path()

const filesystem_path & clanguml::common::model::source_file::path ( ) const
inline

Get the source file's parent path.

Returns
Source file parent path.

Definition at line 139 of file source_file.h.

139{ return path_; }

◆ set_path()

void clanguml::common::model::source_file::set_path ( const filesystem_path p)
inline

Set the path to the element in the diagram.

Parameters
pDiagram path.

Definition at line 97 of file source_file.h.

97{ path_ = p; }

◆ set_system_header()

void clanguml::common::model::source_file::set_system_header ( bool  is_system)
inline

Set whether the file is a system header

Parameters
is_systemWhether the file is a system header

Definition at line 125 of file source_file.h.

125{ is_system_header_ = is_system; }

◆ set_type()

void clanguml::common::model::source_file::set_type ( source_file_t  type)
inline

Set the type of the source file.

Parameters
typeType of the source file.

Definition at line 111 of file source_file.h.

111{ type_ = type; }

◆ type()

source_file_t clanguml::common::model::source_file::type ( ) const
inline

Get the source file elements type.

Returns
Type of the source file.

Definition at line 118 of file source_file.h.

118{ return type_; }

Member Data Documentation

◆ is_absolute_

bool clanguml::common::model::source_file::is_absolute_ {false}
private

Definition at line 201 of file source_file.h.

◆ is_system_header_

bool clanguml::common::model::source_file::is_system_header_ {false}
private

Definition at line 202 of file source_file.h.

◆ path_

filesystem_path clanguml::common::model::source_file::path_ {path_type::kFilesystem}
private

Definition at line 199 of file source_file.h.

◆ type_

source_file_t clanguml::common::model::source_file::type_ {source_file_t::kDirectory}
private

Definition at line 200 of file source_file.h.


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