Skip to main content
Code Review

Return to Revisions

2 of 2
added 209 characters in body
SirPython
  • 13.5k
  • 3
  • 38
  • 93

OOP(s)!

Right now, the meat of your code is two separate functions, just floating around and minding their own business.

It would be better practice to put these two functions into a utility class. That way, they both exist together and can be easily accessed from the same parent.

I think these methods should be static.

EDIT:

According to Jerry Coffin,

These don't look like member functions to me. In any case, a class that contains only static functions should usually be a namespace instead. – Jerry Coffin


Versatility

It is very, very uncommon for an HTML tag to just be a tag along with inner content; there are almost always attributes.

Right now, your code can only generate something like this:

 <foo>bar</foo>

What about this?

<foo spam="eggs">bar</foo>

To improve you code, I recommend create a class/struct that stores the attribute name and value, like this:

typedef struct {
 std::string name;
 std::string val;
} HTML Attribute

Then, your method could take an array of these and loop through them, adding them to the string each time.

SirPython
  • 13.5k
  • 3
  • 38
  • 93
default

AltStyle によって変換されたページ (->オリジナル) /