Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
187 changed files
with
24,332 additions
and
5,838 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class CustomTypeInput : public InputSection | ||
{ | ||
public: | ||
struct LabeledPosition | ||
{ | ||
std::string letters; | ||
std::array<int, 3> numbers; | ||
}; | ||
CustomTestInput() | ||
{ | ||
... | ||
attributes = {"name", "custom_attribute"}; | ||
custom = {"labeled_position", "custom_attribute"}; | ||
} | ||
void setFromStreamCustom(const std::string& ename, const std::string& name, std::istringstream& svalue) override | ||
{ | ||
if (ename == "labeled_position") | ||
{ | ||
LabeledPosition ws; | ||
svalue >> ws.letters; | ||
svalue >> ws.numbers[0]; | ||
svalue >> ws.numbers[1]; | ||
svalue >> ws.numbers[2]; | ||
values_[name] = ws; | ||
} | ||
else if (name == "custom_attribute") | ||
{ | ||
std::string cus_at; | ||
// otherwise you will get not consume the entire attribute just the next piece as determine by operator>> and | ||
// the type you are going into. | ||
std::getline(svalue, cus_at); | ||
... // do your custom parsing. | ||
values_[name] = cus_at; | ||
} | ||
else | ||
throw std::runtime_error("bad name passed: " + name + | ||
" or custom setFromStream not implemented in derived class."); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** Generic delgate input class. | ||
* The delegate input requires: | ||
* A constructor that takes an xmlNodePtr | ||
* A factoryFunction that matches the signature discussed in InputSection::DelegateHandler | ||
*/ | ||
|
||
class AnotherInput | ||
{ | ||
public: | ||
class AnotherInputSection : public InputSection | ||
{ | ||
... | ||
}; | ||
|
||
AnotherInput(xmlNodePtr cur) | ||
{ | ||
... | ||
} | ||
}; | ||
|
||
/// Factory function for the delegate Input class. | ||
std::any makeAnotherInput(xmlNodePtr cur, std::string& value_label) | ||
{ | ||
AnotherInput another_input{cur}; | ||
value_label = another_input.get_name(); | ||
return another_input; | ||
} | ||
|
||
/** Input class delegating to other input classes. | ||
*/ | ||
class DelegatingInput | ||
{ | ||
class DelegatingInputSection : public InputSection | ||
{ | ||
public: | ||
DelegatingInputSection() | ||
{ | ||
section_name = "DelegateTest"; | ||
... | ||
delegates = {"anotherinput"}; | ||
InputSection::registerDelegate("anotherinput", makeAnotherInput); | ||
} | ||
}; | ||
|
||
public: | ||
DelegatingInput(xmlNodePtr cur) { dins_.readXML(cur); } | ||
|
||
// rather than write a real input class we just pass through InputSection for this test. | ||
bool has(const std::string& name) const { return dins_.has(name); } | ||
template<typename T> | ||
T get(const std::string& name) const | ||
{ | ||
return dins_.get<T>(name); | ||
} | ||
|
||
private: | ||
std::string name_ = "DelegatingInput"; | ||
DelegatingInputSection dins_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.