ReactOS  0.4.15-dev-4917-g934e521
hhp_reader Class Reference

#include <hhp_reader.h>

Collaboration diagram for hhp_reader:

Public Member Functions

 hhp_reader (string filename)
 
 ~hhp_reader ()
 
string get_title_string ()
 
string get_contents_file_string ()
 
string get_index_file_string ()
 
string get_default_topic_string ()
 
unsigned int get_language_code ()
 
string get_compiled_file_string ()
 
set< string >::iterator get_file_pathes_iterator_begin ()
 
set< string >::iterator get_file_pathes_iterator_end ()
 

Private Member Functions

void add_section (hhp_section *section)
 
void read ()
 
void compute_unique_file_pathes_set ()
 

Private Attributes

string filename
 
map< string, hhp_section * > sections
 
hhp_options_sectionoptions
 
hhp_files_sectionfiles
 
set< stringunique_file_pathes
 

Detailed Description

Definition at line 109 of file hhp_reader.h.

Constructor & Destructor Documentation

◆ hhp_reader()

hhp_reader::hhp_reader ( string  filename)

Definition at line 152 of file hhp_reader.cpp.

153 {
154  this->filename = filename;
155 
158  files = new hhp_files_section();
160 
161  read();
163 }
void add_section(hhp_section *section)
Definition: hhp_reader.cpp:171
const char * filename
Definition: ioapi.h:135
void read()
Definition: hhp_reader.cpp:179
void compute_unique_file_pathes_set()
Definition: hhp_reader.cpp:216
string filename
Definition: hhp_reader.h:112
hhp_files_section * files
Definition: hhp_reader.h:115

◆ ~hhp_reader()

hhp_reader::~hhp_reader ( )

Definition at line 165 of file hhp_reader.cpp.

166 {
167  delete options;
168  delete files;
169 }
hhp_options_section * options
Definition: hhp_reader.h:114
hhp_files_section * files
Definition: hhp_reader.h:115

Member Function Documentation

◆ add_section()

void hhp_reader::add_section ( hhp_section section)
private

Definition at line 171 of file hhp_reader.cpp.

172 {
173  string upper_case_name = to_upper(section->get_name());
174  if (sections.count(upper_case_name) != 0)
175  throw logic_error("trying to redundantly add section '" + upper_case_name + "'");
176  sections.insert(pair<string, hhp_section*>(upper_case_name, section));
177 }
Definition: parser.c:55
string to_upper(string s)
Definition: utils.cpp:36
map< string, hhp_section * > sections
Definition: hhp_reader.h:113
Definition: _pair.h:47

◆ compute_unique_file_pathes_set()

void hhp_reader::compute_unique_file_pathes_set ( )
private

Definition at line 216 of file hhp_reader.cpp.

217 {
218  for (list<string>::iterator it = files->filenames.begin(); it != files->filenames.end(); ++it)
219  {
220  unique_file_pathes.insert(replace_backslashes(real_path(it->c_str())));
221  }
222 }
string real_path(const char *path)
Definition: utils.cpp:43
string replace_backslashes(string s)
Definition: utils.cpp:63
set< string > unique_file_pathes
Definition: hhp_reader.h:116
_STLP_PRIV _List_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition: _list.h:275
hhp_files_section * files
Definition: hhp_reader.h:115
list< string > filenames
Definition: hhp_reader.h:102

◆ get_compiled_file_string()

string hhp_reader::get_compiled_file_string ( )

Definition at line 249 of file hhp_reader.cpp.

250 {
251  return options->compiled_file->get_value();
252 }

Referenced by main().

◆ get_contents_file_string()

string hhp_reader::get_contents_file_string ( )

Definition at line 229 of file hhp_reader.cpp.

230 {
231  return options->contents_file->get_value();
232 }

Referenced by main().

◆ get_default_topic_string()

string hhp_reader::get_default_topic_string ( )

Definition at line 239 of file hhp_reader.cpp.

240 {
241  return options->default_topic->get_value();
242 }

Referenced by main().

◆ get_file_pathes_iterator_begin()

set< string >::iterator hhp_reader::get_file_pathes_iterator_begin ( )

Definition at line 254 of file hhp_reader.cpp.

255 {
256  return unique_file_pathes.begin();
257 }
set< string > unique_file_pathes
Definition: hhp_reader.h:116

Referenced by main().

◆ get_file_pathes_iterator_end()

set< string >::iterator hhp_reader::get_file_pathes_iterator_end ( )

Definition at line 259 of file hhp_reader.cpp.

260 {
261  return unique_file_pathes.end();
262 }
set< string > unique_file_pathes
Definition: hhp_reader.h:116

Referenced by main().

◆ get_index_file_string()

string hhp_reader::get_index_file_string ( )

Definition at line 234 of file hhp_reader.cpp.

235 {
236  return options->index_file->get_value();
237 }

Referenced by main().

◆ get_language_code()

unsigned int hhp_reader::get_language_code ( )

Definition at line 244 of file hhp_reader.cpp.

245 {
246  return strtoul(options->language->get_value().c_str(), NULL, 0);
247 }
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
#define NULL
Definition: types.h:112

Referenced by main().

◆ get_title_string()

string hhp_reader::get_title_string ( )

Definition at line 224 of file hhp_reader.cpp.

225 {
226  return options->title->get_value();
227 }

Referenced by main().

◆ read()

void hhp_reader::read ( )
private

Definition at line 179 of file hhp_reader.cpp.

180 {
181  ifstream hhp_file;
182  hhp_file.open(filename.c_str());
183 
184  string line;
185  int line_number = 0;
187  while (hhp_file.good())
188  {
189  getline(hhp_file, line);
190  line_number++;
191  if (line[line.length() - 1] == '\015') // delete CR character if present
192  line = line.substr(0, line.length() - 1);
193  if (line[0] == '[' && line[line.length() - 1] == ']')
194  {
195  string name = to_upper(line.substr(1, line.length() - 2));
196  if (sections.count(name))
197  {
198  section = sections.find(name)->second;
199  clog << section->get_name() << endl;
200  }
201  else
202  {
203  clog << "unknown section: " << name << endl;
204  }
205  }
206  else if (line[0] != ';' && !line.empty())
207  {
208  if (section)
209  section->process_line(line);
210  }
211  }
212 
213  hhp_file.close();
214 }
Definition: parser.c:55
const char * filename
Definition: ioapi.h:135
string to_upper(string s)
Definition: utils.cpp:36
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
basic_ifstream< char, char_traits< char > > ifstream
Definition: _iosfwd.h:131
Definition: parser.c:48
map< string, hhp_section * > sections
Definition: hhp_reader.h:113
#define clog
Definition: iostream.cpp:40
IN PCTCH line
Definition: pager.h:36
static long line_number
Definition: main.cpp:16
#define NULL
Definition: types.h:112
Definition: name.c:38
#define getline
Definition: schily.h:567

Member Data Documentation

◆ filename

string hhp_reader::filename
private

Definition at line 112 of file hhp_reader.h.

◆ files

hhp_files_section* hhp_reader::files
private

Definition at line 115 of file hhp_reader.h.

◆ options

hhp_options_section* hhp_reader::options
private

Definition at line 114 of file hhp_reader.h.

◆ sections

map<string, hhp_section*> hhp_reader::sections
private

Definition at line 113 of file hhp_reader.h.

◆ unique_file_pathes

set<string> hhp_reader::unique_file_pathes
private

Definition at line 116 of file hhp_reader.h.


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