File tree 4 files changed +18
-12
lines changed
4 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,21 @@ FlibberCollection::flibber()
32
32
myFlibbers.push_back (makeFlibber ());
33
33
}
34
34
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
+
35
50
Flibber
36
51
makeFlibber ()
37
52
{
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ struct Flibber
12
12
struct FlibberCollection
13
13
{
14
14
void flibber ();
15
+ std::string toString (uint8_t tabs) const ;
15
16
16
17
std::vector<Flibber> myFlibbers;
17
18
};
Original file line number Diff line number Diff line change @@ -25,12 +25,7 @@ ObjectBar::toString(uint8_t tabs) const
25
25
std::string res;
26
26
res += tab + " splinx: " + mySplinx + ' \n ' ;
27
27
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);
34
29
return res;
35
30
}
36
31
Original file line number Diff line number Diff line change @@ -16,12 +16,7 @@ ObjectFoo::toString(uint8_t tabs) const
16
16
std::string res;
17
17
res += tab + " wibble: " + std::to_string (myWibble) + ' \n ' ;
18
18
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);
25
20
return res;
26
21
}
27
22
You can’t perform that action at this time.
0 commit comments