mmCEsim 0.3.0
mmWave Channel Estimation Simulation
Alg_Line Class Reference

Process line of Alg into standard formats. More...

#include <alg_line.h>

Classes

struct  Param_Type
 Parameter type. More...
 
struct  Return_Type
 Return type. More...
 

Public Member Functions

 Alg_Line ()=default
 
 Alg_Line (const std::string &str, ALG_Opt opt=ALG_Opt::NONE)
 Construct a new Alg_Line object. Process string at the same time. More...
 
const std::string & func () const noexcept
 Get the function name. More...
 
const std::vector< Return_Type > & returns () const noexcept
 Return variables. More...
 
const Return_Typereturns (std::vector< Return_Type >::size_type index) const
 Return variable of an index. More...
 
const std::vector< Param_Type > & params () const noexcept
 Parameter variables. More...
 
const Param_Typeparams (std::vector< Param_Type >::size_type index) const
 Parameter variable of an index. More...
 
const Param_Typeparams (const std::string &key) const
 Parameter variable with a key. More...
 
const std::string & operator[] (const std::string key) const
 Get the parameter value with the key. More...
 
const std::string & rawStr () const
 Return the raw string of the line. More...
 
bool hasKey (const std::string &key) const noexcept
 Check whether parameters contain the key. More...
 
bool hasUnknownKey (const std::vector< std::string > &keys) const noexcept
 Check if parameters have unknown keys. More...
 
bool hasUnknownKey (const std::vector< std::string > &keys, std::string &unknown_key) const noexcept
 
bool hasRepeatedKey () const noexcept
 Check if parameters have repeated keys. More...
 
bool isValidKey (const std::string &key, const std::vector< std::string > &keys) const noexcept
 Check is the key is valid. (not violating the needed sequence.) More...
 
bool setKey (std::vector< Param_Type >::size_type index, const std::string &key)
 Set parameter variable key. More...
 
bool needsEnd () const noexcept
 Test whether the function name needs an 'end'. More...
 
bool isEnd () const noexcept
 Test whether the function name serves as an 'end'. More...
 
bool isFunctionDeclaration () const noexcept
 Check whether the line is for function declaration. More...
 
std::ostream & print (std::ostream &out=std::cout, std::string prefix="") const
 Print Alg_Line contents (including return values, function names and parameters). More...
 

Private Member Functions

std::string::size_type _findChars (const std::string &s, std::string cs) const noexcept
 Find the first occupance of substring in string that is not an escape or within quotes. More...
 
std::string::size_type _findChar (const std::string &s, char c) const noexcept
 Find the first occupance of character in string that is not an escape or within quotes. More...
 
void _removeComment (std::string &s) const noexcept
 Remove the comment from the string. More...
 
void _processReturns (const std::vector< std::string > &v)
 Process returns variables. More...
 
void _processFuncParams (const std::vector< std::string > &v)
 Process function name and parameter variables. More...
 
std::string _decodeEscape (const std::string &s) const
 

Private Attributes

std::string _func
 
std::vector< Return_Type_returns
 
std::vector< Param_Type_params
 
std::string _raw_str
 
ALG_Opt _opt
 

Detailed Description

Process line of Alg into standard formats.

The main process is done during constructing.

Constructor & Destructor Documentation

◆ Alg_Line() [1/2]

Alg_Line::Alg_Line ( )
default

◆ Alg_Line() [2/2]

Alg_Line::Alg_Line ( const std::string &  str,
ALG_Opt  opt = ALG_Opt::NONE 
)

Construct a new Alg_Line object. Process string at the same time.

Parameters
strThe raw string from Alg that is to be processed.
optALG parsing options.
Here is the call graph for this function:

Member Function Documentation

◆ _decodeEscape()

std::string Alg_Line::_decodeEscape ( const std::string &  s) const
inlineprivate
Here is the caller graph for this function:

◆ _findChar()

std::string::size_type Alg_Line::_findChar ( const std::string &  s,
char  c 
) const
inlineprivatenoexcept

Find the first occupance of character in string that is not an escape or within quotes.

Parameters
sstring
cthe character to find
Returns
(std::string::size_type) The index of the found char. Return s.size() if not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _findChars()

std::string::size_type Alg_Line::_findChars ( const std::string &  s,
std::string  cs 
) const
privatenoexcept

Find the first occupance of substring in string that is not an escape or within quotes.

Parameters
sstring
csthe substring to find
Returns
(std::string::size_type) The index of the found substring. Return s.size() if not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _processFuncParams()

void Alg_Line::_processFuncParams ( const std::vector< std::string > &  v)
private

Process function name and parameter variables.

Parameters
vThe unprocessed function name and parameter variables token variable.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _processReturns()

void Alg_Line::_processReturns ( const std::vector< std::string > &  v)
private

Process returns variables.

Parameters
vThe unprocessed return variables token vector.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _removeComment()

void Alg_Line::_removeComment ( std::string &  s) const
privatenoexcept

Remove the comment from the string.

Comment starts with hash(#).

Parameters
sThe string to be modified.
Here is the caller graph for this function:

◆ func()

const std::string & Alg_Line::func ( ) const
inlinenoexcept

Get the function name.

Returns
(const std::string&) The function name.
Here is the caller graph for this function:

◆ hasKey()

bool Alg_Line::hasKey ( const std::string &  key) const
inlinenoexcept

Check whether parameters contain the key.

Normally, the function 'setKey' needs to be called first so that parameters specified by locations can be found as well.

Parameters
keyThe key string to check.
Return values
trueParameter variables contain this key.
falseParameter variables do not contain this key.
Here is the caller graph for this function:

◆ hasRepeatedKey()

bool Alg_Line::hasRepeatedKey ( ) const
inlinenoexcept

Check if parameters have repeated keys.

Return values
trueThe parameters have repeated keys.
falseThe parameters do not have repeated keys.

◆ hasUnknownKey() [1/2]

bool Alg_Line::hasUnknownKey ( const std::vector< std::string > &  keys) const
inlinenoexcept

Check if parameters have unknown keys.

Parameters
keysAll valid keys.
Return values
trueAll keys of parameters are valid.
falseThere exist unknown keys.
Here is the call graph for this function:

◆ hasUnknownKey() [2/2]

bool Alg_Line::hasUnknownKey ( const std::vector< std::string > &  keys,
std::string &  unknown_key 
) const
inlinenoexcept
Here is the call graph for this function:

◆ isEnd()

bool Alg_Line::isEnd ( ) const
inlinenoexcept

Test whether the function name serves as an 'end'.

Return values
trueThe function serves as 'end'. ('END', 'ELSE', etc.)
falseThe function does not serve as 'end'.
Here is the call graph for this function:

◆ isFunctionDeclaration()

bool Alg_Line::isFunctionDeclaration ( ) const
inlinenoexcept

Check whether the line is for function declaration.

Return values
trueThe ALG_Opt is set to ALG_Opt::FUNCTION_DECLARATION
falseThe ALG_Opt is not ALG_Opt::FUNCTION_DECLARATION
Here is the caller graph for this function:

◆ isValidKey()

bool Alg_Line::isValidKey ( const std::string &  key,
const std::vector< std::string > &  keys 
) const
inlinenoexcept

Check is the key is valid. (not violating the needed sequence.)

If the key does not exist, it is not valid; If the key exists, the keys need to exist. For example, for size specification, if the third dimension ('dim3') exists, the first two dimensions ('dim1' and 'dim2') also need to exist. Similar to method 'hasKey', normally this method should be called after 'setKey'.

Parameters
keyThe key string to check.
keysThe required keys if key exists.
Return values
trueThe key is not valid.
falseThe key is valid.
Here is the call graph for this function:

◆ needsEnd()

bool Alg_Line::needsEnd ( ) const
inlinenoexcept

Test whether the function name needs an 'end'.

Return values
trueThe function needs 'end'. ('IF', 'ELSE', 'LOOP', etc.)
falseThe function does need 'end'.
Here is the call graph for this function:

◆ operator[]()

const std::string & Alg_Line::operator[] ( const std::string  key) const
inline

Get the parameter value with the key.

Parameters
keyThe key string.
Returns
(const std::string&) The parameter variable value.
Here is the call graph for this function:

◆ params() [1/3]

const std::vector< Alg_Line::Param_Type > & Alg_Line::params ( ) const
inlinenoexcept

Parameter variables.

Returns
(const std::vector<Param_Type>&) The vector of parameter variables.
Here is the caller graph for this function:

◆ params() [2/3]

const Alg_Line::Param_Type & Alg_Line::params ( const std::string &  key) const
inline

Parameter variable with a key.

Parameters
keyThe key string.
Returns
(const Param_Type&) The parameter variable.

◆ params() [3/3]

const Alg_Line::Param_Type & Alg_Line::params ( std::vector< Param_Type >::size_type  index) const
inline

Parameter variable of an index.

Parameters
indexThe index of the parameter index.
Returns
(const Param_Type&) The variable.

◆ print()

std::ostream & Alg_Line::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
inline

Print Alg_Line contents (including return values, function names and parameters).

This is mostly used in internal debugging.

Parameters
outThe output stream.
prefixThe print prefix.
Returns
(std::ostream&) The output stream.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawStr()

const std::string & Alg_Line::rawStr ( ) const
inline

Return the raw string of the line.

Returns
(const std::string&) The raw string.

◆ returns() [1/2]

const std::vector< Alg_Line::Return_Type > & Alg_Line::returns ( ) const
inlinenoexcept

Return variables.

Returns
(const std::vector<Return_Type>&) The vector of return variables.
Here is the caller graph for this function:

◆ returns() [2/2]

const Alg_Line::Return_Type & Alg_Line::returns ( std::vector< Return_Type >::size_type  index) const
inline

Return variable of an index.

Parameters
indexThe index of the return variable.
Returns
(const Return_Type&) The variable.

◆ setKey()

bool Alg_Line::setKey ( std::vector< Param_Type >::size_type  index,
const std::string &  key 
)
inline

Set parameter variable key.

Parameters
indexThe parameter index.
keyThe key string to assign.
Return values
trueThe parameter does not have key previously.
falseThe parameter has key before.
Here is the caller graph for this function:

Member Data Documentation

◆ _func

std::string Alg_Line::_func
private

function name

◆ _opt

ALG_Opt Alg_Line::_opt
private

ALG options

◆ _params

std::vector<Param_Type> Alg_Line::_params
private

parameter variables

◆ _raw_str

std::string Alg_Line::_raw_str
private

raw string (original line)

◆ _returns

std::vector<Return_Type> Alg_Line::_returns
private

return variables


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