Commit dc43bd22 authored by Alvarez, Gonzalo's avatar Alvarez, Gonzalo
Browse files

InputNg: returns map of key/value pairs

parent fb44e393
...@@ -60,6 +60,7 @@ public: ...@@ -60,6 +60,7 @@ public:
typedef std::string::iterator IteratorType; typedef std::string::iterator IteratorType;
typedef Vector<char>::Type VectorCharType; typedef Vector<char>::Type VectorCharType;
typedef AinurState::VectorStringType VectorStringType;
Ainur(String str); Ainur(String str);
...@@ -83,6 +84,12 @@ public: ...@@ -83,6 +84,12 @@ public:
state_.readValue(t, dummy_ + label); state_.readValue(t, dummy_ + label);
} }
template<typename SomeMapType>
void setMap(SomeMapType& map) const
{
state_.setMap(map);
}
private: private:
static bool allEmpty(IteratorType first,IteratorType last) static bool allEmpty(IteratorType first,IteratorType last)
......
...@@ -11,6 +11,8 @@ namespace PsimagLite { ...@@ -11,6 +11,8 @@ namespace PsimagLite {
class AinurState { class AinurState {
public:
typedef Vector<SizeType>::Type VectorSizeType; typedef Vector<SizeType>::Type VectorSizeType;
typedef Vector<String>::Type VectorStringType; typedef Vector<String>::Type VectorStringType;
typedef std::complex<DoubleOrFloatType> ComplexType; typedef std::complex<DoubleOrFloatType> ComplexType;
...@@ -60,8 +62,6 @@ class AinurState { ...@@ -60,8 +62,6 @@ class AinurState {
Matrix<T>& t_; Matrix<T>& t_;
}; // struct ActionMatrix }; // struct ActionMatrix
public:
enum ErrorEnum enum ErrorEnum
{ {
ERR_PARSE_UNDECLARED, ERR_PARSE_UNDECLARED,
...@@ -150,6 +150,15 @@ public: ...@@ -150,6 +150,15 @@ public:
used_[x]++; used_[x]++;
} }
template<typename SomeMapType>
void setMap(SomeMapType& map) const
{
const SizeType n = keys_.size();
assert(n == values_.size());
for (SizeType i = 0; i < n; ++i)
map[keys_[i]] = map[values_[i]];
}
static bool verbose() { return false; } static bool verbose() { return false; }
static String errLabel(ErrorEnum e, String key) static String errLabel(ErrorEnum e, String key)
......
...@@ -538,6 +538,7 @@ public: ...@@ -538,6 +538,7 @@ public:
} }
ainur_ = new Ainur(inputWriteable.inputCheck().import() + data_); ainur_ = new Ainur(inputWriteable.inputCheck().import() + data_);
ainur_->setMap(mapStrStr_);
} }
} }
...@@ -547,14 +548,6 @@ public: ...@@ -547,14 +548,6 @@ public:
ainur_ = 0; ainur_ = 0;
} }
template<typename SomeMemResolvType>
SizeType memResolv(SomeMemResolvType&,
SizeType,
String = "") const
{
return 0;
}
void rewind() {} void rewind() {}
bool isAinur() const { return (ainur_ != nullptr); } bool isAinur() const { return (ainur_ != nullptr); }
...@@ -849,6 +842,11 @@ public: ...@@ -849,6 +842,11 @@ public:
throw RuntimeError("InputNg: Matrix<String> not supported in POD inputs\n"); throw RuntimeError("InputNg: Matrix<String> not supported in POD inputs\n");
} }
MapStrStrType map() const
{
return mapStrStr_;
}
const String& filename() const const String& filename() const
{ {
return file_; return file_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment