move sources to src directory
This commit is contained in:
1 parent
b5e4655f03
commit
24b4b48555
58 files changed
+7
-5
No files matched your search
@@ -0,0 +1,73 @@
|
||||
|
||||
#ifndef SCOPE_H
|
||||
#define SCOPE_H
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class Scope
|
||||
{
|
||||
public:
|
||||
Scope() { push(); }
|
||||
bool contains(const std::string & key)
|
||||
{
|
||||
for (m_list_type::const_reverse_iterator it = m_list.rbegin();
|
||||
it != m_list.rend();
|
||||
it++)
|
||||
{
|
||||
if (it->find(key) != it->end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
double get(const std::string & key)
|
||||
{
|
||||
for (m_list_type::reverse_iterator it = m_list.rbegin();
|
||||
it != m_list.rend();
|
||||
it++)
|
||||
{
|
||||
if (it->find(key) != it->end())
|
||||
{
|
||||
return (*it)[key];
|
||||
}
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
void putLocal(const std::string & key, double val)
|
||||
{
|
||||
(*m_list.rbegin())[key] = val;
|
||||
}
|
||||
void putGlobal(const std::string & key, double val)
|
||||
{
|
||||
for (m_list_type::reverse_iterator it = m_list.rbegin();
|
||||
it != m_list.rend();
|
||||
it++)
|
||||
{
|
||||
if (it->find(key) != it->end())
|
||||
{
|
||||
(*it)[key] = val;
|
||||
return;
|
||||
}
|
||||
}
|
||||
putLocal(key, val);
|
||||
}
|
||||
void push()
|
||||
{
|
||||
m_list.push_back(std::map< std::string, double >());
|
||||
}
|
||||
void pop()
|
||||
{
|
||||
if (m_list.size() > 1)
|
||||
{
|
||||
m_list.pop_back();
|
||||
}
|
||||
}
|
||||
protected:
|
||||
typedef std::list< std::map< std::string, double > > m_list_type;
|
||||
m_list_type m_list;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user