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 
14 namespace srchilite {
15 
29 class 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 
43 public:
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
const std::string getMappedFileNameFromFileName(const std::string &fileName)
Tries to detect the corresponding lang file name, from the file name passed as parameter.
std::set< std::string > getLangNames() const
Returns a set (i.e., an ordered list) of all the lang names of this map.
std::string path
the path for searching for the map file name
Definition: langmap.h:38
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
std::set< std::string > getMappedFileNames() const
Returns a set (i.e., an ordered list) of all the mapped lang file names of this map.
bool isOpen
whether the corresponding file is opened
Definition: langmap.h:35
A map stored in a file with the format key = elem.
Definition: langmap.h:29
LangMap(const std::string &path, const std::string &filename)
A LangMap object based on the passed map file (using the specified path).
void open()
Open the corresponding file (if it is not already opened) and read and parse its contents.
void reload(const std::string &path, const std::string &filename)
Reloads the contents of this map, using the (new) path and filename.
void print()
Prints the contents on the map to the standard output.
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 filename
the map file name
Definition: langmap.h:41
const std::string getMappedFileName(const std::string &lang)
Returns the lang file name corresponding to the passed language name.