![]() |
Version: 1.0 |
Go to the source code of this file.
Classes | |
class | GenerateCodeClass |
Functions | |
std::string | DefaultEmptyFunc (size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id) |
std::string | BeforeMainShiftOne (size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id) |
std::string | BeforeMainShiftTwo (size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id) |
std::string | BeforeEnd (size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id) |
std::string | AfterEnd (size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id) |
std::string | AfterEndNoLoop (size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id) |
bool | GenerateDragCode (const BinaryDrag< conact > &bd, bool with_gotos, std::string before(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), std::string after(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), const std::string prefix, size_t start_id, const std::vector< std::vector< size_t >> mapping, size_t end_group_id) |
Overload. No output stream required in this case. More... | |
size_t | GenerateDragCode (std::ostream &os, const BinaryDrag< conact > &bd, bool with_gotos, std::string before(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), std::string after(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), const std::string prefix, size_t start_id, const std::vector< std::vector< size_t >> mapping, size_t end_group_id) |
This function generates the code for the given drag reversing the output into the specified stream. More... | |
size_t | GenerateLineForestCode (std::ostream &os, const LineForestHandler &lfh, std::string prefix, size_t start_id, std::string before_main(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), std::string after_main(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), std::string before_end(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id), std::string after_end(size_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id)) |
Generate the C++ code for the given Forest. More... | |
std::string AfterEnd | ( | size_t | index, |
const std::string & | prefix, | ||
const std::vector< std::vector< size_t >> & | mapping, | ||
size_t | end_group_id | ||
) |
Definition at line 53 of file graph_code_generator.cpp.
std::string AfterEndNoLoop | ( | size_t | index, |
const std::string & | prefix, | ||
const std::vector< std::vector< size_t >> & | mapping, | ||
size_t | end_group_id | ||
) |
Definition at line 58 of file graph_code_generator.cpp.
std::string BeforeEnd | ( | size_t | index, |
const std::string & | prefix, | ||
const std::vector< std::vector< size_t >> & | mapping, | ||
size_t | end_group_id | ||
) |
Definition at line 48 of file graph_code_generator.cpp.
std::string BeforeMainShiftOne | ( | size_t | index, |
const std::string & | prefix, | ||
const std::vector< std::vector< size_t >> & | mapping, | ||
size_t | end_group_id | ||
) |
Definition at line 28 of file graph_code_generator.cpp.
std::string BeforeMainShiftTwo | ( | size_t | index, |
const std::string & | prefix, | ||
const std::vector< std::vector< size_t >> & | mapping, | ||
size_t | end_group_id | ||
) |
Definition at line 41 of file graph_code_generator.cpp.
std::string DefaultEmptyFunc | ( | size_t | index, |
const std::string & | prefix, | ||
const std::vector< std::vector< size_t >> & | mapping, | ||
size_t | end_group_id | ||
) |
Definition at line 15 of file graph_code_generator.cpp.
bool GenerateDragCode | ( | const BinaryDrag< conact > & | bd, |
bool | with_gotos, | ||
std::string | beforesize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id, | ||
std::string | aftersize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id, | ||
const std::string | prefix, | ||
size_t | start_id, | ||
const std::vector< std::vector< size_t >> | mapping, | ||
size_t | end_group_id | ||
) |
Overload. No output stream required in this case.
Definition at line 246 of file graph_code_generator.cpp.
size_t GenerateDragCode | ( | std::ostream & | os, |
const BinaryDrag< conact > & | bd, | ||
bool | with_gotos = false , |
||
std::string | beforesize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id = DefaultEmptyFunc , |
||
std::string | aftersize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id = DefaultEmptyFunc , |
||
const std::string | prefix = "" , |
||
size_t | start_id = 0 , |
||
const std::vector< std::vector< size_t >> | mapping = {} , |
||
size_t | end_group_id = 0 |
||
) |
This function generates the code for the given drag reversing the output into the specified stream.
Function pointer parameters are not well treated by doxygen. TODO fix it.
[in] | os | Where to write the code (output stream). |
[in] | bd | BinaryDrag<conact> for which generating the code. |
[in] | with_gotos | Whether to add gotos or not during code generation. |
[in] | before | Pointer to the function which defines the string that should be put in the code before a tree. When dealing with forests for example you will need pass to GenerateDragCode a "before" function like the following one (i identifies the tree): [mapping](int i, const std::string& prefix) -> std::string {
return prefix + "tree_" + string(i) + ": if ((c+=1) >= w - 1) goto " + prefix + "break_0_" + string(mapping[0][i]) + ";\n";
}
[mapping](int i, const std::string& prefix) -> std::string {
return prefix + "tree_" + string(i) + ": if ((c+=2) >= w - 2) { if (c > w - 2) { goto " + prefix + \
"break_0_" + string(mapping_[0][i]) + "; } else { goto " + prefix + \
"break_1_" + string(mapping_[1][i]) + "; } } \n";
}
|
[in] | after | Pointer to the function which defines the string that should be put into the code after a tree. When dealing with forest for example you will need pass to GenerateDragCode a "before" function like the following one: [mapping](int i, const std::string& prefix) -> std::string {
return string(2, '\t') + "continue;\n";
}
|
[in] | prefix | String to add before tree names. This variable will be passed to the before and after functions |
[in] | start_id | Is the id from which start node enumeration when dealing with drags. It is especially useful to avoid multiple defined labels when dealing with multiple forests in the same code, like for example when having a special forest for the first line e for the last one. |
[in] | mapping | Mapping between main and end-of-the line trees. Default value is an empty mapping. |
[in] | end_group_id | It is the id of the end-line forest group. It is needed when an algorithm requires multiple end-line forest group, such as when dealing with block-based approaches. Default value is zero. |
Definition at line 265 of file graph_code_generator.cpp.
size_t GenerateLineForestCode | ( | std::ostream & | os, |
const LineForestHandler & | lfh, | ||
std::string | prefix, | ||
size_t | start_id, | ||
std::string | before_mainsize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id = BeforeMainShiftOne , |
||
std::string | after_mainsize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id = DefaultEmptyFunc , |
||
std::string | before_endsize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id = BeforeEnd , |
||
std::string | after_endsize_t index, const std::string &prefix, const std::vector< std::vector< size_t >> &mapping, size_t end_group_id = AfterEnd |
||
) |
Generate the C++ code for the given Forest.
Parameters description missing. (TODO)
Definition at line 298 of file graph_code_generator.cpp.