File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,8 +42,9 @@ int main(int argc, char* argv[]) {
4242 std::list<netlicensing::ValidationResult> vres = netlicensing::validate (ctx, license_number);
4343 std::cout << " got validation results: " << vres.size () << std::endl;
4444 for (auto val_res : vres) {
45- std::cout << " lic model: {" << val_res.licensing_model_ << " } prod mod name {" << val_res.product_module_name_ << " }"
46- << " properties size{" << val_res.properties_ .size () << " }\n " ;
45+ std::cout << val_res.to_string () << std::endl;
46+ // std::cout << "lic model: {" << val_res.licensing_model_ << "} prod mod name {" << val_res.product_module_name_ << "}"
47+ // << " properties size{" << val_res.properties_.size() << "}\n";
4748 }
4849 }
4950 }
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ struct NamedList {
2626
2727template <class T >
2828struct RecursiveList : public NamedList {
29- std::string name_;
3029 std::list<std::shared_ptr<RecursiveList<T> > > nested_lists_;
3130
3231 void add_list (std::shared_ptr<RecursiveList<T> > ptr) {
@@ -70,6 +69,7 @@ class Entity {
7069public:
7170 bool add_property (const std::string& key, const std::string& value);
7271 std::string get_property (const std::string& key) const ;
72+ std::string to_string () const ;
7373};
7474
7575struct Info {
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ struct ValidationProperty : public RecursiveList<ValidationProperty> {
1414 if (RecursiveList<ValidationProperty>::add_property (name, value)) return ;
1515 values.add_property (name, value);
1616 }
17+
18+ std::string to_string () const ;
1719};
1820
1921
@@ -29,6 +31,7 @@ struct ValidationResult {
2931 std::list<std::shared_ptr<ValidationProperty> > properties_;
3032 void add_property (const std::string& name, const std::string& value);
3133 void add_list (std::shared_ptr<PropertyType> ptr);
34+ std::string to_string () const ;
3235};
3336
3437}
Original file line number Diff line number Diff line change 11#include " netlicensing/entity.h"
2+ #include < sstream>
23
34namespace netlicensing {
45
@@ -13,6 +14,15 @@ std::string Entity::get_property(const std::string& key) const {
1314 return " " ;
1415}
1516
17+ std::string Entity::to_string () const {
18+ std::stringstream ss;
19+ for (auto kv : user_defined_properties_) {
20+ ss << kv.first << " {" << kv.second << " } " ;
21+ }
22+
23+ return ss.str ();
24+ }
25+
1626void Info::add_property (const std::string& name, const std::string& value) {
1727 if (name == " value" ) value_ = value;
1828 else if (name == " id" ) id_ = value;
Original file line number Diff line number Diff line change 11#include " netlicensing/validation_result.h"
2+ #include < sstream>
23
34namespace netlicensing {
45
6+ std::string ValidationProperty::to_string () const {
7+ std::stringstream ss;
8+ ss << " ProductModule <" << name_ << " \n " ;
9+ ss << values.to_string ();
10+ // for (auto nested : nested_lists_) {
11+ // ss << nested->nested_lists_.;
12+ // }
13+ ss << " >\n " ;
14+ return ss.str ();
15+ }
16+
517void ValidationResult::add_property (const std::string& name, const std::string& value) {
618 if (name == " productModuleNumber" ) product_module_number_ = value;
719 else if (name == " productModuleName" ) product_module_name_ = value;
@@ -12,4 +24,13 @@ void ValidationResult::add_list(std::shared_ptr<PropertyType> ptr) {
1224 properties_.push_back (ptr);
1325}
1426
27+ std::string ValidationResult::to_string () const {
28+ std::stringstream ss;
29+ for (auto vp : properties_) {
30+ ss << vp->to_string ();
31+ }
32+
33+ return ss.str ();
34+ }
35+
1536}
You can’t perform that action at this time.
0 commit comments