cgv
Loading...
Searching...
No Matches
cgv::ppp::ph_processor Class Reference

the pre header processor parses a pre header file and converts it to a header file or uses the information from parsing to transform a template file to a header file. More...

#include <ph_processor.h>

Public Member Functions

std::string find_include_file (const std::string &fn, bool local) const
 
 ph_processor (const std::string &_additional_include_path="", bool _search_recursive=false, char _special='@')
 
void swap_output (ph_processor &pp)
 
char get_special () const
 
void configure_insert_to_shader (std::vector< std::string > *_inserted_shader_file_names)
 
void set_error_stream (std::ostream &error_stream)
 
bool parse_string (const std::string &text)
 
bool parse_file (const std::string &file_name)
 
bool process_to_string (std::string &output)
 
int process_to_file (const std::string &_file_name, long long last_write_time=0)
 
bool process_without_output ()
 
void close ()
 

Static Public Member Functions

static std::string my_getenv (const char *name)
 

Public Attributes

int exit_code
 

Protected Types

enum  ReflectionParenthesis { RP_COMPOUND , RP_NAMESPACE }
 

Protected Member Functions

unsigned int get_line_number (const token &loc) const
 
void error (const std::string &text, const token &loc, unsigned int error_number=0)
 
bool check_evaluation_error (unsigned int i, unsigned int ei)
 
bool process (unsigned int i, unsigned int j)
 
bool parse ()
 
bool parse_without_special (unsigned nr_skip=0)
 
bool process_include (unsigned int i, bool is_cinclude=false, bool insert=false)
 
bool process_list (unsigned int i)
 
variant construct_namespace_list () const
 
std::string construct_namespace_sequence () const
 
void ensure_reflect_info ()
 
bool reflect (const token &code, const token &comment)
 
bool recursive_dir (std::string rel_directory, std::string actual_directory, std::string filter, bool rel_path, variant &desc_list, bool recursive)
 

Protected Attributes

bool found_error
 
unsigned nr_functions
 
char special
 
bool generate_output
 
bool content_is_external
 
std::ostream * os
 
std::ostream * es
 
const std::string * content
 
std::string file_name
 
std::vector< cgv::utils::linelines
 
std::vector< command_tokencommands
 
int recursion_depth
 
std::vector< std::string > * inserted_shader_file_names
 
bool debug_reflection
 
variantreflect_info
 
std::vector< ReflectionParenthesis > rp_stack
 
std::vector< std::string > namespace_stack
 
std::vector< variant * > compound_stack
 
std::vector< std::string > compound_access_type_stack
 
std::string additional_include_path
 
bool search_recursive
 

Friends

class expression_processor
 

Detailed Description

the pre header processor parses a pre header file and converts it to a header file or uses the information from parsing to transform a template file to a header file.

Support for type reflection:

< ... generates type reflection info from the code on this line before the < token > ... generates type reflection info starting with the code on the next line up to and not including the next ; or { symbol

the to be reflected code is parsed and the following code fragments detected:

#include ... adds an include to the list of include files namespace name ... enters the given namespace class / struct / union name ... begins a compound definition protected / private / public : ... switches the member access type type name ... declares a member typedef type name ... declares a type inside or outside a class definition type name(parameter list) [const] ... declares a method } ... leaves a namespace or ends a compound definition

the extracted information is stored in the variable reflect_info in the following structure of nested lists:

reflect_info = {includes:[string], typedefs:[typedef], enums:[enum], compounds:[compound], variables:[variable], functions:[function] } typedef = {namespaces:[string], namespace_prefix:string, name:string, type:string, comment:string} enum = {namespaces:[string], namespace_prefix:string, name:string, entries:[enum_entries], comment:string} enum_entry = {name:string, value:int, comment:string} compound = {namespaces:[string], namespace_prefix:string, type_name:string, typedefs:[typedef], enums:[enum], compounds:[compound], members:[member], methods:[method] bases:[base], kind:string [class|struct|union], comment:string} base = {type_name:string, is_virtual:bool, access_type:string [private,protected,public] } member = {name:string, type:string, access_type:string [private,protected,public], is_static:bool, comment:string} method = {name:string, type:string, -> return type) parameters:[parameter], access_type:string [private,protected,public] is_virtual:bool, is_const:bool, comment:string} variable = {namespaces:[string], namespace_prefix:string, name:string, type:string, comment:string} function = [namespaces:[string], namespace_prefix:string, name:string, type:string, parameters:[parameter], comment:string] parameter = {name:string, type:string, has_default_value:bool, default_value:string}

