22 #define MAX_LEN_ERRORBUF 1024
27 #define DEBUG_ENTRIES(...)
39 const struct section *psection,
const char *file,
40 const char *
function,
int line,
const char *format, ...)
45 va_start(args, format);
50 "In %s() [%s:%d]: secfile '%s' in section '%s': %s",
function,
52 psection !=
nullptr ?
section_name(psection) :
"nullptr",
61 return (
nullptr != psection ? psection->
name :
nullptr);
71 secfile->
name =
nullptr;
99 section_list_destroy(secfile->
sections);
100 delete[] secfile->
name;
101 secfile->
name =
nullptr;
131 if (
'$' == tok[0] ||
'"' == tok[0]) {
132 bool escaped = (
'"' == tok[0]);
140 || ((
'-' == tok[0] ||
'+' == tok[0]) && tok[1].isDigit())) {
141 if (tok.contains(
'.')) {
143 auto fvalue = tok.toFloat(&ok);
151 auto ivalue = tok.toInt(&ok, 0);
162 if (tok.compare(QStringLiteral(
"FALSE"), Qt::CaseInsensitive) == 0
163 || tok.compare(QStringLiteral(
"TRUE"), Qt::CaseInsensitive) == 0) {
165 (tok.compare(QStringLiteral(
"TRUE"), Qt::CaseInsensitive) == 0);
#define fc_assert_ret(condition)
void section_destroy(struct section *psection)
Remove this section from the secfile.
struct entry * section_entry_str_new(struct section *psection, const QString &name, const QString &value, bool escaped)
Returns a new entry of type ENTRY_STR.
const char * secfile_name(const struct section_file *secfile)
Return the filename the section file was loaded as, or "(anonymous)" if this sectionfile was created ...
struct entry * section_entry_int_new(struct section *psection, const QString &name, int value)
Returns a new entry of type ENTRY_INT.
struct entry * section_entry_bool_new(struct section *psection, const QString &name, bool value)
Returns a new entry of type ENTRY_BOOL.
struct entry * section_entry_float_new(struct section *psection, const QString &name, float value)
Returns a new entry of type ENTRY_FLOAT.
void secfile_log(const struct section_file *secfile, const struct section *psection, const char *file, const char *function, int line, const char *format,...)
Edit the error_buffer.
static char error_buffer[MAX_LEN_ERRORBUF]
const char * secfile_error()
Returns the last error which occurred in a string.
bool entry_from_token(struct section *psection, const QString &name, const QString &tok)
Add entry to section from token.
struct section_file * secfile_new(bool allow_duplicates)
Create a new empty section file.
void secfile_allow_digital_boolean(struct section_file *secfile, bool allow_digital_boolean)
Set if we could consider values 0 and 1 as boolean.
const char * section_name(const struct section *psection)
Returns the section name.
#define DEBUG_ENTRIES(...)
void secfile_destroy(struct section_file *secfile)
Free a section file.
#define SECFILE_RETURN_IF_FAIL(secfile, psection, condition)
struct section_file::@7 hash
QMultiHash< QString, struct entry * > * entries
struct section_list * sections
bool allow_digital_boolean
unsigned int num_includes
unsigned int num_long_comments
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
QString remove_escapes(const QString &str, bool full_escapes)
Copies a string.