Source-highlight Library
langmap.h
1//
2// Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004
3//
4// Copyright: See COPYING file that comes with this distribution
5//
6//
7#ifndef LANGMAP_H
8#define LANGMAP_H
9
10#include <string>
11#include <map>
12#include <set>
13
14namespace srchilite {
15
29class LangMap {
30 typedef std::map<std::string, std::string> Map;
31
32 Map langmap;
33
35 bool isOpen;
36
38 std::string path;
39
41 std::string filename;
42
43public:
50 LangMap(const std::string &path, const std::string &filename);
51
57 LangMap(const std::string &filename);
58
59 ~LangMap();
60
61 typedef Map::const_iterator const_iterator;
62
63 const_iterator begin() {
64 return langmap.begin();
65 }
66
67 const_iterator end() {
68 return langmap.end();
69 }
70
75 void print();
76
83 void open();
84
96 const std::string getFileName(const std::string &lang) {
97 return langmap[lang];
98 }
99
111 const std::string getMappedFileName(const std::string &lang);
112
139 const std::string getMappedFileNameFromFileName(const std::string &fileName);
140
146 std::set<std::string> getLangNames() const;
147
153 std::set<std::string> getMappedFileNames() const;
154
161 void reload(const std::string &path, const std::string &filename);
162
163};
164
165}
166
167#endif
A map stored in a file with the format key = elem.
Definition: langmap.h:29
void reload(const std::string &path, const std::string &filename)
Reloads the contents of this map, using the (new) path and filename.
Definition: langmap.cpp:131
bool isOpen
whether the corresponding file is opened
Definition: langmap.h:35
std::set< std::string > getLangNames() const
Returns a set (i.e., an ordered list) of all the lang names of this map.
Definition: langmap.cpp:114
const std::string getFileName(const std::string &lang)
Returns the lang file name corresponding to the passed language name.
Definition: langmap.h:96
std::string path
the path for searching for the map file name
Definition: langmap.h:38
void open()
Open the corresponding file (if it is not already opened) and read and parse its contents.
Definition: langmap.cpp:46
void print()
Prints the contents on the map to the standard output.
Definition: langmap.cpp:109
const std::string getMappedFileName(const std::string &lang)
Returns the lang file name corresponding to the passed language name.
Definition: langmap.cpp:71
std::string filename
the map file name
Definition: langmap.h:41
const std::string getMappedFileNameFromFileName(const std::string &fileName)
Tries to detect the corresponding lang file name, from the file name passed as parameter.
Definition: langmap.cpp:78
LangMap(const std::string &path, const std::string &filename)
A LangMap object based on the passed map file (using the specified path).
Definition: langmap.cpp:35
std::set< std::string > getMappedFileNames() const
Returns a set (i.e., an ordered list) of all the mapped lang file names of this map.
Definition: langmap.cpp:122
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13