mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-12-22 07:57:17 +01:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
412
vendor/POCO/Foundation/include/Poco/Dynamic/Pair.h
vendored
Normal file
412
vendor/POCO/Foundation/include/Poco/Dynamic/Pair.h
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
//
|
||||
// Pair.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Dynamic
|
||||
// Module: Pair
|
||||
//
|
||||
// Definition of the Pair class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Pair_INCLUDED
|
||||
#define Foundation_Pair_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Dynamic/Var.h"
|
||||
#include "Poco/Dynamic/VarHolder.h"
|
||||
#include <utility>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Dynamic {
|
||||
|
||||
|
||||
template <typename K>
|
||||
class Pair
|
||||
/// Pair allows to define a pair of values.
|
||||
{
|
||||
public:
|
||||
using Data = typename std::pair<K, Var>;
|
||||
|
||||
Pair(): _data()
|
||||
/// Creates an empty Pair
|
||||
{
|
||||
}
|
||||
|
||||
Pair(const Pair& other): _data(other._data)
|
||||
/// Creates the Pair from another pair.
|
||||
{
|
||||
}
|
||||
|
||||
Pair(const Data& val): _data(val)
|
||||
/// Creates the Pair from the given value.
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Pair(const std::pair<K, T>& val): _data(std::make_pair(val.first, val.second))
|
||||
/// Creates Pair form standard pair.
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Pair(const K& first, const T& second): _data(std::make_pair(first, second))
|
||||
/// Creates pair from two values.
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Pair()
|
||||
/// Destroys the Pair.
|
||||
{
|
||||
}
|
||||
|
||||
Pair& swap(Pair& other)
|
||||
/// Swaps the content of the two Pairs.
|
||||
{
|
||||
std::swap(_data, other._data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Pair& operator = (const Pair& other)
|
||||
/// Copy constructs Pair from another pair.
|
||||
{
|
||||
Pair(other).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const K& first() const
|
||||
/// Returns the first member of the pair.
|
||||
{
|
||||
return _data.first;
|
||||
}
|
||||
|
||||
inline const Var& second() const
|
||||
/// Returns the second member of the pair.
|
||||
{
|
||||
return _data.second;
|
||||
}
|
||||
|
||||
std::string toString()
|
||||
{
|
||||
std::string str;
|
||||
Var(*this).template convert<std::string>(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
private:
|
||||
Data _data;
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
class VarHolderImpl<Pair<std::string>>: public VarHolder
|
||||
{
|
||||
public:
|
||||
VarHolderImpl(const Pair<std::string>& val): _val(val)
|
||||
{
|
||||
}
|
||||
|
||||
~VarHolderImpl()
|
||||
{
|
||||
}
|
||||
|
||||
const std::type_info& type() const
|
||||
{
|
||||
return typeid(Pair<std::string>);
|
||||
}
|
||||
|
||||
void convert(Int8& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int8");
|
||||
}
|
||||
|
||||
void convert(Int16& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int16");
|
||||
}
|
||||
|
||||
void convert(Int32& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int32");
|
||||
}
|
||||
|
||||
void convert(Int64& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int64");
|
||||
}
|
||||
|
||||
void convert(UInt8& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt8");
|
||||
}
|
||||
|
||||
void convert(UInt16& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt16");
|
||||
}
|
||||
|
||||
void convert(UInt32& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt32");
|
||||
}
|
||||
|
||||
void convert(UInt64& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt64");
|
||||
}
|
||||
|
||||
void convert(bool& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to bool");
|
||||
}
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to float");
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to double");
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to char");
|
||||
}
|
||||
|
||||
void convert(std::string& val) const
|
||||
{
|
||||
// Serialize in JSON format: equals an object
|
||||
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
||||
val.append("{ ");
|
||||
Var key(_val.first());
|
||||
Impl::appendJSONKey(val, key);
|
||||
val.append(" : ");
|
||||
Impl::appendJSONValue(val, _val.second());
|
||||
val.append(" }");
|
||||
}
|
||||
|
||||
void convert(Poco::DateTime&) const
|
||||
{
|
||||
throw BadCastException("Pair -> Poco::DateTime");
|
||||
}
|
||||
|
||||
void convert(Poco::LocalDateTime&) const
|
||||
{
|
||||
throw BadCastException("Pair -> Poco::LocalDateTime");
|
||||
}
|
||||
|
||||
void convert(Poco::Timestamp&) const
|
||||
{
|
||||
throw BadCastException("Pair -> Poco::Timestamp");
|
||||
}
|
||||
|
||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
||||
{
|
||||
return cloneHolder(pVarHolder, _val);
|
||||
}
|
||||
|
||||
const Pair<std::string>& value() const
|
||||
{
|
||||
return _val;
|
||||
}
|
||||
|
||||
bool isArray() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isStruct() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isInteger() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSigned() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isNumeric() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
Pair<std::string> _val;
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
class VarHolderImpl<Pair<int>>: public VarHolder
|
||||
{
|
||||
public:
|
||||
VarHolderImpl(const Pair<int>& val): _val(val)
|
||||
{
|
||||
}
|
||||
|
||||
~VarHolderImpl()
|
||||
{
|
||||
}
|
||||
|
||||
const std::type_info& type() const
|
||||
{
|
||||
return typeid(Pair<int>);
|
||||
}
|
||||
|
||||
void convert(Int8& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int8");
|
||||
}
|
||||
|
||||
void convert(Int16& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int16");
|
||||
}
|
||||
|
||||
void convert(Int32& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int32");
|
||||
}
|
||||
|
||||
void convert(Int64& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to Int64");
|
||||
}
|
||||
|
||||
void convert(UInt8& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt8");
|
||||
}
|
||||
|
||||
void convert(UInt16& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt16");
|
||||
}
|
||||
|
||||
void convert(UInt32& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt32");
|
||||
}
|
||||
|
||||
void convert(UInt64& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to UInt64");
|
||||
}
|
||||
|
||||
void convert(bool& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to bool");
|
||||
}
|
||||
|
||||
void convert(float& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to float");
|
||||
}
|
||||
|
||||
void convert(double& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to double");
|
||||
}
|
||||
|
||||
void convert(char& val) const
|
||||
{
|
||||
throw BadCastException("Cannot cast Pair type to char");
|
||||
}
|
||||
|
||||
void convert(std::string& val) const
|
||||
{
|
||||
// Serialize in JSON format: equals an object
|
||||
// JSON format definition: { string ':' value } string:value pair n-times, sep. by ','
|
||||
val.append("{ ");
|
||||
Var key(_val.first());
|
||||
Impl::appendJSONKey(val, key);
|
||||
val.append(" : ");
|
||||
Impl::appendJSONValue(val, _val.second());
|
||||
val.append(" }");
|
||||
}
|
||||
|
||||
void convert(Poco::DateTime&) const
|
||||
{
|
||||
throw BadCastException("Pair -> Poco::DateTime");
|
||||
}
|
||||
|
||||
void convert(Poco::LocalDateTime&) const
|
||||
{
|
||||
throw BadCastException("Pair -> Poco::LocalDateTime");
|
||||
}
|
||||
|
||||
void convert(Poco::Timestamp&) const
|
||||
{
|
||||
throw BadCastException("Pair -> Poco::Timestamp");
|
||||
}
|
||||
|
||||
VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const
|
||||
{
|
||||
return cloneHolder(pVarHolder, _val);
|
||||
}
|
||||
|
||||
const Pair<int>& value() const
|
||||
{
|
||||
return _val;
|
||||
}
|
||||
|
||||
bool isArray() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isStruct() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isInteger() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSigned() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isNumeric() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isString() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
Pair<int> _val;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Dynamic
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Pair_INCLUDED
|
||||
1005
vendor/POCO/Foundation/include/Poco/Dynamic/Struct.h
vendored
Normal file
1005
vendor/POCO/Foundation/include/Poco/Dynamic/Struct.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2350
vendor/POCO/Foundation/include/Poco/Dynamic/Var.h
vendored
Normal file
2350
vendor/POCO/Foundation/include/Poco/Dynamic/Var.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4198
vendor/POCO/Foundation/include/Poco/Dynamic/VarHolder.h
vendored
Normal file
4198
vendor/POCO/Foundation/include/Poco/Dynamic/VarHolder.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
155
vendor/POCO/Foundation/include/Poco/Dynamic/VarIterator.h
vendored
Normal file
155
vendor/POCO/Foundation/include/Poco/Dynamic/VarIterator.h
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// VarIterator.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Dynamic
|
||||
// Module: VarIterator
|
||||
//
|
||||
// Definition of the VarIterator class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_VarIterator_INCLUDED
|
||||
#define Foundation_VarIterator_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Exception.h"
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Dynamic {
|
||||
|
||||
|
||||
class Var;
|
||||
|
||||
|
||||
class Foundation_API VarIterator
|
||||
/// VarIterator class.
|
||||
{
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef Var value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef Var* pointer;
|
||||
typedef Var& reference;
|
||||
|
||||
static const std::size_t POSITION_END;
|
||||
/// End position indicator.
|
||||
|
||||
VarIterator(Var* pVar, bool positionEnd);
|
||||
/// Creates the VarIterator and positions it at the end of
|
||||
/// the recordset if positionEnd is true. Otherwise, it is
|
||||
/// positioned at the beginning.
|
||||
|
||||
VarIterator(const VarIterator& other);
|
||||
/// Creates a copy of other VarIterator.
|
||||
|
||||
VarIterator(VarIterator&& other) noexcept;
|
||||
/// Moves another VarIterator.
|
||||
|
||||
~VarIterator();
|
||||
/// Destroys the VarIterator.
|
||||
|
||||
VarIterator& operator = (const VarIterator& other);
|
||||
/// Assigns the other VarIterator.
|
||||
|
||||
VarIterator& operator = (VarIterator&& other) noexcept;
|
||||
/// Assigns the other VarIterator.
|
||||
|
||||
bool operator == (const VarIterator& other) const;
|
||||
/// Equality operator.
|
||||
|
||||
bool operator != (const VarIterator& other) const;
|
||||
/// Inequality operator.
|
||||
|
||||
Var& operator * () const;
|
||||
/// Returns value at the current position.
|
||||
|
||||
Var* operator -> () const;
|
||||
/// Returns pointer to the value at current position.
|
||||
|
||||
const VarIterator& operator ++ () const;
|
||||
/// Advances by one position and returns current position.
|
||||
|
||||
VarIterator operator ++ (int) const;
|
||||
/// Advances by one position and returns copy of the iterator with
|
||||
/// previous current position.
|
||||
|
||||
const VarIterator& operator -- () const;
|
||||
/// Goes back by one position and returns copy of the iterator with
|
||||
/// previous current position.
|
||||
|
||||
VarIterator operator -- (int) const;
|
||||
/// Goes back by one position and returns previous current position.
|
||||
|
||||
VarIterator operator + (std::size_t diff) const;
|
||||
/// Returns a copy the VarIterator advanced by diff positions.
|
||||
|
||||
VarIterator operator - (std::size_t diff) const;
|
||||
/// Returns a copy the VarIterator backed by diff positions.
|
||||
/// Throws RangeException if diff is larger than current position.
|
||||
|
||||
void swap(VarIterator& other);
|
||||
/// Swaps the VarIterator with another one.
|
||||
|
||||
private:
|
||||
VarIterator();
|
||||
|
||||
void increment() const;
|
||||
/// Increments the iterator position by one.
|
||||
/// Throws RangeException if position is out of range.
|
||||
|
||||
void decrement() const;
|
||||
/// Decrements the iterator position by one.
|
||||
/// Throws RangeException if position is out of range.
|
||||
|
||||
void setPosition(std::size_t pos) const;
|
||||
/// Sets the iterator position.
|
||||
/// Throws RangeException if position is out of range.
|
||||
|
||||
Var* _pVar;
|
||||
mutable std::size_t _position;
|
||||
|
||||
friend class Var;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// inlines
|
||||
///
|
||||
|
||||
|
||||
inline bool VarIterator::operator == (const VarIterator& other) const
|
||||
{
|
||||
return _pVar == other._pVar && _position == other._position;
|
||||
}
|
||||
|
||||
|
||||
inline bool VarIterator::operator != (const VarIterator& other) const
|
||||
{
|
||||
return _pVar != other._pVar || _position != other._position;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Dynamic
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
inline void swap<Poco::Dynamic::VarIterator>(Poco::Dynamic::VarIterator& s1, Poco::Dynamic::VarIterator& s2) noexcept
|
||||
/// Full template specialization of std:::swap for VarIterator
|
||||
{
|
||||
s1.swap(s2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // Foundation_VarIterator_INCLUDED
|
||||
Reference in New Issue
Block a user