cgv
Loading...
Searching...
No Matches
ph_processor.h
1#pragma once
2
3#include <string>
4#include <vector>
5#include <fstream>
6#include "variables.h"
7#include "command_token.h"
9
10#include "lib_begin.h"
11
12namespace cgv {
13 namespace ppp {
100 class CGV_API ph_processor
101 {
102 using token = cgv::utils::token;
103
104 protected:
105 friend class expression_processor;
106 bool found_error;
107 unsigned nr_functions;
108 char special;
109 bool generate_output;
110 bool content_is_external;
111 std::ostream* os;
112 std::ostream* es;
113 const std::string* content;
114 std::string file_name;
115 std::vector<cgv::utils::line> lines;
116 std::vector<command_token> commands;
117 int recursion_depth;
118
119 std::vector<std::string>* inserted_shader_file_names;
120
121 unsigned int get_line_number(const token& loc) const;
122 void error(const std::string& text, const token& loc, unsigned int error_number = 0);
123 bool check_evaluation_error(unsigned int i, unsigned int ei);
124
125 bool process(unsigned int i, unsigned int j);
126 bool parse();
127 bool parse_without_special(unsigned nr_skip = 0);
128 public:
129 static std::string my_getenv(const char* name);
130 std::string find_include_file(const std::string& fn, bool local) const;
131 protected:
132 bool process_include(unsigned int i, bool is_cinclude = false, bool insert = false);
133 bool process_list(unsigned int i);
134
135 bool debug_reflection;
136 variant* reflect_info;
137 enum ReflectionParenthesis { RP_COMPOUND, RP_NAMESPACE };
138 std::vector<ReflectionParenthesis> rp_stack;
139 std::vector<std::string> namespace_stack;
140 std::vector<variant*> compound_stack;
141 std::vector<std::string> compound_access_type_stack;
142 variant construct_namespace_list() const;
143 std::string construct_namespace_sequence() const;
144 void ensure_reflect_info();
145 bool reflect(const token& code, const token& comment);
146
147 bool recursive_dir(std::string rel_directory,
148 std::string actual_directory, std::string filter,
149 bool rel_path, variant& desc_list, bool recursive);
150 std::string additional_include_path;
151 bool search_recursive;
152 public:
153 ph_processor(const std::string& _additional_include_path = "", bool _search_recursive = false, char _special = '@');
155 int exit_code;
156 void swap_output(ph_processor& pp);
157 char get_special() const { return special; }
158 void configure_insert_to_shader(std::vector<std::string>* _inserted_shader_file_names);
159
160
161 void set_error_stream(std::ostream& error_stream);
162
163 bool parse_string(const std::string& text);
164 bool parse_file(const std::string& file_name);
165
166 bool process_to_string(std::string& output);
167 int process_to_file(const std::string& _file_name, long long last_write_time = 0);
168 bool process_without_output();
169 /*
170 enum ProcessingOptions {
171
172 int process_input_to_string(const std::string& inp_file, std::string& output, int processing_options);
173 int process_input_to_file(const std::string& inp_file, const std::string& out_file, int processing_options, );
174 */
175 void close();
176 };
177
178 }
179}
180#include <cgv/config/lib_end.h>
More advanced text processing for splitting text into lines or tokens.
the pre header processor parses a pre header file and converts it to a header file or uses the inform...
the cgv namespace
Definition print.h:11
representation of a token in a text by two pointers begin and end, that point to the first character ...
Definition token.h:18