Add const qualifier to some functions

The `Function::call()` second argument is now qualified as `const`,
this makes the function usable even if the Function* is const.

The function `TokenMap::find()` now has a const version that
return a `const packToken*`.
This commit is contained in:
Vinícius Garcia
2017-05-12 21:25:31 -03:00
parent be451335d5
commit a077e73615
4 changed files with 19 additions and 6 deletions

View File

@@ -110,7 +110,7 @@ MapData_t& MapData_t::operator=(const MapData_t& other) {
/* * * * * TokenMap Class: * * * * */
packToken* TokenMap::find(std::string key) {
packToken* TokenMap::find(const std::string& key) {
TokenMap_t::iterator it = map().find(key);
if (it != map().end()) {
@@ -122,7 +122,19 @@ packToken* TokenMap::find(std::string key) {
}
}
TokenMap* TokenMap::findMap(std::string key) {
const packToken* TokenMap::find(const std::string& key) const {
TokenMap_t::const_iterator it = map().find(key);
if (it != map().end()) {
return &it->second;
} else if (parent()) {
return parent()->find(key);
} else {
return 0;
}
}
TokenMap* TokenMap::findMap(const std::string& key) {
TokenMap_t::iterator it = map().find(key);
if (it != map().end()) {