clean yet

This commit is contained in:
2020-06-10 14:11:44 +03:00
parent c59579d5d5
commit 4bd54274c9
11 changed files with 48 additions and 327 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip)
set(_PIP_MAJOR 1)
set(_PIP_MINOR 19)
set(_PIP_MINOR 20)
set(_PIP_REVISION 0)
set(_PIP_SUFFIX alpha)
set(_PIP_COMPANY SHS)
@@ -274,15 +274,6 @@ else()
endif()
# Check if STL containers is on (to enable use "-DSTL=" argument of cmake)
if(STL)
message(STATUS "Building PIP with STL containers")
add_definitions(-DPIP_CONTAINERS_STL)
else()
message(STATUS "Building PIP with PIP containers")
endif()
# Check if ICU used for PIString and PIChar
if(ICU)
message(STATUS "Building PIP with ICU")

View File

@@ -25,7 +25,6 @@
#include "pimap.h"
#include "piqueue.h"
#include "piset.h"
#include "pilist.h"
#include "pistack.h"
#include "pivector2d.h"

View File

@@ -28,9 +28,6 @@
#include "picontainers.h"
#if !defined(PIP_CONTAINERS_STL) || defined(DOXYGEN)
template <typename T>
class PIDeque {
public:
@@ -505,33 +502,6 @@ private:
template<> inline PIDeque<T> & PIDeque<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
#else
template<typename Type, typename Allocator = std::allocator<Type> >
class PIP_EXPORT PIDeque: public deque<Type, Allocator> {
typedef PIDeque<Type, Allocator> _CDeque;
typedef deque<Type, Allocator> _stlc;
public:
PIDeque() {piMonitor.containers++;}
PIDeque(const Type & value) {piMonitor.containers++; _stlc::resize(1, value);}
PIDeque(const Type & v0, const Type & v1) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1);}
PIDeque(const Type & v0, const Type & v1, const Type & v2) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
PIDeque(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
~PIDeque() {piMonitor.containers--;}
int size_s() const {return static_cast<int>(_stlc::size());}
bool isEmpty() const {return _stlc::empty();}
bool has(const Type & t) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) return true; return false;}
int etries(const Type & t) const {int ec = 0; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) ++ec; return ec;}
_CDeque & operator <<(const Type & t) {_CDeque::push_back(t); return *this;}
PIDeque<Type> toVector() {PIDeque<Type> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
};
#define __PIDEQUE_SIMPLE_FUNCTIONS__(T)
#endif
__PIDEQUE_SIMPLE_TYPE__(bool)
__PIDEQUE_SIMPLE_TYPE__(char)
__PIDEQUE_SIMPLE_TYPE__(uchar)

View File

