Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libcore: Started removal of Qt dependencies
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent cd7b597 commit 9ba83cf
Show file tree
Hide file tree
Showing 15 changed files with 876 additions and 562 deletions.
3 changes: 1 addition & 2 deletions doomsday/apps/api/dd_version.h.in
Expand Up @@ -32,8 +32,7 @@ extern "C" {

#define DOOMSDAY_NICENAME "Doomsday Engine"
#define DOOMSDAY_HOMEURL "http://dengine.net"
#define DOOMSDAY_MASTERURL "http://dengine.net/master.php"
#define DOOMSDAY_DOCSURL "http://dengine.net/dew"
#define DOOMSDAY_DOCSURL "https://manual.dengine.net"

/**
* Version number rules: (major).(minor).(revision)-(release name)
Expand Down
31 changes: 31 additions & 0 deletions doomsday/cmake/FindCPlus.cmake
@@ -0,0 +1,31 @@
# c_Plus provides a number of low-level C features.

set (CPLUS_DIR "" CACHE PATH "Location of the c_Plus library")

set (_oldPath ${CPLUS_DEFS_H})
find_file (CPLUS_DEFS_H include/c_plus/defs.h
PATHS "${CPLUS_DIR}"
HINTS ENV DENG_DEPEND_PATH
PATH_SUFFIXES cplus c_plus
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
mark_as_advanced (CPLUS_DEFS_H)

if (NOT _oldPath STREQUAL CPLUS_DEFS_H)
if (CPLUS_DEFS_H)
message (STATUS "Looking for c_Plus - found")
else ()
message (STATUS "Looking for c_Plus - not found (set the CPLUS_DIR variable)")
endif ()
endif ()

if (CPLUS_DEFS_H AND NOT TARGET cplus)
get_filename_component (cplusInc "${CPLUS_DEFS_H}" DIRECTORY)
get_filename_component (cplusInc "${cplusInc}" DIRECTORY)

add_library (cplus INTERFACE)
target_include_directories (cplus INTERFACE ${cplusInc})
# target_link_libraries (cplus INTERFACE xxx)
endif ()

4 changes: 3 additions & 1 deletion doomsday/libs/core/CMakeLists.txt
Expand Up @@ -5,6 +5,7 @@ project (DE_LIBCORE)
include (../../cmake/Config.cmake)

# Dependencies.
find_package (CPlus)
include (ZLIB)
find_package (Git QUIET)

Expand Down Expand Up @@ -58,8 +59,9 @@ deng_add_package (net.dengine.stdlib)

deng_add_library (libcore ${SOURCES} ${HEADERS})
target_include_directories (libcore PRIVATE ${ZLIB_INCLUDE_DIR})
deng_target_link_qt (libcore PUBLIC Core Network)
#deng_target_link_qt (libcore PUBLIC Core Network)
target_link_libraries (libcore PUBLIC ${ZLIB_LIBRARIES})
target_link_libraries (libcore PRIVATE cplus)
deng_deploy_library (libcore DengCore)

deng_cotire (libcore src/precompiled.h)
1 change: 1 addition & 0 deletions doomsday/libs/core/include/de/List
@@ -0,0 +1 @@
#include "data/list.h"
1 change: 1 addition & 0 deletions doomsday/libs/core/include/de/RegExp
@@ -0,0 +1 @@
#include "data/regexp.h"
25 changes: 18 additions & 7 deletions doomsday/libs/core/include/de/data/block.h
Expand Up @@ -23,9 +23,10 @@
#include "../IByteArray"
#include "../IBlock"
#include "../ISerializable"
#include "../List"
#include "../Writer"

#include <QByteArray>
#include <c_plus/block.h>
#include <array>

namespace de {
Expand All @@ -43,15 +44,17 @@ class IIStream;
*
* @ingroup data
*/
class DE_PUBLIC Block : public QByteArray, public IByteArray, public IBlock,
public ISerializable
class DE_PUBLIC Block
: public IByteArray
, public IBlock
, public ISerializable
{
public:
Block(Size initialSize = 0);
Block(const iBlock *);
Block(IByteArray const &array);
Block(Block const &other);
Block(Block &&moved);
Block(QByteArray const &byteArray);
Block(char const *nullTerminatedCStr);
Block(void const *data, Size length);

Expand Down Expand Up @@ -83,16 +86,21 @@ class DE_PUBLIC Block : public QByteArray, public IByteArray, public IBlock,
*/
Block(IByteArray const &array, Offset at, Size count);

virtual ~Block();

Byte *data();
Byte const *dataConst() const;
inline Byte const *cdata() const { return dataConst(); }
inline Byte const *constData() const { return dataConst(); }

Block &append(Byte b);
Block &append(char const *str, int len);

inline explicit operator bool() const { return !isEmpty(); }
operator const iBlock *() const { return &_block; }
inline explicit operator bool() const { return !isEmpty_Block(&_block); }

Block &operator += (char const *nullTerminatedCStr);
Block &operator += (QByteArray const &bytes);
// Block &operator += (QByteArray const &bytes);

/// Appends a block after this one.
Block &operator += (Block const &other);
Expand Down Expand Up @@ -180,7 +188,10 @@ class DE_PUBLIC Block : public QByteArray, public IByteArray, public IBlock,
void operator << (Reader &from);

public:
static Block join(QList<Block> const &blocks, Block const &sep = Block());
static Block join(List<Block> const &blocks, Block const &sep = Block());

private:
iBlock _block;
};

template <typename... Args>
Expand Down
72 changes: 72 additions & 0 deletions doomsday/libs/core/include/de/data/list.h
@@ -0,0 +1,72 @@
/** @file
*
* @authors Copyright (c) 2018 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBCORE_LIST_H
#define LIBCORE_LIST_H

#include <vector>

namespace de {

/**
* Array of elements.
* @ingroup data
*/
template <typename T>
class List : public std::vector<T>
{
using Base = std::vector<T>;

public:
List() {}
List(const List &);
List(List &&);
List(const std::initializer_list<T> &init) {
for (const auto &i : init) {
push_back(i);
}
}

using iterator = typename Base::iterator;
using const_iterator = typename Base::const_iterator;
using reverse_iterator = typename Base::reverse_iterator;
using const_reverse_iterator = typename Base::const_reverse_iterator;

// Qt style methods:

int size() const { return int(Base::size()); }
void clear() { Base::clear(); }
bool isEmpty() const { return Base::size() == 0; }
void append(const T &s) { Base::push_back(s); }
void prepend(const T &s) { Base::push_front(s); }
void insert(int pos, const T &value) { Base::insert(Base::begin() + pos, value); }
const T &operator[](int pos) const { return Base::at(pos); }
T & operator[](int pos) { return Base::operator[](pos); }
const T &at(int pos) const { return Base::at(pos); }
const T &first() const { return Base::front(); }
const T &last() const { return Base::back(); }
T takeFirst() { T v = first(); Base::pop_front(); return v; }
T takeLast() { T v = last(); Base::pop_back(); return v; }
void removeFirst() { Base::erase(Base::begin()); }
void removeLast() { Base::erase(Base::begin() + size() - 1); }
void removeAt(int pos) { Base::erase(Base::begin() + pos); }
};

} // namespace de

#endif // LIBCORE_LIST_H
50 changes: 50 additions & 0 deletions doomsday/libs/core/include/de/data/regexp.h
@@ -0,0 +1,50 @@
/** @file regexp.h Perl-compatible regular expressions.
*
* @authors Copyright (c) 2018 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* LGPL: http://www.gnu.org/licenses/lgpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBCORE_REGEXP_H
#define LIBCORE_REGEXP_H

#include "../String"
#include <c_plus/regexp.h>

namespace de {

class RegExpMatch
{
public:
RegExpMatch();

private:
iRegExpMatch _match;
};

/**
* Perl-compatible regular expression.
*/
class RegExp
{
public:
RegExp(const String &expression = {}, String::CaseSensitivity cs = String::CaseSensitive);

private:
iRegExp *_d;
};

} // namespace de

#endif // LIBCORE_REGEXP_H

0 comments on commit 9ba83cf

Please sign in to comment.