1010#include < sstream>
1111#include < string>
1212// windows compatibility includes
13- #include < cctype>
1413#include < algorithm>
14+ #include < cctype>
1515
1616// -----------------------------------------------------------------------------
1717
@@ -36,11 +36,13 @@ class BlockParser
3636 *
3737 * @method
3838 * @param {std::function<void(std::string&)>} parseLineCallback
39- * @param {std::function<std::shared_ptr<BlockParser>(const std::string& line)>} getBlockParserForLineCallback
39+ * @param {std::function<std::shared_ptr<BlockParser>(const std::string&
40+ * line)>} getBlockParserForLineCallback
4041 */
4142 BlockParser (
4243 std::function<void (std::string&)> parseLineCallback,
43- std::function<std::shared_ptr<BlockParser>(const std::string& line)> getBlockParserForLineCallback
44+ std::function<std::shared_ptr<BlockParser>(const std::string& line)>
45+ getBlockParserForLineCallback
4446 )
4547 : result(" " , std::ios_base::ate | std::ios_base::in | std::ios_base::out)
4648 , childParser(nullptr )
@@ -64,8 +66,7 @@ class BlockParser
6466 * @param {std::string&} line
6567 * @return {void}
6668 */
67- virtual void
68- AddLine (std::string& line)
69+ virtual void AddLine (std::string& line)
6970 {
7071 this ->parseBlock (line);
7172
@@ -113,11 +114,7 @@ class BlockParser
113114 * @method
114115 * @return {std::stringstream}
115116 */
116- std::stringstream&
117- GetResult ()
118- {
119- return this ->result ;
120- }
117+ std::stringstream& GetResult () { return this ->result ; }
121118
122119 /* *
123120 * Clear
@@ -129,11 +126,7 @@ class BlockParser
129126 * @method
130127 * @return {void}
131128 */
132- void
133- Clear ()
134- {
135- this ->result .str (" " );
136- }
129+ void Clear () { this ->result .str (" " ); }
137130
138131protected:
139132 std::stringstream result;
@@ -143,47 +136,42 @@ class BlockParser
143136 virtual bool isLineParserAllowed () const = 0;
144137 virtual void parseBlock (std::string& line) = 0;
145138
146- void
147- parseLine (std::string& line)
139+ void parseLine (std::string& line)
148140 {
149141 if (parseLineCallback)
150142 {
151143 parseLineCallback (line);
152144 }
153145 }
154146
155- uint32_t
156- getIndentationWidth (const std::string& line) const
147+ uint32_t getIndentationWidth (const std::string& line) const
157148 {
158149 bool hasMetNonSpace = false ;
159150
160- uint32_t indentation = static_cast <uint32_t >(
161- std::count_if (
162- line.begin (),
163- line.end (),
164- [&hasMetNonSpace](unsigned char c)
151+ uint32_t indentation = static_cast <uint32_t >(std::count_if (
152+ line.begin (),
153+ line.end (),
154+ [&hasMetNonSpace](unsigned char c)
155+ {
156+ if (hasMetNonSpace)
165157 {
166- if (hasMetNonSpace)
167- {
168- return false ;
169- }
170-
171- if (std::isspace (c))
172- {
173- return true ;
174- }
175-
176- hasMetNonSpace = true ;
177158 return false ;
178159 }
179- )
180- );
160+
161+ if (std::isspace (c))
162+ {
163+ return true ;
164+ }
165+
166+ hasMetNonSpace = true ;
167+ return false ;
168+ }
169+ ));
181170
182171 return indentation;
183172 }
184173
185- std::shared_ptr<BlockParser>
186- getBlockParserForLine (const std::string& line)
174+ std::shared_ptr<BlockParser> getBlockParserForLine (const std::string& line)
187175 {
188176 if (getBlockParserForLineCallback)
189177 {
@@ -195,7 +183,8 @@ class BlockParser
195183
196184private:
197185 std::function<void (std::string&)> parseLineCallback;
198- std::function<std::shared_ptr<BlockParser>(const std::string& line)> getBlockParserForLineCallback;
186+ std::function<std::shared_ptr<BlockParser>(const std::string& line)>
187+ getBlockParserForLineCallback;
199188}; // class BlockParser
200189
201190// -----------------------------------------------------------------------------
0 commit comments