@@ -1,70 +0,0 @@
/*! \file pilist.h
* \brief Linked list container, wrapper for std::list
*
* This file declares PIList
*/
/*
PIP - Platform Independent Primitives
Linked list container, wrapper for std::list
Ivan Pelipenko peri4ko@yandex.ru
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/>.
*/
#ifndef PILIST_H
#define PILIST_H
#include "pibase.h"
#include <list>
template<typename Type, typename Allocator = std::allocator<Type> >
class PIP_EXPORT PIList: public std::list<Type, Allocator> {
typedef PIList<Type, Allocator> _CList;
typedef std::list<Type, Allocator> _stlc;
public:
PIList() {}
PIList(const Type & value) {_stlc::resize(1, value);}
PIList(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
PIList(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
PIList(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
PIList(uint size, const Type & value = Type()) {_stlc::resize(size, value);}
virtual ~PIList() {}
Type & operator [](uint index) {return (*this)[index];}
Type & operator [](uint index) const {return (*this)[index];}
const Type * data(uint index = 0) const {return &(*this)[index];}
Type * data(uint index = 0) {return &(*this)[index];}
int size_s() const {return static_cast<int>(_stlc::size());}
bool isEmpty() const {return _stlc::empty();}
bool has(const Type & t) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) return true; return false;}
int etries(const Type & t) const {int ec = 0; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) ++ec; return ec;}
_CList & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
_CList & remove(uint index) {_stlc::erase(_stlc::begin() + index); return *this;}
_CList & remove(uint index, uint count) {_stlc::erase(_stlc::begin() + index, _stlc::begin() + index + count); return *this;}
_CList & insert(uint pos, const Type & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
_CList & operator <<(const Type & t) {_stlc::push_back(t); return *this;}
PIVector<Type> toVector() const {PIVector<Type> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
};
//! \relatesalso PIByteArray \brief Store operator
template<typename T> inline PIByteArray & operator <<(PIByteArray & s, const PIList<T> & v);
//! \relatesalso PIByteArray \brief Restore operator
template<typename T> inline PIByteArray & operator >>(PIByteArray & s, PIList<T> & v);
template<typename T>
inline PIByteArray & operator <<(PIByteArray & s, const PIList<T> & v) {s << int(v.size_s()); for (uint i = 0; i < v.size(); ++i) s << v[i]; return s;}
template<typename T>
inline PIByteArray & operator >>(PIByteArray & s, PIList<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
#endif // PILIST_H

View File

@@ -33,8 +33,6 @@ __PIDEQUE_SIMPLE_TYPE__(T)\
__PIVECTOR_SIMPLE_TYPE__(T)
#if !defined(PIP_CONTAINERS_STL) || defined(DOXYGEN)
template<class T>
void piQuickSort(T * a, ssize_t N) {
if (N < 1) return;
@@ -311,73 +309,6 @@ protected:
};
#else
template<typename Key, typename Type>
class PIP_EXPORT PIMap: public map<Key, Type> {
typedef PIMap<Key, Type> _CMap;
typedef map<Key, Type> _stlc;
typedef std::pair<Key, Type> _stlpair;
public:
PIMap() {;}
PIMap(const Key & key_, const Type & value_) {insert(key_, value_);}
bool isEmpty() const {return _stlc::empty();}
bool contains(const Key & key_) const {return _stlc::count(key_) > 0;}
int size_s() const {return static_cast<int>(_stlc::size());}
_CMap & insert(const Key & key_, const Type & value_) {_stlc::insert(_stlpair(key_, value_)); return *this;}
_CMap & insert(PIPair<Key, Type> entry_) {_stlc::insert(_stlpair(entry_.first, entry_.second)); return *this;}
Key key(Type value_, const Key & default_ = Key()) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); i++) if (i->second == value_) return i->first; return default_;}
PIVector<Key> keys() const {
PIVector<Key> ret;
for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); i++)
ret << i->first;
return ret;
}
Type & at(const Key & key_) {return _stlc::find(key_)->second;}
Type value(const Key & key_) const {typename _stlc::const_iterator it = _stlc::find(key_); if (it != _stlc::end()) return it->second; return Type();}
};
template<typename Key, typename Type>
class PIP_EXPORT PIMultiMap: public multimap<Key, Type> {
typedef PIMultiMap<Key, Type> _CMultiMap;
typedef multimap<Key, Type> _stlc;
typedef std::pair<Key, Type> _stlpair;
public:
PIMultiMap() {;}
PIMultiMap(const Key & key_, const Type & value_) {insert(key_, value_);}
_CMultiMap & insert(const Key & key_, const Type & value_) {_stlc::insert(_stlpair(key_, value_)); return *this;}
_CMultiMap & insert(PIPair<Key, Type> entry_) {_stlc::insert(_stlpair(entry_.first, entry_.second)); return *this;}
bool isEmpty() const {return _stlc::empty();}
bool contains(const Key & key_) const {return _stlc::count(key_) > 0;}
Key key(Type value_, const Key & default_ = Key()) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); i++) if (i->second == value_) return i->first; return default_;}
PIVector<Key> keys(Type value_) const {
PIVector<Key> ret;
for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); i++)
if (i->second == value_)
ret << i->first;
return ret;
}
Type & value(const Key & key_) {typename _stlc::iterator i = _stlc::find(key_); if (i == _stlc::end()) return Type(); return i->second;}
Type value(const Key & key_) const {typename _stlc::const_iterator i = _stlc::find(key_); if (i == _stlc::end()) return Type(); return i->second;}
PIVector<Type> values(const Key & key_) const {
std::pair<typename _stlc::const_iterator, typename _stlc::const_iterator> range = _stlc::equal_range(key_);
PIVector<Type> ret;
for (typename _stlc::const_iterator i = range.first; i != range.second; ++i)
ret << i->second;
return ret;
}
Type & operator [](const Key & key_) {if (!contains(key_)) return _stlc::insert(_stlpair(key_, Type()))->second; return _stlc::find(key_)->second;}
Type operator [](const Key & key_) const {return _stlc::find(key_)->second;}
};
#define __PIMAP_SIMPLE_FUNCTIONS__(T)
#endif
#ifdef PIP_STD_IOSTREAM
template<typename Key, typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMap<Key, Type> & v) {

View File

@@ -28,9 +28,6 @@
#include "picontainers.h"
#if !defined(PIP_CONTAINERS_STL) || defined(DOXYGEN)
template <typename T>
class PIVector {
public:
@@ -454,93 +451,6 @@ private:
template<> inline PIVector<T> & PIVector<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
#else
template<typename T, typename Allocator = std::allocator<T> >
class PIP_EXPORT PIVector: public vector<T, Allocator> {
typedef PIVector<T, Allocator> _CVector;
typedef vector<T, Allocator> _stlc;
public:
PIVector() {}
PIVector(uint size, const T & value = T()) {_stlc::resize(size, value);}
~PIVector() {}
const T & at(uint index) const {return (*this)[index];}
T & at(uint index) {return (*this)[index];}
const T * data(uint index = 0) const {return &(*this)[index];}
T * data(uint index = 0) {return &(*this)[index];}
#ifdef DOXYGEN
uint size() const;
#endif
int size_s() const {return static_cast<int>(_stlc::size());}
bool isEmpty() const {return _stlc::empty();}
bool has(const T & t) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) return true; return false;}
int etries(const T & t) const {int ec = 0; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) ++ec; return ec;}
typedef int (*CompareFunc)(const T * , const T * );
static int compare_func(const T * t0, const T * t1) {return (*t0) == (*t1) ? 0 : ((*t0) < (*t1) ? -1 : 1);}
#ifdef DOXYGEN
void resize(uint size, const T & new_type = T());
PIVector<T, Allocator> & enlarge(uint size);
void clear();
PIVector<T, Allocator> & sort(CompareFunc compare = compare_func) {piqsort(&at(0), _stlc::size(), sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
PIVector<T, Allocator> & fill(const T & t) {_stlc::assign(_stlc::size(), t); return *this;}
T & back();
const T & back() const;
T & front();
const T & front() const;
PIVector<T, Allocator> & push_back(const T & t);
PIVector<T, Allocator> & push_front(const T & t) {_stlc::insert(_stlc::begin(), t); return *this;}
PIVector<T, Allocator> & pop_back();
PIVector<T, Allocator> & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
T take_back() {T t(_stlc::back()); _stlc::pop_back(); return t;}
T take_front() {T t(_stlc::front()); pop_front(); return t;}
PIVector<T, Allocator> & remove(uint index) {_stlc::erase(_stlc::begin() + index); return *this;}
PIVector<T, Allocator> & remove(uint index, uint count) {_stlc::erase(_stlc::begin() + index, _stlc::begin() + index + count); return *this;}
PIVector<T, Allocator> & removeOne(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); return *this;} return *this;}
PIVector<T, Allocator> & removeAll(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); --i;} return *this;}
PIVector<T, Allocator> & insert(uint pos, const T & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
PIVector<T, Allocator> & insert(uint pos, const PIVector<T, Allocator> & t) {_stlc::insert(_stlc::begin() + pos, t.begin(), t.end()); return *this;}
T & operator [](uint index);
const T & operator [](uint index) const;
PIVector<T, Allocator> & operator <<(const T & t) {_stlc::push_back(t); return *this;}
PIVector<T, Allocator> & operator <<(const PIVector<T, Allocator> & t) {for (typename _stlc::const_iterator i = t.begin(); i != t.end(); i++) _stlc::push_back(*i); return *this;}
bool operator ==(const PIVector<T, Allocator> & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return false; return true;}
bool operator !=(const PIVector<T, Allocator> & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return true; return false;}
bool contains(const T & v) const {for (uint i = 0; i < _stlc::size(); ++i) if (v == at(i)) return true; return false;}
#else
_CVector & enlarge(int size_) {int ns = size_s() + size_; if (ns <= 0) _stlc::clear(); else _stlc::resize(ns); return *this;}
_CVector & sort(CompareFunc compare = compare_func) {piqsort(&at(0), _stlc::size(), sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
_CVector & fill(const T & t) {_stlc::assign(_stlc::size(), t); return *this;}
_CVector & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
_CVector & push_front(const T & t) {_stlc::insert(_stlc::begin(), t); return *this;}
T take_front() {T t(_stlc::front()); pop_front(); return t;}
T take_back() {T t(_stlc::back()); _stlc::pop_back(); return t;}
_CVector & remove(uint index) {_stlc::erase(_stlc::begin() + index); return *this;}
_CVector & remove(uint index, uint count) {_stlc::erase(_stlc::begin() + index, _stlc::begin() + index + count); return *this;}
_CVector & removeOne(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); return *this;} return *this;}
_CVector & removeAll(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); --i;} return *this;}
_CVector & insert(uint pos, const T & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
_CVector & insert(uint pos, const _CVector & t) {_stlc::insert(_stlc::begin() + pos, t.begin(), t.end()); return *this;}
_CVector & operator <<(const T & t) {_stlc::push_back(t); return *this;}
_CVector & operator <<(const _CVector & t) {for (typename _stlc::const_iterator i = t.begin(); i != t.end(); i++) _stlc::push_back(*i); return *this;}
bool operator ==(const _CVector & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return false; return true;}
bool operator !=(const _CVector & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return true; return false;}
bool contains(const T & v) const {for (uint i = 0; i < _stlc::size(); ++i) if (v == at(i)) return true; return false;}
#endif
};
#define __PIVECTOR_SIMPLE_TYPE__(T)
#endif
__PIVECTOR_SIMPLE_TYPE__(bool)
__PIVECTOR_SIMPLE_TYPE__(char)
__PIVECTOR_SIMPLE_TYPE__(uchar)

View File

@@ -94,9 +94,6 @@
//! Macro is defined when PIP can use "rt" library for "PITimer::ThreadRT" timers implementation
# define PIP_TIMER_RT
//! Define this macro to use STL implementation of containers, else PIP implementation will be used
# define PIP_CONTAINERS_STL
#endif
#ifdef PIP_CXX11_SUPPORT

View File

@@ -123,10 +123,11 @@ PIInit::PIInit() {
PIStringList ifpathes;
ifpathes << PIStringAscii("/bin/ifconfig") << PIStringAscii("/sbin/ifconfig")
<< PIStringAscii("/usr/bin/ifconfig") << PIStringAscii("/usr/sbin/ifconfig");
piForeachC (PIString & i, ifpathes)
if (fileExists(i)) {
sinfo->ifconfigPath = i;
piBreak;
piForeachC (PIString & i, ifpathes) {
if (fileExists(i)) {
sinfo->ifconfigPath = i;
piBreak;
}
}
# else
// OS version
@@ -228,12 +229,12 @@ PIInit::PIInit() {
GetSystemInfo(&sysinfo);
sinfo->processorsCount = sysinfo.dwNumberOfProcessors;
switch (sysinfo.wProcessorArchitecture) {
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
case PROCESSOR_ARCHITECTURE_UNKNOWN:
default: sinfo->architecture = PIStringAscii("unknown"); break;
case PROCESSOR_ARCHITECTURE_AMD64: sinfo->architecture = PIStringAscii("x86_64"); break;
case PROCESSOR_ARCHITECTURE_ARM: sinfo->architecture = PIStringAscii("arm"); break;
case PROCESSOR_ARCHITECTURE_IA64: sinfo->architecture = PIStringAscii("Intel Itanium-based"); break;
case PROCESSOR_ARCHITECTURE_INTEL: sinfo->architecture = PIStringAscii("x86"); break;
case PROCESSOR_ARCHITECTURE_UNKNOWN:
default: sinfo->architecture = PIStringAscii("unknown"); break;
}
int argc_(0);
wchar_t ** argv_ = CommandLineToArgvW(GetCommandLineW(), &argc_);
@@ -271,7 +272,7 @@ PIInit::PIInit() {
sinfo->OS_version = esp_get_idf_version();
#endif
sinfo->OS_name =
#ifdef WINDOWS
#ifdef WINDOWS
PIStringAscii("Windows");
#else
# ifdef QNX
@@ -323,61 +324,55 @@ PIInit::~PIInit() {
bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) {
switch (o) {
case ICU: return
#ifdef PIP_ICU
true;
case ICU: return
#ifdef PIP_ICU
true;
#else
false;
false;
#endif
case USB: return
#ifdef PIP_USB
true;
case USB: return
#ifdef PIP_USB
true;
#else
false;
false;
#endif
case STL: return
#ifdef PIP_CONTAINERS_STL
true;
case Crypt: return
#ifdef PIP_CRYPT
true;
#else
false;
false;
#endif
case Crypt: return
#ifdef PIP_CRYPT
true;
case Introspection: return
#ifdef PIP_INTROSPECTION
true;
#else
false;
false;
#endif
case Introspection: return
#ifdef PIP_INTROSPECTION
true;
case FFTW: return
#ifdef PIP_FFTW
true;
#else
false;
false;
#endif
case FFTW: return
#ifdef PIP_FFTW
true;
case Compress: return
#ifdef PIP_COMPRESS
true;
#else
false;
false;
#endif
case Compress: return
#ifdef PIP_COMPRESS
true;
case OpenCL: return
#ifdef PIP_OPENCL
true;
#else
false;
false;
#endif
case OpenCL: return
#ifdef PIP_OPENCL
true;
case Cloud: return
#ifdef PIP_CLOUD
true;
#else
false;
false;
#endif
case Cloud: return
#ifdef PIP_CLOUD
true;
#else
false;
#endif
default: return false;
default: return false;
}
return false;
}
@@ -387,7 +382,6 @@ PIStringList PIInit::buildOptions() {
PIStringList ret;
if (isBuildOptionEnabled(ICU)) ret << "ICU";
if (isBuildOptionEnabled(USB)) ret << "USB";
if (isBuildOptionEnabled(STL)) ret << "STL";
if (isBuildOptionEnabled(Crypt)) ret << "Crypt";
if (isBuildOptionEnabled(Introspection)) ret << "Introspection";
if (isBuildOptionEnabled(FFTW)) ret << "FFTW";

View File

@@ -49,7 +49,6 @@ public:
enum BuildOption {
ICU /*! Unicode support */ = 0x01,
USB /*! USB support */ = 0x02,
STL /*! STL containers implementation */ = 0x04,
Crypt /*! Crypt support */ = 0x08,
Introspection /*! Introspection */ = 0x010,
FFTW /*! FFTW3 support */ = 0x40,

View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Config parser
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru
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

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Configuration parser and writer
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru
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