mirror of
https://github.com/hyprwm/hyprlang.git
synced 2024-12-22 09:59:48 +01:00
doxygen: init
This commit is contained in:
parent
70145fd8da
commit
efcd821ee0
3 changed files with 2930 additions and 46 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -10,4 +10,6 @@ compile_commands.json
|
||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
_deps
|
_deps
|
||||||
.vscode
|
.vscode
|
||||||
build/
|
build/
|
||||||
|
doxygen/
|
||||||
|
doxygen-awesome-css/
|
2822
hyprlang-docs
Normal file
2822
hyprlang-docs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,9 @@ struct SSpecialCategory;
|
||||||
|
|
||||||
namespace Hyprlang {
|
namespace Hyprlang {
|
||||||
|
|
||||||
/* types */
|
/*!
|
||||||
|
A very simple vector type
|
||||||
|
*/
|
||||||
struct SVector2D {
|
struct SVector2D {
|
||||||
float x = 0, y = 0;
|
float x = 0, y = 0;
|
||||||
|
|
||||||
|
@ -31,14 +33,18 @@ namespace Hyprlang {
|
||||||
class CParseResult {
|
class CParseResult {
|
||||||
public:
|
public:
|
||||||
bool error = false;
|
bool error = false;
|
||||||
/* Get this ParseResult's error string.
|
/*!
|
||||||
Pointer valid until the error string is changed or this
|
Get this ParseResult's error string.
|
||||||
object gets destroyed. */
|
Pointer valid until the error string is changed or this
|
||||||
|
object gets destroyed.
|
||||||
|
*/
|
||||||
const char* getError() const {
|
const char* getError() const {
|
||||||
return errorString;
|
return errorString;
|
||||||
}
|
}
|
||||||
/* Set an error contained by this ParseResult.
|
/*!
|
||||||
Creates a copy of the string, does not take ownership. */
|
Set an error contained by this ParseResult.
|
||||||
|
Creates a copy of the string, does not take ownership.
|
||||||
|
*/
|
||||||
void setError(const char* err);
|
void setError(const char* err);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -50,41 +56,58 @@ namespace Hyprlang {
|
||||||
friend class CConfig;
|
friend class CConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generic struct for options for the config parser */
|
/*!
|
||||||
|
Generic struct for options for the config parser
|
||||||
|
*/
|
||||||
struct SConfigOptions {
|
struct SConfigOptions {
|
||||||
/* Don't throw errors on missing values. */
|
/*!
|
||||||
|
Don't throw errors on missing values.
|
||||||
|
*/
|
||||||
bool verifyOnly = false;
|
bool verifyOnly = false;
|
||||||
|
|
||||||
/* Return all errors instead of the first */
|
/*!
|
||||||
|
Return all errors instead of just the first
|
||||||
|
*/
|
||||||
bool throwAllErrors = false;
|
bool throwAllErrors = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generic struct for options for handlers */
|
/*!
|
||||||
|
Generic struct for options for handlers
|
||||||
|
*/
|
||||||
struct SHandlerOptions {
|
struct SHandlerOptions {
|
||||||
bool allowFlags = false;
|
bool allowFlags = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generic struct for options for special categories */
|
/*!
|
||||||
|
Generic struct for options for special categories
|
||||||
|
*/
|
||||||
struct SSpecialCategoryOptions {
|
struct SSpecialCategoryOptions {
|
||||||
/* a key is the name of a value that will be the identifier of a special category
|
/*!
|
||||||
can be left null for no key, aka a generic one
|
a key is the name of a value that will be the identifier of a special category
|
||||||
keys are always strings. Default key value is "0" */
|
can be left null for no key, aka a generic one
|
||||||
|
keys are always strings. Default key value is "0"
|
||||||
|
*/
|
||||||
const char* key = nullptr;
|
const char* key = nullptr;
|
||||||
|
|
||||||
/* don't pop up an error if the config value is missing */
|
/*!
|
||||||
|
don't pop up an error if the config value is missing
|
||||||
|
*/
|
||||||
bool ignoreMissing = false;
|
bool ignoreMissing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* typedefs */
|
/*!
|
||||||
|
typedefs
|
||||||
|
*/
|
||||||
typedef CParseResult (*PCONFIGHANDLERFUNC)(const char* COMMAND, const char* VALUE);
|
typedef CParseResult (*PCONFIGHANDLERFUNC)(const char* COMMAND, const char* VALUE);
|
||||||
typedef CParseResult (*PCONFIGCUSTOMVALUEHANDLERFUNC)(const char* VALUE, void** data);
|
typedef CParseResult (*PCONFIGCUSTOMVALUEHANDLERFUNC)(const char* VALUE, void** data);
|
||||||
typedef void (*PCONFIGCUSTOMVALUEDESTRUCTOR)(void** data);
|
typedef void (*PCONFIGCUSTOMVALUEDESTRUCTOR)(void** data);
|
||||||
|
|
||||||
/* Container for a custom config value type
|
/*!
|
||||||
When creating, pass your handler.
|
Container for a custom config value type
|
||||||
Handler will receive a void** that points to a void* that you can set to your own
|
When creating, pass your handler.
|
||||||
thing. Pass a dtor to free whatever you allocated when the custom value type is being released.
|
Handler will receive a void** that points to a void* that you can set to your own
|
||||||
data may always be pointing to a nullptr.
|
thing. Pass a dtor to free whatever you allocated when the custom value type is being released.
|
||||||
|
data may always be pointing to a nullptr.
|
||||||
*/
|
*/
|
||||||
class CConfigCustomValueType {
|
class CConfigCustomValueType {
|
||||||
public:
|
public:
|
||||||
|
@ -101,7 +124,9 @@ namespace Hyprlang {
|
||||||
friend class CConfig;
|
friend class CConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Container for a config value */
|
/*!
|
||||||
|
Container for a config value
|
||||||
|
*/
|
||||||
class CConfigValue {
|
class CConfigValue {
|
||||||
public:
|
public:
|
||||||
CConfigValue();
|
CConfigValue();
|
||||||
|
@ -116,7 +141,16 @@ namespace Hyprlang {
|
||||||
CConfigValue(CConfigValue&) = delete;
|
CConfigValue(CConfigValue&) = delete;
|
||||||
~CConfigValue();
|
~CConfigValue();
|
||||||
|
|
||||||
void* dataPtr() const;
|
/*!
|
||||||
|
Return a pointer to the data. Prefer getValue().
|
||||||
|
*/
|
||||||
|
void* dataPtr() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get the contained value as an std::any.
|
||||||
|
For strings, this is a const char*.
|
||||||
|
For custom data types, this is a CConfigCustomValueType*.
|
||||||
|
*/
|
||||||
std::any getValue() const {
|
std::any getValue() const {
|
||||||
switch (m_eType) {
|
switch (m_eType) {
|
||||||
case CONFIGDATATYPE_EMPTY: throw;
|
case CONFIGDATATYPE_EMPTY: throw;
|
||||||
|
@ -148,55 +182,79 @@ namespace Hyprlang {
|
||||||
friend class CConfig;
|
friend class CConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Base class for a config file */
|
/*!
|
||||||
|
Base class for a config file
|
||||||
|
*/
|
||||||
class CConfig {
|
class CConfig {
|
||||||
public:
|
public:
|
||||||
CConfig(const char* configPath, const SConfigOptions& options);
|
CConfig(const char* configPath, const SConfigOptions& options);
|
||||||
~CConfig();
|
~CConfig();
|
||||||
|
|
||||||
/* Add a config value, for example myCategory:myValue.
|
/*!
|
||||||
This has to be done before commence()
|
Add a config value, for example myCategory:myValue.
|
||||||
Value provided becomes default */
|
This has to be done before commence()
|
||||||
|
Value provided becomes default.
|
||||||
|
*/
|
||||||
void addConfigValue(const char* name, const CConfigValue& value);
|
void addConfigValue(const char* name, const CConfigValue& value);
|
||||||
|
|
||||||
/* Register a handler. Can be called anytime, though not recommended
|
/*!
|
||||||
to do this dynamically */
|
Register a handler. Can be called anytime, though not recommended
|
||||||
|
to do this dynamically .
|
||||||
|
*/
|
||||||
void registerHandler(PCONFIGHANDLERFUNC func, const char* name, SHandlerOptions options);
|
void registerHandler(PCONFIGHANDLERFUNC func, const char* name, SHandlerOptions options);
|
||||||
|
|
||||||
/* Commence the config state. Config becomes immutable, as in
|
/*!
|
||||||
no new values may be added or removed. Required for parsing. */
|
Commence the config state. Config becomes immutable, as in
|
||||||
|
no new values may be added or removed. Required for parsing.
|
||||||
|
*/
|
||||||
void commence();
|
void commence();
|
||||||
|
|
||||||
/* Add a special category. Can be done dynamically. */
|
/*!
|
||||||
|
Add a special category. Can be done dynamically.
|
||||||
|
*/
|
||||||
void addSpecialCategory(const char* name, SSpecialCategoryOptions options);
|
void addSpecialCategory(const char* name, SSpecialCategoryOptions options);
|
||||||
|
|
||||||
/* Add a config value to a special category */
|
/*!
|
||||||
|
Add a config value to a special category.
|
||||||
|
*/
|
||||||
void addSpecialConfigValue(const char* cat, const char* name, const CConfigValue value);
|
void addSpecialConfigValue(const char* cat, const char* name, const CConfigValue value);
|
||||||
|
|
||||||
/* Parse the config. Refresh the values. */
|
/*!
|
||||||
|
Parse the config. Refresh the values.
|
||||||
|
*/
|
||||||
CParseResult parse();
|
CParseResult parse();
|
||||||
|
|
||||||
/* Same as parse(), but parse a specific file, without any refreshing.
|
/*!
|
||||||
recommended to use for stuff like source = path.conf */
|
Same as parse(), but parse a specific file, without any refreshing.
|
||||||
|
recommended to use for stuff like source = path.conf
|
||||||
|
*/
|
||||||
CParseResult parseFile(std::string file);
|
CParseResult parseFile(std::string file);
|
||||||
|
|
||||||
/* Parse a single "line", dynamically.
|
/*!
|
||||||
Values set by this are temporary and will be overwritten
|
Parse a single "line", dynamically.
|
||||||
by default / config on the next parse() */
|
Values set by this are temporary and will be overwritten
|
||||||
|
by default / config on the next parse()
|
||||||
|
*/
|
||||||
CParseResult parseDynamic(const char* line);
|
CParseResult parseDynamic(const char* line);
|
||||||
CParseResult parseDynamic(const char* command, const char* value);
|
CParseResult parseDynamic(const char* command, const char* value);
|
||||||
|
|
||||||
/* Get a config's value ptr. These are static.
|
/*!
|
||||||
nullptr on fail */
|
Get a config's value ptr. These are static.
|
||||||
|
nullptr on fail
|
||||||
|
*/
|
||||||
CConfigValue* getConfigValuePtr(const char* name);
|
CConfigValue* getConfigValuePtr(const char* name);
|
||||||
|
|
||||||
/* Get a special category's config value ptr. These are only static for static (key-less)
|
/*!
|
||||||
|
Get a special category's config value ptr. These are only static for static (key-less)
|
||||||
categories, unless a new variable is added via addSpecialConfigValue.
|
categories, unless a new variable is added via addSpecialConfigValue.
|
||||||
key can be nullptr for static categories. Cannot be nullptr for id-based categories.
|
key can be nullptr for static categories. Cannot be nullptr for id-based categories.
|
||||||
nullptr on fail. */
|
nullptr on fail.
|
||||||
|
*/
|
||||||
CConfigValue* getSpecialConfigValuePtr(const char* category, const char* name, const char* key = nullptr);
|
CConfigValue* getSpecialConfigValuePtr(const char* category, const char* name, const char* key = nullptr);
|
||||||
|
|
||||||
/* Get a config value's stored value. Empty on fail*/
|
/*!
|
||||||
|
Get a config value's stored value. Empty on fail
|
||||||
|
*/
|
||||||
std::any getConfigValue(const char* name) {
|
std::any getConfigValue(const char* name) {
|
||||||
CConfigValue* val = getConfigValuePtr(name);
|
CConfigValue* val = getConfigValuePtr(name);
|
||||||
if (!val)
|
if (!val)
|
||||||
|
@ -204,7 +262,9 @@ namespace Hyprlang {
|
||||||
return val->getValue();
|
return val->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a special config value's stored value. Empty on fail. */
|
/*!
|
||||||
|
Get a special config value's stored value. Empty on fail.
|
||||||
|
*/
|
||||||
std::any getSpecialConfigValue(const char* category, const char* name, const char* key = nullptr) {
|
std::any getSpecialConfigValue(const char* category, const char* name, const char* key = nullptr) {
|
||||||
CConfigValue* val = getSpecialConfigValuePtr(category, name, key);
|
CConfigValue* val = getSpecialConfigValuePtr(category, name, key);
|
||||||
if (!val)
|
if (!val)
|
||||||
|
|
Loading…
Reference in a new issue