1 #ifndef Rosebud_Utility_H
2 #define Rosebud_Utility_H
3 #include <Rosebud/Ast.h>
5 #include <Sawyer/Graph.h>
6 #include <Sawyer/Message.h>
7 #include <Sawyer/Optional.h>
9 #include <boost/filesystem.hpp>
15 #define THIS_LOCATION locationDirective(__LINE__, __FILE__)
48 std::string
matching(
const std::string&);
73 std::string
prefixLines(
const std::string &s,
const std::string &prefix);
74 void prefixLines(std::vector<std::string> &lines,
const std::string &prefix);
78 size_t editDistance(
const std::string &src,
const std::string &tgt);
88 std::string
bestMatch(
const std::vector<std::string> &candidates,
const std::string &sample);
102 boost::filesystem::path
findRoseRootDir(
const boost::filesystem::path&);
115 boost::filesystem::path
toPath(
const std::string &symbol,
const std::string &extension);
130 std::string
makeBlockComment(
const std::string &text,
const std::string &opening);
131 std::vector<std::string>
makeBlockComment(
const std::vector<std::string> &textLines,
const std::string &opening);
139 std::string
makeTitleComment(
const std::string &multiLine,
const std::string &prefix,
char bar,
size_t width);
140 std::vector<std::string>
makeTitleComment(
const std::vector<std::string> &lines,
const std::string &prefix,
char bar,
size_t width);
148 std::string
appendToDoxygen(
const std::string &existingComment,
const std::string &newText);
181 const Token &end,
const std::string &mesg);
257 std::string
constRef(
const std::string &type);
285 std::vector<std::string>
extractCpp(std::string&,
const std::regex&,
size_t capture);
std::string s
Class name is the key.
Like C++ protected access.
double relativeDifference(const std::string &src, const std::string &tgt)
Compute the relative difference between two strings.
Graph containing user-defined vertices and edges.
std::vector< std::string > splitIntoLines(const std::string &)
Split a multi-line string into one string per line.
Hierarchy classHierarchy(const Classes &)
Generate the class hierarchy from the specified class definitions.
std::string removeVolatileMutable(const std::string &type)
Rmove "volatile" and "mutable" from the beginning of a type string.
Classes bottomUp(Hierarchy &)
Return all the class definitions so that derived classes appear before base classes.
std::string appendToDoxygen(const std::string &existingComment, const std::string &newText)
Append text to a Doxygen comment.
HierarchyKey(const std::string &s)
Construct key from name.
Command-line settings for the rosebud tool.
bool showingLocations
Output should show source location from whence it came.
Rosebud is a tool to generate code for ROSE.
std::string makeBlockComment(const std::string &text, const std::string &opening)
Make a block comment.
void eraseBlankLines(std::vector< std::string > &)
Remove lines that are empty or contain only white space.
Classes topDown(Hierarchy &)
Return all the class definitions so that base classes are before derived classes. ...
Settings settings
Command-line settings for the rosebud tool.
boost::filesystem::path toPath(const std::string &symbol, const std::string &extension)
Convert a qualified C++ name to a relative path.
std::string backend
Name of main backend code generator to use.
std::vector< Ast::ClassPtr > Classes
Ordered sequence of classes.
bool operator<(const HierarchyKey &other) const
Compare keys.
When
When something should be done.
void message(Sawyer::Message::Importance, const Ast::FilePtr &, const Token &, const std::string &mesg)
Print a diagnostic message to standard error.
std::string bestMatch(const std::vector< std::string > &candidates, const std::string &sample)
Returns the best match.
bool debugging
Generate additional debugging output.
std::string locationDirective(size_t line, const std::string &file)
Input location information.
bool usingColor()
True if we're using color output for diagnostics.
std::string makeTitleComment(const std::string &multiLine, const std::string &prefix, char bar, size_t width)
Make a title comment that spans the entire width of the source code.
size_t nErrors
Number of error messages reported.
size_t editDistance(const std::string &src, const std::string &tgt)
Compute the Damerau-Levenshtein edit distance between two strings.
Classes derivedClasses(const Ast::ClassPtr &, const Hierarchy &)
Return all known subclasses.
void checkClassHierarchy(Hierarchy &)
Check for problems such as cycles in the class hiearchy and report them as errors.
boost::filesystem::path findRoseRootDir(const boost::filesystem::path &)
Find the root of the ROSE source tree.
std::string prefixLines(const std::string &s, const std::string &prefix)
Add a prefix to every line.
void trimBlankLines(std::vector< std::string > &)
Trim leading, trailing, and internal blank lines and trailing white space.
std::string firstPublicBaseClass(const Ast::ClassPtr &)
Name of first public base class.
Importance
Level of importance for a message.
Key for ordering classes in the class hierarchy.
std::string constRef(const std::string &type)
Turn a type into a const reference to the type.
std::shared_ptr< File > FilePtr
Shared-ownership pointer to a File.
std::shared_ptr< Class > ClassPtr
Shared-ownership pointer to a Class.
HierarchyKey(const Ast::ClassPtr &c)
Construct key from class.
std::vector< std::string > extractCpp(std::string &, const std::regex &, size_t capture)
Extract all matching C preprocessor directives from the text.
bool isBaseClass(const Ast::ClassPtr &, const Hierarchy &)
True if the class is a base class of some other class.
std::string matching(const std::string &)
Return the matching opening or closing construct.
std::string toCppSymbol(const std::string &)
Convert a C++ qualified name to a CPP symbol.
bool showingWarnings
Show warnings about the input.
std::shared_ptr< Node > NodePtr
Shared-ownership pointer to a Node.
When usingColor
Use ANSI color escapes in the diagnostic output.
boost::filesystem::path relativeToRoseSource(const boost::filesystem::path &)
Convert a file path to a ROSE-relative path.
std::string toString(Access)
Convert an access enum to a C++ string.
std::vector< Ast::PropertyPtr > allConstructorArguments(const Ast::ClassPtr &, const Hierarchy &)
Properties that form constructor arguments.
std::string serializer
Name of the serializer code generator to use.
std::string messageString(Sawyer::Message::Importance, const std::string &mesg)
Convert an importance level and message to an error output string.