Skip to content
Snippets Groups Projects
Commit 0c5f4dad authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

New command dv to display list of defined variables

parent b1f0ee3d
No related branches found
No related tags found
No related merge requests found
- New command dv to display list of defined variables
- Experimental code for 2d plots
Release 2.3.6b of 14mar17:
- Replaced experimental/filesystem by boost/filesystem for compilation under gcc4.8
......
......@@ -39,6 +39,7 @@
#include "reduce_spec.hpp"
#include "rssm.hpp"
#include "special.hpp"
#include "variables.hpp"
#include "commands.hpp"
......@@ -211,28 +212,31 @@ bool frida_command(string cmd)
} else if (cmd == "d") {
cout << "Directory commands: inspect internal files\n"
" df list of files\n"
" dz z-values and spectral ranges\n"
" dp x|y-values\n"
" dy y-values\n"
" dr real parameters\n"
" dc coordinate names and units\n"
" dd doc lines\n";
" dc coordinate names and units\n"
" dd doc lines\n"
" df list of files\n"
" dp x|y-values\n"
" dr real parameters\n"
" dv variables\n"
" dy y-values\n"
" dz z-values and spectral ranges\n";
} else if (cmd == "dc") {
NEdif::show_coord();
} else if (cmd == "dd") {
NEdif::show_doc();
} else if (cmd == "df") {
NEdif::show_files();
} else if (cmd == "dz") {
NEdif::show_spectra();
} else if (cmd == "dp") {
NOperate::show("xyd");
} else if (cmd == "dy") {
NOperate::show("y");
} else if (cmd == "dr") {
NEdif::show_numpars();
} else if (cmd == "dc") {
NEdif::show_coord();
} else if (cmd == "dd") {
NEdif::show_doc();
} else if (cmd == "dv") {
SVariRegistry::instance()->display_all();
} else if (cmd == "dy") {
NOperate::show("y");
} else if (cmd == "dz") {
NEdif::show_spectra();
} else if (cmd == "e") {
cout << "Edit commands:\n"
......
......@@ -7,18 +7,21 @@
//! \file variables.cpp
//! \brief Implements class SVariRegistry.
#include <algorithm>
#include "variables.hpp"
#include "defs.hpp"
#include "obj.hpp"
#include "ptr.hpp"
PObj SVariRegistry::find(string key) const
PObj SVariRegistry::find(const string& key) const
{
auto pos = Map.find(key);
return pos == Map.end() ? nullptr : pos->second;
}
PObj SVariRegistry::find_or_fail(string key) const
PObj SVariRegistry::find_or_fail(const string& key) const
{
PObj ret = find(key);
if (!ret)
......@@ -27,36 +30,21 @@ PObj SVariRegistry::find_or_fail(string key) const
}
void SVariRegistry::display_functions() const
void SVariRegistry::display_all() const
{
/*
// this implementation works only, if flist is strictly ordered:
// first operators by precedence, then functions.
cout << "Operators by precedence:\n";
int precedence = -1;
for( int i=0; i<FList.size(); ++i ){
const CFunc *f;
f = FList[i];
if( f->precedence ) { // operators
if( f->precedence!=precedence )
cout << "\n ";
cout << " " << f->key;
} else { // functions
if( f->precedence!=precedence )
cout << "\nBuilt-in functions:\n";
cout << " " << f->key << f->explanation << "\n";
}
precedence = f->precedence;
}
*/
vector<string> keys;
for (const auto& it: Map)
keys.push_back(it.first);
sort(keys.begin(), keys.end());
for (const string& key: keys)
cout << " " << key << " = " << Map.at(key)->to_s() << "\n";
}
void SVariRegistry::register_scalar(string key, PObj val) { Map[key] = val; }
void SVariRegistry::register_scalar(const string& key, PObj val) { Map[key] = val; }
//! Undefines a key (removes entry from registry); returns true unless the key wasn't defined.
bool SVariRegistry::undef(string key)
bool SVariRegistry::undef(const string& key)
{
auto pos = Map.find(key);
if (pos == Map.end())
......
......@@ -20,16 +20,16 @@
class SVariRegistry : public triv::ISingleton<SVariRegistry>
{
private:
map<string, PObj> Map; //! unsorted hash, for expression evaluation
map<const string, PObj> Map; //! unsorted hash, for expression evaluation
public:
PObj find(string key) const;
PObj find_or_fail(string key) const;
PObj find(const string& key) const;
PObj find_or_fail(const string& key) const;
void display_functions() const;
void display_all() const;
void register_scalar(string key, PObj val);
bool undef(string key);
void register_scalar(const string& key, PObj val);
bool undef(const string& key);
};
#endif // VARIABLES_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment