R8 phase 1: extract app/engine shared utilities into shared/include/oakutil
Move the pure-header utilities shared by app/ and engine/ out of engine/common/ into a new shared/include/oakutil/ layer (define, lerp, decibel, digit, range, crashpadutils, autoscroll, qtutils, filefunctions declarations, and a trimmed xmlutils exposing a CancelAtom-free void* overload). engine/common/ keeps forwarding headers so internal include paths are unchanged; app/ now includes oakutil/* directly. engine/node/project.h gains an explicit NodeGroup forward declaration previously obtained transitively through the old xmlutils.h.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_AUTOSCROLL_H
|
||||
#define OAK_AUTOSCROLL_H
|
||||
|
||||
#include "oakutil/define.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class AutoScroll {
|
||||
public:
|
||||
enum Method { k_none, k_page, k_smooth };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_AUTOSCROLL_H
|
||||
@@ -0,0 +1,41 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_CRASHPADUTILS_H
|
||||
#define OAK_CRASHPADUTILS_H
|
||||
|
||||
#include <client/crashpad_client.h>
|
||||
|
||||
// Copied from base::FilePath to match its macro
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
// On most platforms, native pathnames are char arrays, and the encoding
|
||||
// may or may not be specified. On Mac OS X, native pathnames are encoded
|
||||
// in UTF-8.
|
||||
#define QSTRING_TO_BASE_STRING(x) x.toStdString()
|
||||
#define BASE_STRING_TO_QSTRING(x) QString::fromStdString(x)
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
// On Windows, for Unicode-aware applications, native pathnames are wchar_t
|
||||
// arrays encoded in UTF-16.
|
||||
#define QSTRING_TO_BASE_STRING(x) x.toStdWString()
|
||||
#define BASE_STRING_TO_QSTRING(x) QString::fromStdWString(x)
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
#endif // OAK_CRASHPADUTILS_H
|
||||
@@ -0,0 +1,104 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_DECIBEL_H
|
||||
#define OAK_DECIBEL_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <cmath>
|
||||
|
||||
//#define ALLOW_RETURNING_INFINITY
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class Decibel {
|
||||
public:
|
||||
// In basically all circumstances, this should calculate to 0.0 linear
|
||||
static constexpr double minimum = -200.0;
|
||||
|
||||
static double from_linear(double linear)
|
||||
{
|
||||
double v = double(20.0) * std::log10(linear);
|
||||
#ifndef ALLOW_RETURNING_INFINITY
|
||||
if (std::isinf(v)) {
|
||||
return minimum;
|
||||
}
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
static double to_linear(double decibel)
|
||||
{
|
||||
double to_linear = std::pow(double(10.0), decibel / double(20.0));
|
||||
|
||||
// Minimum threshold that we figure is close enough to 0 that we may as well just return 0
|
||||
if (to_linear < 0.000001) {
|
||||
return 0;
|
||||
} else {
|
||||
return to_linear;
|
||||
}
|
||||
}
|
||||
|
||||
static double from_logarithmic(double logarithmic)
|
||||
{
|
||||
if (logarithmic < 0.001)
|
||||
#ifdef ALLOW_RETURNING_INFINITY
|
||||
return std::numeric_limits<double>::infinity();
|
||||
#else
|
||||
return minimum;
|
||||
#endif
|
||||
else if (logarithmic > 0.99)
|
||||
return 0;
|
||||
else
|
||||
return 20.0 * std::log10(-std::log(1 - logarithmic) / lo_g100);
|
||||
}
|
||||
|
||||
static double to_logarithmic(double decibel)
|
||||
{
|
||||
if (qFuzzyIsNull(decibel)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 1 - std::exp(-std::pow(10.0, decibel / 20.0) * lo_g100);
|
||||
}
|
||||
}
|
||||
|
||||
static double linear_to_logarithmic(double linear)
|
||||
{
|
||||
return 1 - std::exp(-linear * lo_g100);
|
||||
}
|
||||
|
||||
static double logarithmic_to_linear(double logarithmic)
|
||||
{
|
||||
if (logarithmic > 0.99) {
|
||||
return 1;
|
||||
} else {
|
||||
return -std::log(1 - logarithmic) / lo_g100;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr double lo_g100 = 4.60517018599;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_DECIBEL_H
|
||||
@@ -0,0 +1,68 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_OLIVECOMMONDEFINE_H
|
||||
#define OAK_OLIVECOMMONDEFINE_H
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
/// The minimum size an icon in ProjectExplorer can be
|
||||
const int k_project_icon_size_minimum = 16;
|
||||
|
||||
/// The maximum size an icon in ProjectExplorer can be
|
||||
const int k_project_icon_size_maximum = 256;
|
||||
|
||||
/// The default size an icon in ProjectExplorer can be
|
||||
const int k_project_icon_size_default = 64;
|
||||
|
||||
const int k_bytes_in_gigabyte = 1073741824;
|
||||
|
||||
}
|
||||
|
||||
#define MACRO_NAME_AS_STR(s) #s
|
||||
#define MACRO_VAL_AS_STR(s) MACRO_NAME_AS_STR(s)
|
||||
|
||||
#define OLIVE_NS_CONST_ARG(x, y) \
|
||||
QArgument<const olive::x>("const " MACRO_VAL_AS_STR(olive) "::" #x, y)
|
||||
#define OLIVE_NS_ARG(x, y) \
|
||||
QArgument<olive::x>(MACRO_VAL_AS_STR(olive) "::" #x, y)
|
||||
#define OLIVE_NS_RETURN_ARG(x, y) \
|
||||
QReturnArgument<olive::x>(MACRO_VAL_AS_STR(olive) "::" #x, y)
|
||||
|
||||
/**
|
||||
* Copy/move deleters. Similar to Q_DISABLE_COPY_MOVE, et al. but those functions are not present in Qt < 5.13 so we
|
||||
* use our own functions for portability.
|
||||
*/
|
||||
|
||||
#define DISABLE_COPY(Class) \
|
||||
Class(const Class &) = delete; \
|
||||
Class &operator=(const Class &) = delete;
|
||||
|
||||
#define DISABLE_MOVE(Class) \
|
||||
Class(Class &&) = delete; \
|
||||
Class &operator=(Class &&) = delete;
|
||||
|
||||
#define DISABLE_COPY_MOVE(Class) \
|
||||
DISABLE_COPY(Class) \
|
||||
DISABLE_MOVE(Class)
|
||||
|
||||
#endif // OAK_OLIVECOMMONDEFINE_H
|
||||
@@ -0,0 +1,48 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_DIGIT_H
|
||||
#define OAK_DIGIT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
inline int64_t get_digit_count(int64_t input)
|
||||
{
|
||||
input = std::abs(input);
|
||||
|
||||
int64_t lim = 10;
|
||||
int64_t digit = 1;
|
||||
|
||||
while (input >= lim) {
|
||||
lim *= 10;
|
||||
digit++;
|
||||
}
|
||||
|
||||
return digit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_DIGIT_H
|
||||
@@ -0,0 +1,109 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_FILEFUNCTIONS_H
|
||||
#define OAK_FILEFUNCTIONS_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
|
||||
#include "oakutil/define.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A collection of static file and directory functions
|
||||
*/
|
||||
class FileFunctions {
|
||||
public:
|
||||
/**
|
||||
* @brief Returns true if the application is running in portable mode
|
||||
*
|
||||
* In portable mode, any persistent configuration files should be made in a path relative to the application rather
|
||||
* than in the user's home folder.
|
||||
*/
|
||||
static bool is_portable();
|
||||
|
||||
static QString get_unique_file_identifier(const QString &filename);
|
||||
|
||||
static QString get_configuration_location();
|
||||
|
||||
static QString get_application_path();
|
||||
|
||||
static QString get_temp_file_path();
|
||||
|
||||
static bool can_copy_directory_without_overwriting(const QString &source,
|
||||
const QString &dest);
|
||||
|
||||
static void copy_directory(const QString &source, const QString &dest,
|
||||
bool overwrite = false);
|
||||
|
||||
static bool directory_is_valid(const QDir &dir,
|
||||
bool try_to_create_if_not_exists = true);
|
||||
|
||||
/**
|
||||
* @brief Ensures a given filename has a certain extension
|
||||
*
|
||||
* Checks if the filename has the extension provided and appends it if not. The extension is
|
||||
* checked case-insensitive. The extension should be provided with no dot (e.g. "ove" rather than
|
||||
* ".ove").
|
||||
|
||||
* @return The filename provided either untouched or with the extension appended to it.
|
||||
*/
|
||||
static QString ensure_filename_extension(QString fn,
|
||||
const QString &extension);
|
||||
|
||||
static QString read_file_as_string(const QString &filename);
|
||||
|
||||
/**
|
||||
* @brief Returns a temporary filename that can be used while writing rather than the original
|
||||
*
|
||||
* If overwriting a file, it's safest to write to a new file first and then only replace it at
|
||||
* the end so that if the program crashes or the user cancels the save half way through, the
|
||||
* original file is still intact.
|
||||
*
|
||||
* This function returns a slight variant of the filename provided that's guaranteed to not exist
|
||||
* and therefore won't overwrite anything important.
|
||||
*/
|
||||
static QString get_safe_temporary_filename(const QString &original);
|
||||
|
||||
/**
|
||||
* @brief Renames a file from `from` to `to`, deleting `to` if such a file already exists first
|
||||
*/
|
||||
static bool rename_file_allow_overwrite(const QString &from,
|
||||
const QString &to);
|
||||
|
||||
inline static QString get_formatted_executable_for_platform(QString unformatted)
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
unformatted.append(QStringLiteral(".exe"));
|
||||
#endif
|
||||
|
||||
return unformatted;
|
||||
}
|
||||
|
||||
static QString get_auto_recovery_root();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_FILEFUNCTIONS_H
|
||||
@@ -0,0 +1,42 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_LERP_H
|
||||
#define OAK_LERP_H
|
||||
|
||||
template <typename T>
|
||||
/**
|
||||
* @brief Linearly interpolate a value between a and b using t
|
||||
*
|
||||
* t should be a number between 0.0 and 1.0. 0.0 will return a, 1.0 will return b, and between will return a value
|
||||
* in between a and b at that point linearly.
|
||||
*/
|
||||
T lerp(T a, T b, double t)
|
||||
{
|
||||
return (a * (1.0 - t)) + (b * t);
|
||||
}
|
||||
|
||||
template <typename T> T lerp(T a, T b, float t)
|
||||
{
|
||||
return (a * (1.0f - t)) + (b * t);
|
||||
}
|
||||
|
||||
#endif // OAK_LERP_H
|
||||
@@ -0,0 +1,113 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_QTVERSIONABSTRACTION_H
|
||||
#define OAK_QTVERSIONABSTRACTION_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QComboBox>
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
#include <QFontMetrics>
|
||||
#include <QFrame>
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class QtUtils {
|
||||
public:
|
||||
/**
|
||||
* @brief Retrieves the width of a string according to certain QFontMetrics
|
||||
*
|
||||
* QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the
|
||||
* latter was only introduced in 5.11+. This function wraps the latter for 5.11+ and the former for
|
||||
* earlier.
|
||||
*/
|
||||
static int q_font_metrics_width(QFontMetrics fm, const QString &s);
|
||||
|
||||
static QFrame *create_horizontal_line();
|
||||
|
||||
static QFrame *create_vertical_line();
|
||||
|
||||
static QDateTime get_creation_date(const QFileInfo &info);
|
||||
|
||||
static QString get_formatted_date_time(const QDateTime &dt);
|
||||
|
||||
static QStringList word_wrap_string(const QString &s, const QFontMetrics &fm,
|
||||
int bounding_width);
|
||||
|
||||
static Qt::KeyboardModifiers
|
||||
flip_control_and_shift_modifiers(Qt::KeyboardModifiers e);
|
||||
|
||||
static void set_combo_box_data(QComboBox *cb, int data);
|
||||
static void set_combo_box_data(QComboBox *cb, const QString &data);
|
||||
|
||||
template <typename T> static T *get_parent_of_type(const QObject *child)
|
||||
{
|
||||
QObject *t = child->parent();
|
||||
|
||||
while (t) {
|
||||
if (T *p = dynamic_cast<T *>(t)) {
|
||||
return p;
|
||||
}
|
||||
t = t->parent();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static QColor to_q_color(const core::Color &c);
|
||||
|
||||
/**
|
||||
* @brief Convert a pointer to a value that can be sent between NodeParams
|
||||
*/
|
||||
static QVariant ptr_to_value(void *ptr)
|
||||
{
|
||||
return reinterpret_cast<quintptr>(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert a NodeParam value to a pointer of any kind
|
||||
*/
|
||||
template <class T> static T *value_to_ptr(const QVariant &ptr)
|
||||
{
|
||||
return reinterpret_cast<T *>(ptr.value<quintptr>());
|
||||
}
|
||||
};
|
||||
|
||||
namespace core
|
||||
{
|
||||
|
||||
uint qHash(const core::Rational &r, uint seed = 0);
|
||||
uint qHash(const core::TimeRange &r, uint seed = 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(olive::core::Rational)
|
||||
Q_DECLARE_METATYPE(olive::core::Color)
|
||||
Q_DECLARE_METATYPE(olive::core::TimeRange)
|
||||
Q_DECLARE_METATYPE(olive::core::Bezier)
|
||||
Q_DECLARE_METATYPE(olive::core::AudioParams)
|
||||
Q_DECLARE_METATYPE(olive::core::SampleBuffer)
|
||||
|
||||
#endif // OAK_QTVERSIONABSTRACTION_H
|
||||
@@ -0,0 +1,30 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_RANGE_H
|
||||
#define OAK_RANGE_H
|
||||
|
||||
template <typename T> bool in_range(T a, T b, T range)
|
||||
{
|
||||
return (a >= b - range && a <= b + range);
|
||||
}
|
||||
|
||||
#endif // OAK_RANGE_H
|
||||
@@ -0,0 +1,50 @@
|
||||
/***
|
||||
|
||||
Oak - Non-Linear Video Editor
|
||||
Copyright (C) 2022 Olive Team
|
||||
Modifications Copyright (C) 2025 mikesolar
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef OAK_XMLUTILS_SHARED_H
|
||||
#define OAK_XMLUTILS_SHARED_H
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
#define XMLAttributeLoop(reader, item) \
|
||||
foreach (const QXmlStreamAttribute &item, reader->attributes())
|
||||
|
||||
/**
|
||||
* @brief Workaround for QXmlStreamReader::readNextStartElement not detecting the end of a document
|
||||
*
|
||||
* Since Qt's default function doesn't exit at the end of the document, it ends up consistently
|
||||
* throwing a "premature end of document" error. We have our own function here that does essentially
|
||||
* the same thing but fixes that issue.
|
||||
*
|
||||
* See also: https://stackoverflow.com/questions/46346450/qt-qxmlstreamreader-always-returns-premature-end-of-document-error
|
||||
*
|
||||
* @param cancel_atom Optional pointer to a CancelAtom (from engine) for cancellation support.
|
||||
* Pass nullptr when calling from app code without engine dependencies.
|
||||
*/
|
||||
bool xml_read_next_start_element(QXmlStreamReader *reader,
|
||||
void *cancel_atom = nullptr);
|
||||
|
||||
}
|
||||
|
||||
#endif // OAK_XMLUTILS_SHARED_H
|
||||
Reference in New Issue
Block a user