1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
// -*- related-file-name: "../../libefont/psres.cc" -*-
#ifndef EFONT_PSRES_HH
#define EFONT_PSRES_HH
#include <lcdf/vector.hh>
#include <lcdf/hashmap.hh>
#include <lcdf/string.hh>
#include <lcdf/filename.hh>
class Slurper;
namespace Efont {
class PsresDatabaseSection;
class PsresDatabase { public:
PsresDatabase();
~PsresDatabase();
void add_psres_path(const char* path, const char* defaults, bool override);
bool add_psres_file(Filename&, bool override);
void add_database(PsresDatabase*, bool override);
inline PsresDatabaseSection* section(PermString section) const;
const String& value(PermString section, PermString key) const;
const String& unescaped_value(PermString section, PermString key) const;
Filename filename_value(PermString section, PermString key) const;
private:
HashMap<PermString, int> _section_map;
Vector<PsresDatabaseSection*> _sections;
PsresDatabaseSection* force_section(PermString);
bool add_one_psres_file(Slurper&, bool override);
void add_psres_directory(PermString);
};
class PsresDatabaseSection { public:
PsresDatabaseSection(PermString);
PermString section_name() const { return _section_name; }
void add_psres_file_section(Slurper&, PermString, bool);
void add_section(PsresDatabaseSection*, bool override);
const String& value(PermString key) { return value(_map[key]); }
inline const String& unescaped_value(PermString key) const;
Filename filename_value(PermString key);
private:
PermString _section_name;
HashMap<PermString, int> _map;
Vector<PermString> _directories;
Vector<String> _values;
Vector<int> _value_escaped;
const String& value(int index);
};
inline PsresDatabaseSection* PsresDatabase::section(PermString n) const
{
return _sections[_section_map[n]];
}
inline const String& PsresDatabaseSection::unescaped_value(PermString key) const
{
assert(!_value_escaped[_map[key]]);
return _values[_map[key]];
}
}
#endif
|