Add project files
This commit is contained in:
commit
f2fe6b8855
114 files changed
+20525
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/// Just enough of CMake's syntax to find and edit a command call in a CMakeLists.txt or a settings
|
||||
/// file without disturbing anything else in it: comments, layout and line endings stay as they
|
||||
/// were.
|
||||
namespace breeze::cmake
|
||||
{
|
||||
|
||||
/// One argument of a call. begin/end are byte offsets of the argument as written (quotes
|
||||
/// included); text is its value without the quotes.
|
||||
struct Token
|
||||
{
|
||||
std::size_t begin = 0;
|
||||
std::size_t end = 0;
|
||||
std::string text;
|
||||
bool quoted = false;
|
||||
};
|
||||
|
||||
/// A command call: name(args...). begin/end span the whole call, "name(" through ")".
|
||||
struct Call
|
||||
{
|
||||
std::string name;
|
||||
std::size_t begin = 0;
|
||||
std::size_t end = 0;
|
||||
std::vector<Token> args;
|
||||
};
|
||||
|
||||
/// Every call in `text`, in order, whose name `wanted` accepts. Comments, quoted strings and
|
||||
/// the arguments of other calls are never mistaken for calls.
|
||||
std::vector<Call> findCalls(const std::string& text,
|
||||
const std::function<bool(const std::string&)>& wanted);
|
||||
|
||||
/// The first set(<variable> ...) call.
|
||||
std::optional<Call> findSet(const std::string& text, const std::string& variable);
|
||||
|
||||
/// `value` as a quoted CMake argument.
|
||||
std::string quote(const std::string& value);
|
||||
|
||||
/// Replaces the token's text in `text` (offsets of later tokens are stale afterwards).
|
||||
void replaceToken(std::string& text, const Token& token, const std::string& replacement);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user