coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
parsed_line Struct Reference

#include <parsed_line.h>

Inheritance diagram for parsed_line:
parse_buffer

Public Types

using base_type = parse_buffer
 Type of base class.
 
- Public Types inherited from parse_buffer
using value_type = char
 Value-type of parse_buffer
 

Public Member Functions

 parsed_line (std::istream *in, std::ostream *out)
 Construct given pointers to input and output streams.
 
std::istream * file ()
 Get a pointer to the input stream from which this parsed_line reads.
 
unsigned num () const
 Get the greatest source line number spanned by this line.
 
unsigned extensions () const
 Get the number of linefeeds embedded in this line.
 
void mark_keyword (size_t off, size_t len)
 Record the offset and length of a directive keyword in the line.
 
bool get ()
 Try to read a line of input. More...
 
void replace (std::string const &replacement)
 Replace the line with another string.
 
template<directive_type DirectiveType>
void keyword_edit ()
 Replace the directive in the line. More...
 
void set_simplified (bool value=true)
 Classifiy the line as simplified or not.
 
bool is_simplified () const
 Say whether the line has been simplified.
 
bool reportable ()
 Is the line reportable for the operative command.
 
void set_directive_type (directive_type dtype)
 Set the directive type of the line.
 
directive_type get_directive_type () const
 Get Set the directive type of the line.
 
void set_dropping ()
 Record whether we are dropping the line.
 
bool dropping () const
 Are we dropping the line?
 
void output ()
 Output the line.
 
void drop ()
 Drop the line.
 
unsigned & indent ()
 Get a reference to the line's indentation amount.
 
- Public Member Functions inherited from parse_buffer
 parse_buffer ()=default
 Default constuctor.
 
virtual ~parse_buffer ()
 Destructor.
 
 parse_buffer (std::string const &str)
 Explicitly construct from an std::string
 
parse_bufferoperator= (parse_buffer const &)=default
 Assign another parse_buffer
 
parse_bufferoperator= (std::string const &str)
 Assign an std::string
 
bool operator== (parse_buffer const &other) const
 Equality.
 
bool operator!= (parse_buffer const &other) const
 Inequality operator.
 
size_t size () const
 Get the length of the parse_buffer
 
 operator std::string const & () const
 Explicitly cast to std::string
 
std::string substr (size_t start, size_t len=std::string::npos) const
 Get a substring of the parse_buffer.
 
bool overshoot (size_t off=0) const
 Say whether an offset is out of tange.
 
char at (size_t off) const
 Get the character indexed by an offset. Not range-checked.
 
char & at (size_t off)
 Get a reference to the character an offset. Not range-checked.
 
char operator[] (size_t off) const
 Get the character at an offset. Not range checked.
 
char & operator[] (size_t offset)
 Get a reference to the character at an offset. Not range checked.
 
void clear ()
 Empty the parse_buffer.
 
unsigned eol (size_t offset) const
 Say whether there is a newline sequence at an offset. More...
 
std::string & str ()
 Get a [const] reference to the underlying std::string.
 
std::string const & str () const
 
char const * data () const
 Get a [const] pointer to the data.
 
char * data ()
 

Protected Member Functions

size_t extension_pending (size_t off) const override
 Say whether a line extension is pending at an offset in the line.
 
size_t extend (size_t skip) override
 Try to extend the line past a new-line sequence. More...
 
size_t extend () override
 Try to read another line of input, returning the number of bytes read.
 
void keyword_lop (std::string const &keyword)
 Convert the directive in the line into a another one that has no argument. More...
 
void keyword_swap (std::string const &directive)
 Replace the directive keyword in the line with another one. More...
 
void write ()
 Output the line.
 
void write_commented_out ()
 Output the line commented out.
 
void write_fast ()
 Output the line fast, when possible.
 
void write_slow ()
 Output the line slowely, when necessary.
 
void write (bool keep)
 Output the line or else discard it according to options. More...
 
void set_reportable ()
 Record whether the line is reportable for the operative command.
 

Protected Attributes

unsigned _extensions = 0
 The number of linefeeds embedded in the line.
 
unsigned _lineno = 0
 The greatest source line number spanned by this line.
 
std::istream * _in
 The input stream from which this line is read.
 
std::ostream * _out
 The output stream to which this line is written.
 
size_t _keyword_posn = 0
 Offset to directive keyword, if any.
 
size_t _keyword_len = 0
 Length of directive keyword, if any.
 
directive_type _dtype = HASH_UNKNOWN
 The directive type of this line.
 
bool _reportable = false
 Is this line reportable?
 
bool _dropping = false
 Are we dropping this line.
 
bool _simplified = false
 Has the line been simplified?
 
unsigned _drop_run_length = 0
 Count of contiguous lines that are dropped together.
 
unsigned _indent = 0
 Amount by which the line is indented.
 
- Protected Attributes inherited from parse_buffer
std::string _text
 The data.
 

Detailed Description

struct parsed_line is the coan parser's representation of a parsed line of input read from a file.

Definition at line 50 of file parsed_line.h.

Member Function Documentation

size_t parsed_line::extend ( size_t  skip)
overrideprotectedvirtual

Try to extend the line past a new-line sequence.

Parameters
skipThe length of the newline-sequence at the scanning position.
Returns
The net length of the extension.

Reimplemented from parse_buffer.

bool parsed_line::get ( )

Try to read a line of input.

Returns
true iff a line is read.
template<directive_type DirectiveType>
void parsed_line::keyword_edit ( )

Replace the directive in the line.

Template Parameters
DirectiveTypeThe type of directive that is to replace the existing one.

The member function edits the line to subsitute a directive of type DirectiveType for the existing directive in the line to rectify the #if-logic of the file in the light of lines that have been dropped.

If DirectiveType denotes a type of directive that has no argument then the existing directive keyword is replaced the keyword corresponding to DirectiveType and the line is then terminated with a linefeed.

Otherwise the existing directive keyord is simply replaced the keyword corresponding to DirectiveType.

void parsed_line::keyword_lop ( std::string const &  keyword)
protected

Convert the directive in the line into a another one that has no argument.

Parameters
keywordThe keyword of the replacement directive.
The existing directive keyword in the line, if any,
is replaced the `keyword` and the line is then terminated
with a linefeed.
void parsed_line::keyword_swap ( std::string const &  directive)
protected

Replace the directive keyword in the line with another one.

Parameters
directiveThe keyword of the replacement directive.
void parsed_line::write ( bool  keep)
protected

Output the line or else discard it according to options.

Parameters
keepWhether to retain or drop the line

keep is negated if options::complement() is true. Then, if keep is true, the line is output. Otherwise a blank line or a commented-out line, or nothing, is output depending on the specified or default --discard option.


The documentation for this struct was generated from the following file: