ONE - On-device Neural Engine
Loading...
Searching...
No Matches
pp::LinearDocument Class Referencefinal

#include <LinearDocument.h>

Collaboration diagram for pp::LinearDocument:

Public Types

enum class  Direction { Forward , Reverse }
 

Public Member Functions

 LinearDocument ()
 
 LinearDocument (const Direction &direction)
 
void indent (void)
 
void unindent (void)
 
void append (void)
 
void append (const std::string &line)
 
template<typename Derived >
std::enable_if< std::is_base_of< MultiLineText, Derived >::value >::type append (const Derived &txt)
 
template<typename... Args>
void append (const Args &...args)
 
void append (const LinearDocument &doc)
 
uint32_t lines (void) const override
 
const std::string & line (uint32_t n) const override
 
- Public Member Functions inherited from pp::MultiLineText
virtual ~MultiLineText ()=default
 

Detailed Description

Definition at line 32 of file LinearDocument.h.

Member Enumeration Documentation

◆ Direction

enum class pp::LinearDocument::Direction
strong
Enumerator
Forward 
Reverse 

Definition at line 35 of file LinearDocument.h.

Constructor & Destructor Documentation

◆ LinearDocument() [1/2]

pp::LinearDocument::LinearDocument ( )
inline

Definition at line 42 of file LinearDocument.h.

42 : _direction{Direction::Forward}
43 {
44 // DO NOTHING
45 }

◆ LinearDocument() [2/2]

pp::LinearDocument::LinearDocument ( const Direction direction)
inline

Definition at line 48 of file LinearDocument.h.

48 : _direction{direction}
49 {
50 // DO NOTHING
51 }

Member Function Documentation

◆ append() [1/5]

template<typename... Args>
void pp::LinearDocument::append ( const Args &...  args)
inline

Definition at line 73 of file LinearDocument.h.

73{ append(fmt(args...)); }
FormattedGraph fmt(loco::Graph *g)
Definition LogHelper.cpp:73
args
Definition infer.py:21

References append().

Referenced by append().

◆ append() [2/5]

template<typename Derived >
std::enable_if< std::is_base_of< MultiLineText, Derived >::value >::type pp::LinearDocument::append ( const Derived &  txt)
inline

Definition at line 65 of file LinearDocument.h.

66 {
67 for (uint32_t n = 0; n < txt.lines(); ++n)
68 {
69 append(txt.line(n));
70 }
71 }

References append().

◆ append() [3/5]

void pp::LinearDocument::append ( const LinearDocument doc)

Definition at line 45 of file LinearDocument.cpp.

46{
47 for (uint32_t n = 0; n < doc.lines(); ++n)
48 {
49 // NOTE Do NOT update _lines here and use append method
50 append(doc.line(n));
51 }
52}

References append(), line(), and lines().

◆ append() [4/5]

void pp::LinearDocument::append ( const std::string &  line)

Definition at line 33 of file LinearDocument.cpp.

34{
35 if (line.empty())
36 {
37 append();
38 return;
39 }
40
41 // Append indentation space(s), and insert the update string to lines
42 _lines.emplace_back(_indent.build(line));
43}
std::string build(const std::string &content)
const std::string & line(uint32_t n) const override

References append(), pp::IndentedStringBuilder::build(), and line().

◆ append() [5/5]

void pp::LinearDocument::append ( void  )

Definition at line 27 of file LinearDocument.cpp.

28{
29 // NOTE Do NOT indent empty lines
30 _lines.emplace_back("");
31}

Referenced by append(), append(), append(), DEBUGGING_API_P(), DEBUGGING_API_P(), DEBUGGING_API_P(), DEBUGGING_API_P(), DEBUGGING_API_P(), DEBUGGING_API_P(), and enco::CppCode::dump().

◆ indent()

void pp::LinearDocument::indent ( void  )

Definition at line 24 of file LinearDocument.cpp.

24{ _indent.increase(); }

References pp::IndentedStringBuilder::increase().

Referenced by enco::CppCode::dump().

◆ line()

const std::string & pp::LinearDocument::line ( uint32_t  n) const
overridevirtual

Implements pp::MultiLineText.

Definition at line 54 of file LinearDocument.cpp.

55{
56 switch (_direction)
57 {
59 {
60 return _lines.at(n);
61 }
63 {
64 return _lines.at(lines() - n - 1);
65 }
66 default:
67 throw std::runtime_error{"Not supported Direction"};
68 }
69}
uint32_t lines(void) const override

References Forward, lines(), and Reverse.

Referenced by append(), append(), and pp::EnclosedDocument::line().

◆ lines()

uint32_t pp::LinearDocument::lines ( void  ) const
inlineoverridevirtual

Implements pp::MultiLineText.

Definition at line 79 of file LinearDocument.h.

79{ return _lines.size(); }

Referenced by append(), pp::EnclosedDocument::line(), line(), and pp::EnclosedDocument::lines().

◆ unindent()

void pp::LinearDocument::unindent ( void  )

Definition at line 25 of file LinearDocument.cpp.

25{ _indent.decrease(); }

References pp::IndentedStringBuilder::decrease().

Referenced by enco::CppCode::dump().


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