Commit dfad61fe authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

Moved a few definitions to .cpp

parent c81327f8
#include "QBind.h"
extern QIdentifierLiteral qBindExpectedItem ("ExpectedItem" );
extern QIdentifierLiteral qBindExpectedNull ("ExpectedNull" );
extern QIdentifierLiteral qBindExpectedSequence ("ExpectedSequence" );
extern QIdentifierLiteral qBindExpectedRecord ("ExpectedRecord" );
extern QIdentifierLiteral qBindExpectedText ("ExpectedText" );
extern QIdentifierLiteral qBindExpectedBytes ("ExpectedBytes" );
extern QIdentifierLiteral qBindExpectedInteger ("ExpectedInteger" );
extern QIdentifierLiteral qBindExpectedDecimal ("ExpectedDecimal" );
extern QIdentifierLiteral qBindExpectedSmallerNumber ("ExpectedSmallerNumber" );
extern QIdentifierLiteral qBindExpectedPositiveNumber("ExpectedPositiveNumber");
extern QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" );
extern QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" );
extern QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" );
extern QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" );
extern QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" );
extern QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
extern QIdentifierLiteral qmDataStreamVersion ("qmDataStreamVersion" );
extern QIdentifierLiteral qmColumns ("columns" );
extern QIdentifierLiteral qmSizes ("sizes" );
extern QIdentifierLiteral qmChildren ("children" );
extern QIdentifierLiteral qmName ("name" );
extern QIdentifierLiteral qmColor ("color" );
......@@ -54,23 +54,23 @@
// //////////////////////////////////////////////////////////////////////////
// Standard error names
static QIdentifierLiteral qBindExpectedItem ("ExpectedItem" );
static QIdentifierLiteral qBindExpectedNull ("ExpectedNull" );
static QIdentifierLiteral qBindExpectedSequence ("ExpectedSequence" );
static QIdentifierLiteral qBindExpectedRecord ("ExpectedRecord" );
static QIdentifierLiteral qBindExpectedText ("ExpectedText" );
static QIdentifierLiteral qBindExpectedBytes ("ExpectedBytes" );
static QIdentifierLiteral qBindExpectedInteger ("ExpectedInteger" );
static QIdentifierLiteral qBindExpectedDecimal ("ExpectedDecimal" );
static QIdentifierLiteral qBindExpectedSmallerNumber ("ExpectedSmallerNumber" );
static QIdentifierLiteral qBindExpectedPositiveNumber("ExpectedPositiveNumber");
static QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" );
static QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" );
static QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" );
static QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" );
static QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" );
static QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
extern QIdentifierLiteral qBindExpectedItem ;
extern QIdentifierLiteral qBindExpectedNull ;
extern QIdentifierLiteral qBindExpectedSequence ;
extern QIdentifierLiteral qBindExpectedRecord ;
extern QIdentifierLiteral qBindExpectedText ;
extern QIdentifierLiteral qBindExpectedBytes ;
extern QIdentifierLiteral qBindExpectedInteger ;
extern QIdentifierLiteral qBindExpectedDecimal ;
extern QIdentifierLiteral qBindExpectedSmallerNumber ;
extern QIdentifierLiteral qBindExpectedPositiveNumber;
extern QIdentifierLiteral qBindExpectedBoolean ;
extern QIdentifierLiteral qBindExpectedConstant ;
extern QIdentifierLiteral qBindIgnoredItem ;
extern QIdentifierLiteral qBindIgnoredItemName ;
extern QIdentifierLiteral qBindIgnoredCharacter ;
extern QIdentifierLiteral qBindIgnoredBytes ;
// //////////////////////////////////////////////////////////////////////////
// Standard meta data names
......@@ -84,24 +84,27 @@ static QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
// meta(QIdentifierLiteral name, QAsciiData value) is optional meta-data about current data to enable optimized processing (e.g. tag, , style, etc.) and/or transmission (QAbstractItemModel headers, CBOR tags, XML attribute, CSS, numpy.ndarray shapes, etc.)
static const QIdentifierLiteral qmDataStreamVersion("qmDataStreamVersion"); //!< Allows IBind support of QDataStream
extern QIdentifierLiteral qmDataStreamVersion; //!< Allows IBind support of QDataStream
// N-dimensional data structures for which specific IWriter may have optimized implementations
// BEWARE though that nested calls to IWriter are not guaranteed to follow the declared structure (this would prevent reusing general QBind functors for nested data structures)
//! Sequence of records can be implemented as table with columns below (record item names are always the same in a fixed order)
static const QIdentifierLiteral qmColumns ("columns" ); //!< comma-separated names
//! Contains comma-separated names
extern QIdentifierLiteral qmColumns;
//! Sequence of nested non-empty sequences of definite sizes can be implemented as multi-dimensional array
static const QIdentifierLiteral qmSizes ("sizes" ); //!< comma-separated natural numbers
//! Contains comma-separated natural numbers
extern QIdentifierLiteral qmSizes;
//! Sequence of records where item(qmNodes) contains children can be implemented as trees
static const QIdentifierLiteral qmChildren("children"); //!< name of a sequence of records with recursively the same name
//! Contains name of a sequence of records with recursively the same name
extern QIdentifierLiteral qmChildren;
//! Name of current data
static const QIdentifierLiteral qmName ("name" );
extern QIdentifierLiteral qmName;
static const QIdentifierLiteral qmColor ("color" ); //!< comma-separated names
extern QIdentifierLiteral qmColor;
// //////////////////////////////////////////////////////////////////////////
// QBind<T,TResult>
......
#include "QData.h"
bool AsciiIdentifier::isValid(const char* s, int size)
{
if ((s == nullptr && size != 0) || size < 1)
return false;
for (int i=0; i<size; ++i) {
if (s[i] < 0x20/*' '*/ || 0x7F/*DEL*/ == s[i])
return false;
if (i==0 && (s[i]!='_' && (s[0]<'A' || 'z'<s[0] || ('Z'<s[0] && s[0]<'a'))))
qWarning("Non alphabetic first character may not be supported by IBind");
if (i< 0 && (s[i]!='_' && (s[i]<'0' || 'z'<s[i] || ('9'<s[i] && s[i]<'A')
|| ('Z'<s[i] && s[i]<'a'))))
qWarning("Non alphanumeric or underscore character may not be supported by IBind");
}
return true;
}
bool AsciiPrintable::isValid(const char* s, int size)
{
if ((s == nullptr && size != 0) || size < 0) return false;
for (int i=1; i<size; ++i) {
if (s[i] < 0x20/*' '*/ || 0x7F/*DEL*/ <= s[i]) return false;
}
return true;
}
bool Ascii::isValid(const char* s, int size)
{
if ((s == nullptr && size != 0) || size < 0) return false;
for (int i=1; i<size; ++i) {
if (s[i] <= 0) return false;
}
return true;
}
bool Latin1::isValid(const char* s, int size) { return !((s == nullptr && size != 0) || size < 0); }
bool Utf8 ::isValid(const char* s, int size) { return !((s == nullptr && size != 0) || size < 0); }
template<> QData<Utf8>::QData(QDataView<Utf8> v);
QIdentifier::QIdentifier(QIdentifierLiteral n) : QData(QByteArray::fromRawData(n.data(), n.size())) { /* no need to check QIdentifierLiteral content or take ownership */ }
......
......@@ -6,57 +6,11 @@
// Content types
//! Non-empty string of [0x20..0x7E] ASCII subset with a preference for [A..Za..z_][0..9A..Za..z_]* identifiers
struct AsciiIdentifier {
static bool isValid(const char* s, int size)
{
if ((s == nullptr && size != 0) || size < 1)
return false;
for (int i=0; i<size; ++i) {
if (s[i] < 0x20/*' '*/ || 0x7F/*DEL*/ == s[i])
return false;
if (i==0 && (s[i]!='_' && (s[0]<'A' || 'z'<s[0] || ('Z'<s[0] && s[0]<'a'))))
qWarning("Non alphabetic first character may not be supported by IBind");
if (i< 0 && (s[i]!='_' && (s[i]<'0' || 'z'<s[i] || ('9'<s[i] && s[i]<'A')
|| ('Z'<s[i] && s[i]<'a'))))
qWarning("Non alphanumeric or underscore character may not be supported by IBind");
}
return true;
}
};
struct AsciiPrintable
{
static bool isValid(const char* s, int size)
{
if ((s == nullptr && size != 0) || size < 0) return false;
for (int i=1; i<size; ++i) {
if (s[i] < 0x20/*' '*/ || 0x7F/*DEL*/ <= s[i]) return false;
}
return true;
}
};
struct Ascii
{
static bool isValid(const char* s, int size)
{
if ((s == nullptr && size != 0) || size < 0) return false;
for (int i=1; i<size; ++i) {
if (s[i] <= 0) return false;
}
return true;
}
};
struct Latin1
{
static bool isValid(const char* s, int size) { return !((s == nullptr && size != 0) || size < 0); }
};
struct Utf8
{
static bool isValid(const char* s, int size) { return !((s == nullptr && size != 0) || size < 0); }
};
struct AsciiIdentifier { static bool isValid(const char* s, int size); };
struct AsciiPrintable { static bool isValid(const char* s, int size); };
struct Ascii { static bool isValid(const char* s, int size); };
struct Latin1 { static bool isValid(const char* s, int size); };
struct Utf8 { static bool isValid(const char* s, int size); };
template<class TContent> class QDataView;
......@@ -78,8 +32,8 @@ public:
constexpr int size() const noexcept { return m_bytes.size (); }
constexpr const char* data() const noexcept { return m_bytes.data(); }
void set(QByteArray&& b) noexcept { m_bytes=b; }
void set(QByteArray& b) noexcept { m_bytes=b; }
void set(QByteArray&& b) noexcept { m_bytes=b; }
void set(QByteArray& b) noexcept { m_bytes=b; }
protected:
template<class T> friend bool operator==(const QData <T> &a, const QData <T> &b) noexcept;
template<class T> friend bool operator!=(const QData <T> &a, const QData <T> &b) noexcept;
......@@ -120,8 +74,7 @@ protected:
#define DEBUG_CHECK(cond) Q_ASSERT(cond)
#endif
template<class TContent>
class QDataView
template<class TContent> class QDataView
{
public:
using Content = TContent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment