File tree Expand file tree Collapse file tree 4 files changed +18
-12
lines changed
Expand file tree Collapse file tree 4 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,21 @@ FlibberCollection::flibber()
3232 myFlibbers.push_back (makeFlibber ());
3333}
3434
35+ std::string
36+ FlibberCollection::toString (uint8_t tabs) const
37+ {
38+ if (myFlibbers.size () == 0 )
39+ return {};
40+ std::string tab;
41+ for (uint8_t i = 0 ; i < tabs; ++i)
42+ tab += ' \t ' ;
43+
44+ std::string res = tab + " flibbers:\n " ;
45+ for (const Flibber& fli : myFlibbers)
46+ res += tab + ' \t ' + fli.myKey + " : " + fli.myValue + ' \n ' ;
47+ return res;
48+ }
49+
3550Flibber
3651makeFlibber ()
3752{
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ struct Flibber
1212struct FlibberCollection
1313{
1414 void flibber ();
15+ std::string toString (uint8_t tabs) const ;
1516
1617 std::vector<Flibber> myFlibbers;
1718};
Original file line number Diff line number Diff line change @@ -25,12 +25,7 @@ ObjectBar::toString(uint8_t tabs) const
2525 std::string res;
2626 res += tab + " splinx: " + mySplinx + ' \n ' ;
2727 res += tab + " yibble: " + std::to_string (myYibble) + ' \n ' ;
28- if (myFlibbers.size () > 0 )
29- {
30- res += tab + " flibbers:\n " ;
31- for (const Flibber& fli : myFlibbers)
32- res += tab + ' \t ' + fli.myKey + " : " + fli.myValue + ' \n ' ;
33- }
28+ res += FlibberCollection::toString (tabs);
3429 return res;
3530}
3631
Original file line number Diff line number Diff line change @@ -16,12 +16,7 @@ ObjectFoo::toString(uint8_t tabs) const
1616 std::string res;
1717 res += tab + " wibble: " + std::to_string (myWibble) + ' \n ' ;
1818 res += tab + " zorble: " + myZorble + ' \n ' ;
19- if (myFlibbers.size () > 0 )
20- {
21- res += tab + " flibbers:\n " ;
22- for (const Flibber& fli : myFlibbers)
23- res += tab + ' \t ' + fli.myKey + " : " + fli.myValue + ' \n ' ;
24- }
19+ res += FlibberCollection::toString (tabs);
2520 return res;
2621}
2722
You can’t perform that action at this time.
0 commit comments