Source-highlight Library
|
A map stored in a file with the format key = elem. More...
#include <langmap.h>
Public Types | |
typedef Map::const_iterator | const_iterator |
Public Member Functions | |
LangMap (const std::string &path, const std::string &filename) | |
A LangMap object based on the passed map file (using the specified path). More... | |
LangMap (const std::string &filename) | |
A LangMap object based on the passed map file (using the path stored in the settings or the default hardcoded one). More... | |
const_iterator | begin () |
const_iterator | end () |
void | print () |
Prints the contents on the map to the standard output. More... | |
void | open () |
Open the corresponding file (if it is not already opened) and read and parse its contents. More... | |
const std::string | getFileName (const std::string &lang) |
Returns the lang file name corresponding to the passed language name. More... | |
const std::string | getMappedFileName (const std::string &lang) |
Returns the lang file name corresponding to the passed language name. More... | |
const std::string | getMappedFileNameFromFileName (const std::string &fileName) |
Tries to detect the corresponding lang file name, from the file name passed as parameter. More... | |
std::set< std::string > | getLangNames () const |
Returns a set (i.e., an ordered list) of all the lang names of this map. More... | |
std::set< std::string > | getMappedFileNames () const |
Returns a set (i.e., an ordered list) of all the mapped lang file names of this map. More... | |
void | reload (const std::string &path, const std::string &filename) |
Reloads the contents of this map, using the (new) path and filename. More... | |
Private Types | |
typedef std::map< std::string, std::string > | Map |
Private Attributes | |
Map | langmap |
bool | isOpen |
whether the corresponding file is opened | |
std::string | path |
the path for searching for the map file name | |
std::string | filename |
the map file name | |
A map stored in a file with the format key = elem.
Comment line start with a #
This is used for lang.map, outlang.map and style.defaults (and for any other files that have this simple syntax).
Methods of this class can throw ParserException if they can't parse the map file because of a syntax error.
srchilite::LangMap::LangMap | ( | const std::string & | path, |
const std::string & | filename | ||
) |
A LangMap object based on the passed map file (using the specified path).
path | the path where to search for the filename |
filename | the map file |
srchilite::LangMap::LangMap | ( | const std::string & | filename | ) |
A LangMap object based on the passed map file (using the path stored in the settings or the default hardcoded one).
filename | the map file |
|
inline |
Returns the lang file name corresponding to the passed language name.
The lang map file must have already been opened (if you want to be sure of that, use getMappedFileName instead).
lang | the language name whose lang definition file name we want to retrieve |
set< string > srchilite::LangMap::getLangNames | ( | ) | const |
Returns a set (i.e., an ordered list) of all the lang names of this map.
const std::string srchilite::LangMap::getMappedFileName | ( | const std::string & | lang | ) |
Returns the lang file name corresponding to the passed language name.
The lang map file is opened and parsed if it has not been inspected yet.
lang | the language name whose lang definition file name we want to retrieve |
ParserException | in case the lang map file is not correct. |
const std::string srchilite::LangMap::getMappedFileNameFromFileName | ( | const std::string & | fileName | ) |
Tries to detect the corresponding lang file name, from the file name passed as parameter.
In order to do so it proceeds as follows (until it succeeds):
This is useful, e.g., for highlighting a file using its file name for detecting its source language. Similarly, for choosing the output format by using the name of the output file.
This method opens the lang map file if it hasn't been parsed yet.
fileName | the language name whose lang definition file name we want to retrieve |
ParserException | in case the lang map file is not correct. |
std::set< std::string > srchilite::LangMap::getMappedFileNames | ( | ) | const |
Returns a set (i.e., an ordered list) of all the mapped lang file names of this map.
void srchilite::LangMap::open | ( | ) |
Open the corresponding file (if it is not already opened) and read and parse its contents.
If the map file has been already opened (and parsed) this does nothing.
ParserException | in case the lang map file is not correct. |
void srchilite::LangMap::print | ( | ) |
Prints the contents on the map to the standard output.
This is basically for testing purposes.
void srchilite::LangMap::reload | ( | const std::string & | path, |
const std::string & | filename | ||
) |
Reloads the contents of this map, using the (new) path and filename.
path | the path where to search for the filename |
filename | the map file |