Definition at line 100 of file ph_processor.h.

Member Enumeration Documentation

◆ ReflectionParenthesis

enum cgv::ppp::ph_processor::ReflectionParenthesis
protected

Definition at line 137 of file ph_processor.h.

Constructor & Destructor Documentation

◆ ph_processor()

cgv::ppp::ph_processor::ph_processor ( const std::string &  _additional_include_path = "",
bool  _search_recursive = false,
char  _special = '@' 
)

Definition at line 23 of file ph_processor.cxx.

◆ ~ph_processor()

cgv::ppp::ph_processor::~ph_processor ( )

Definition at line 43 of file ph_processor.cxx.

Member Function Documentation

◆ check_evaluation_error()

bool cgv::ppp::ph_processor::check_evaluation_error ( unsigned int  i,
unsigned int  ei 
)
protected

Definition at line 342 of file ph_processor.cxx.

◆ close()

void cgv::ppp::ph_processor::close ( )

Definition at line 53 of file ph_processor.cxx.

◆ configure_insert_to_shader()

void cgv::ppp::ph_processor::configure_insert_to_shader ( std::vector< std::string > *  _inserted_shader_file_names)

Definition at line 48 of file ph_processor.cxx.

◆ construct_namespace_list()

variant cgv::ppp::ph_processor::construct_namespace_list ( ) const
protected

Definition at line 493 of file ph_processor.cxx.

◆ construct_namespace_sequence()

std::string cgv::ppp::ph_processor::construct_namespace_sequence ( ) const
protected

Definition at line 503 of file ph_processor.cxx.

◆ ensure_reflect_info()

void cgv::ppp::ph_processor::ensure_reflect_info ( )
protected

Definition at line 475 of file ph_processor.cxx.

◆ error()

void cgv::ppp::ph_processor::error ( const std::string &  text,
const token loc,
unsigned int  error_number = 0 
)
protected

Definition at line 211 of file ph_processor.cxx.

◆ find_include_file()

std::string cgv::ppp::ph_processor::find_include_file ( const std::string &  fn,
bool  local 
) const

Definition at line 259 of file ph_processor.cxx.

◆ get_line_number()

unsigned int cgv::ppp::ph_processor::get_line_number ( const token loc) const
protected

Definition at line 202 of file ph_processor.cxx.

◆ get_special()

char cgv::ppp::ph_processor::get_special ( ) const
inline

Definition at line 157 of file ph_processor.h.

◆ my_getenv()

std::string cgv::ppp::ph_processor::my_getenv ( const char *  name)
static

Definition at line 236 of file ph_processor.cxx.

◆ parse()

bool cgv::ppp::ph_processor::parse ( )
protected

Definition at line 1840 of file ph_processor.cxx.

◆ parse_file()

bool cgv::ppp::ph_processor::parse_file ( const std::string &  file_name)

Definition at line 70 of file ph_processor.cxx.

◆ parse_string()

bool cgv::ppp::ph_processor::parse_string ( const std::string &  text)

Definition at line 62 of file ph_processor.cxx.

◆ parse_without_special()

bool cgv::ppp::ph_processor::parse_without_special ( unsigned  nr_skip = 0)
protected

Definition at line 1935 of file ph_processor.cxx.

◆ process()

bool cgv::ppp::ph_processor::process ( unsigned int  i,
unsigned int  j 
)
protected

Definition at line 1160 of file ph_processor.cxx.

◆ process_include()

bool cgv::ppp::ph_processor::process_include ( unsigned int  i,
bool  is_cinclude = false,
bool  insert = false 
)
protected

Definition at line 289 of file ph_processor.cxx.

◆ process_list()

bool cgv::ppp::ph_processor::process_list ( unsigned int  i)
protected

Definition at line 379 of file ph_processor.cxx.

◆ process_to_file()

int cgv::ppp::ph_processor::process_to_file ( const std::string &  _file_name,
long long  last_write_time = 0 
)

Definition at line 150 of file ph_processor.cxx.

◆ process_to_string()

