ONE - On-device Neural Engine
Loading...
Searching...
No Matches
pp::IndentedStringBuilder Class Reference

#include <IndentedStringBuilder.h>

Public Member Functions

 IndentedStringBuilder ()
 
void increase (void)
 
void decrease (void)
 
std::string build (const std::string &content)
 
template<typename... Args>
std::string build (const Args &...args)
 

Detailed Description

Definition at line 27 of file IndentedStringBuilder.h.

Constructor & Destructor Documentation

◆ IndentedStringBuilder()

pp::IndentedStringBuilder::IndentedStringBuilder ( )
inline

Definition at line 30 of file IndentedStringBuilder.h.

30 : _level{0}
31 {
32 // DO NOTHING
33 }

Member Function Documentation

◆ build() [1/2]

template<typename... Args>
std::string pp::IndentedStringBuilder::build ( const Args &...  args)
inline

Definition at line 43 of file IndentedStringBuilder.h.

43{ return build(fmt(args...)); }
std::string build(const std::string &content)
FormattedGraph fmt(loco::Graph *g)
Definition LogHelper.cpp:73
args
Definition infer.py:21

References build().

Referenced by build().

◆ build() [2/2]

std::string pp::IndentedStringBuilder::build ( const std::string &  content)

Definition at line 37 of file IndentedStringBuilder.cpp.

38{
39 assert(std::find(content.begin(), content.end(), '\n') == content.end());
40
41 const char c = ' ';
42 const size_t space_per_indent_level = 2;
43 const size_t space_count = space_per_indent_level * _level;
44
45 return std::string(space_count, c) + content;
46}

Referenced by pp::LinearDocument::append().

◆ decrease()

void pp::IndentedStringBuilder::decrease ( void  )

Definition at line 31 of file IndentedStringBuilder.cpp.

32{
33 assert(_level > 0);
34 --_level;
35}

Referenced by pp::LinearDocument::unindent().

◆ increase()

void pp::IndentedStringBuilder::increase ( void  )

Definition at line 25 of file IndentedStringBuilder.cpp.

26{
27 // TODO Check overflow
28 ++_level;
29}

Referenced by pp::LinearDocument::indent().


The documentation for this class was generated from the following files: