mmCEsim 0.3.0
mmWave Channel Estimation Simulation
|
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_Type & | returns (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_Type & | params (std::vector< Param_Type >::size_type index) const |
Parameter variable of an index. More... | |
const Param_Type & | params (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 |
Process line of Alg into standard formats.
The main process is done during constructing.
|
default |
Alg_Line::Alg_Line | ( | const std::string & | str, |
ALG_Opt | opt = ALG_Opt::NONE |
||
) |
|
inlineprivate |
|
inlineprivatenoexcept |
Find the first occupance of character in string that is not an escape or within quotes.
s | string |
c | the character to find |
|
privatenoexcept |
Find the first occupance of substring in string that is not an escape or within quotes.
s | string |
cs | the substring to find |
|
private |
Process function name and parameter variables.
v | The unprocessed function name and parameter variables token variable. |
|
private |
Process returns variables.
v | The unprocessed return variables token vector. |
|
privatenoexcept |
Remove the comment from the string.
Comment starts with hash(#).
s | The string to be modified. |
|
inlinenoexcept |
Get the function name.
|
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.
key | The key string to check. |
true | Parameter variables contain this key. |
false | Parameter variables do not contain this key. |
|
inlinenoexcept |
Check if parameters have repeated keys.
true | The parameters have repeated keys. |
false | The parameters do not have repeated keys. |
|
inlinenoexcept |
Check if parameters have unknown keys.
keys | All valid keys. |
true | All keys of parameters are valid. |
false | There exist unknown keys. |
|
inlinenoexcept |
|
inlinenoexcept |
Test whether the function name serves as an 'end'.
true | The function serves as 'end'. ('END', 'ELSE', etc.) |
false | The function does not serve as 'end'. |
|
inlinenoexcept |
Check whether the line is for function declaration.
true | The ALG_Opt is set to ALG_Opt::FUNCTION_DECLARATION |
false | The ALG_Opt is not ALG_Opt::FUNCTION_DECLARATION |
|
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'.
key | The key string to check. |
keys | The required keys if key exists. |
true | The key is not valid. |
false | The key is valid. |
|
inlinenoexcept |
Test whether the function name needs an 'end'.
true | The function needs 'end'. ('IF', 'ELSE', 'LOOP', etc.) |
false | The function does need 'end'. |
|
inline |
Get the parameter value with the key.
key | The key string. |
|
inlinenoexcept |
Parameter variables.
|
inline |
Parameter variable with a key.
key | The key string. |
|
inline |
Parameter variable of an index.
index | The index of the parameter index. |
|
inline |
Print Alg_Line contents (including return values, function names and parameters).
This is mostly used in internal debugging.
out | The output stream. |
prefix | The print prefix. |
|
inline |
Return the raw string of the line.
|
inlinenoexcept |
Return variables.
|
inline |
Return variable of an index.
index | The index of the return variable. |
|
inline |
Set parameter variable key.
index | The parameter index. |
key | The key string to assign. |
true | The parameter does not have key previously. |
false | The parameter has key before. |
|
private |
function name
|
private |
ALG options
|
private |
parameter variables
|
private |
raw string (original line)
|
private |
return variables