bool cgv::ppp::ph_processor::process_to_string ( std::string &  output)

Definition at line 133 of file ph_processor.cxx.

◆ process_without_output()

bool cgv::ppp::ph_processor::process_without_output ( )

Definition at line 114 of file ph_processor.cxx.

◆ recursive_dir()

bool cgv::ppp::ph_processor::recursive_dir ( std::string  rel_directory,
std::string  actual_directory,
std::string  filter,
bool  rel_path,
variant desc_list,
bool  recursive 
)
protected

Definition at line 1761 of file ph_processor.cxx.

◆ reflect()

bool cgv::ppp::ph_processor::reflect ( const token code,
const token comment 
)
protected

Definition at line 514 of file ph_processor.cxx.

◆ set_error_stream()

void cgv::ppp::ph_processor::set_error_stream ( std::ostream &  error_stream)

Definition at line 197 of file ph_processor.cxx.

◆ swap_output()

void cgv::ppp::ph_processor::swap_output ( ph_processor pp)

Definition at line 127 of file ph_processor.cxx.

Friends And Related Symbol Documentation

◆ expression_processor

friend class expression_processor
friend

Definition at line 105 of file ph_processor.h.

Member Data Documentation

◆ additional_include_path

std::string cgv::ppp::ph_processor::additional_include_path
protected

Definition at line 150 of file ph_processor.h.

◆ commands

std::vector<command_token> cgv::ppp::ph_processor::commands
protected

Definition at line 116 of file ph_processor.h.

◆ compound_access_type_stack

std::vector<std::string> cgv::ppp::ph_processor::compound_access_type_stack
protected

Definition at line 141 of file ph_processor.h.

◆ compound_stack

std::vector<variant*> cgv::ppp::ph_processor::compound_stack
protected

Definition at line 140 of file ph_processor.h.

◆ content

const std::string* cgv::ppp::ph_processor::content
protected

Definition at line 113 of file ph_processor.h.

◆ content_is_external

bool cgv::ppp::ph_processor::content_is_external
protected

Definition at line 110 of file ph_processor.h.

◆ debug_reflection

bool cgv::ppp::ph_processor::debug_reflection
protected

Definition at line 135 of file ph_processor.h.

◆ es

std::ostream* cgv::ppp::ph_processor::es
protected

Definition at line 112 of file ph_processor.h.

◆ exit_code

int cgv::ppp::ph_processor::exit_code

Definition at line 155 of file ph_processor.h.

◆ file_name

std::string cgv::ppp::ph_processor::file_name
protected

Definition at line 114 of file ph_processor.h.

◆ found_error

bool cgv::ppp::ph_processor::found_error
protected

Definition at line 106 of file ph_processor.h.

◆ generate_output

bool cgv::ppp::ph_processor::generate_output
protected

Definition at line 109 of file ph_processor.h.

◆ inserted_shader_file_names

std::vector<std::string>* cgv::ppp::ph_processor::inserted_shader_file_names
protected

Definition at line 119 of file ph_processor.h.

◆ lines

std::vector<cgv::utils::line> cgv::ppp::ph_processor::lines
protected

Definition at line 115 of file ph_processor.h.

◆ namespace_stack

std::vector<std::string> cgv::ppp::ph_processor::namespace_stack
protected

Definition at line 139 of file ph_processor.h.

◆ nr_functions

unsigned cgv::ppp::ph_processor::nr_functions
protected

Definition at line 107 of file ph_processor.h.

◆ os

std::ostream* cgv::ppp::ph_processor::os
protected

Definition at line 111 of file ph_processor.h.

◆ recursion_depth

int cgv::ppp::ph_processor::recursion_depth
protected

Definition at line 117 of file ph_processor.h.

◆ reflect_info

variant* cgv::ppp::ph_processor::reflect_info
protected

Definition at line 136 of file ph_processor.h.

◆ rp_stack

std::vector<ReflectionParenthesis> cgv::ppp::ph_processor::rp_stack
protected

Definition at line 138 of file ph_processor.h.

◆ search_recursive

bool cgv::ppp::ph_processor::search_recursive
protected

Definition at line 151 of file ph_processor.h.

◆ special

char cgv::ppp::ph_processor::special
protected

Definition at line 108 of file ph_processor.h.


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