picout and clean
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
project(pip)
|
||||
set(pip_MAJOR 2)
|
||||
set(pip_MINOR 99)
|
||||
set(pip_MINOR 100)
|
||||
set(pip_REVISION 0)
|
||||
set(pip_SUFFIX )
|
||||
set(pip_COMPANY SHS)
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
other._reset();
|
||||
}
|
||||
|
||||
inline virtual ~PIDeque() {
|
||||
inline ~PIDeque() {
|
||||
PIINTROSPECTION_CONTAINER_DELETE(T)
|
||||
PIINTROSPECTION_CONTAINER_FREE(T, (pid_rsize))
|
||||
deleteT(pid_data + pid_start, pid_size);
|
||||
|
||||
@@ -91,15 +91,15 @@ public:
|
||||
|
||||
//! \~english Constructs an empty map.
|
||||
//! \~russian Создает пустой словарь.
|
||||
PIMap() {}
|
||||
inline PIMap() {}
|
||||
|
||||
//! \~english Copy constructor.
|
||||
//! \~russian Копирующий конструктор.
|
||||
PIMap(const PIMap<Key, T> & other) {*this = other;}
|
||||
inline PIMap(const PIMap<Key, T> & other) {*this = other;}
|
||||
|
||||
//! \~english Move constructor.
|
||||
//! \~russian Перемещающий конструктор.
|
||||
PIMap(PIMap<Key, T> && other) : pim_content(std::move(other.pim_content)), pim_index(std::move(other.pim_index)) {}
|
||||
inline PIMap(PIMap<Key, T> && other) : pim_content(std::move(other.pim_content)), pim_index(std::move(other.pim_index)) {}
|
||||
|
||||
//! \~english Contructs map from
|
||||
//! [C++11 initializer list](https://en.cppreference.com/w/cpp/utility/initializer_list).
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
//! PIMap <int, PIString> m{{1, "a"}, {2, "b"}};
|
||||
//! piCout << m; // {1, 2, 3}
|
||||
//! \endcode
|
||||
PIMap(std::initializer_list<std::pair<Key, T>> init_list) {
|
||||
inline PIMap(std::initializer_list<std::pair<Key, T>> init_list) {
|
||||
for (auto i: init_list) {
|
||||
insert(std::get<0>(i), std::get<1>(i));
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
|
||||
//! \~english Assign operator.
|
||||
//! \~russian Оператор присваивания.
|
||||
PIMap<Key, T> & operator =(const PIMap<Key, T> & other) {
|
||||
inline PIMap<Key, T> & operator =(const PIMap<Key, T> & other) {
|
||||
if (this == &other) return *this;
|
||||
clear();
|
||||
pim_content = other.pim_content;
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
|
||||
//! \~english Assign move operator.
|
||||
//! \~russian Оператор перемещающего присваивания.
|
||||
PIMap<Key, T> & operator =(PIMap<Key, T> && other) {
|
||||
inline PIMap<Key, T> & operator =(PIMap<Key, T> && other) {
|
||||
swap(other);
|
||||
return *this;
|
||||
}
|
||||
@@ -212,53 +212,53 @@ public:
|
||||
};
|
||||
|
||||
|
||||
iterator begin() {return iterator(this, 0);}
|
||||
inline iterator begin() {return iterator(this, 0);}
|
||||
|
||||
iterator end() {return iterator(this, size());}
|
||||
inline iterator end() {return iterator(this, size());}
|
||||
|
||||
const_iterator begin() const {return const_iterator(this, 0);}
|
||||
inline const_iterator begin() const {return const_iterator(this, 0);}
|
||||
|
||||
const_iterator end() const {return const_iterator(this, size());}
|
||||
inline const_iterator end() const {return const_iterator(this, size());}
|
||||
|
||||
const_iterator constBegin() const {return const_iterator(this, 0);}
|
||||
inline const_iterator constBegin() const {return const_iterator(this, 0);}
|
||||
|
||||
const_iterator constEnd() const {return const_iterator(this, size());}
|
||||
inline const_iterator constEnd() const {return const_iterator(this, size());}
|
||||
|
||||
reverse_iterator rbegin() {return reverse_iterator(this, size() - 1);}
|
||||
inline reverse_iterator rbegin() {return reverse_iterator(this, size() - 1);}
|
||||
|
||||
reverse_iterator rend() {return reverse_iterator(this, -1);}
|
||||
inline reverse_iterator rend() {return reverse_iterator(this, -1);}
|
||||
|
||||
const_reverse_iterator rbegin() const {return const_reverse_iterator(this, size() - 1);}
|
||||
inline const_reverse_iterator rbegin() const {return const_reverse_iterator(this, size() - 1);}
|
||||
|
||||
const_reverse_iterator rend() const {return const_reverse_iterator(this, -1);}
|
||||
inline const_reverse_iterator rend() const {return const_reverse_iterator(this, -1);}
|
||||
|
||||
const_reverse_iterator constRbegin() const {return const_reverse_iterator(this, size() - 1);}
|
||||
inline const_reverse_iterator constRbegin() const {return const_reverse_iterator(this, size() - 1);}
|
||||
|
||||
const_reverse_iterator constRend() const {return const_reverse_iterator(this, -1);}
|
||||
inline const_reverse_iterator constRend() const {return const_reverse_iterator(this, -1);}
|
||||
|
||||
//! \relatesalso PIMapIteratorConst
|
||||
PIMapIteratorConst<Key, T> makeIterator() const {return PIMapIteratorConst<Key, T>(*this);}
|
||||
inline PIMapIteratorConst<Key, T> makeIterator() const {return PIMapIteratorConst<Key, T>(*this);}
|
||||
|
||||
//! \relatesalso PIMapIterator
|
||||
PIMapIterator<Key, T> makeIterator() {return PIMapIterator<Key, T>(*this);}
|
||||
inline PIMapIterator<Key, T> makeIterator() {return PIMapIterator<Key, T>(*this);}
|
||||
|
||||
//! \relatesalso PIMapIteratorConstReverse
|
||||
PIMapIteratorConstReverse<Key, T> makeReverseIterator() const {return PIMapIteratorConstReverse<Key, T>(*this);}
|
||||
inline PIMapIteratorConstReverse<Key, T> makeReverseIterator() const {return PIMapIteratorConstReverse<Key, T>(*this);}
|
||||
|
||||
//! \relatesalso PIMapIteratorReverse
|
||||
PIMapIteratorReverse<Key, T> makeReverseIterator() {return PIMapIteratorReverse<Key, T>(*this);}
|
||||
inline PIMapIteratorReverse<Key, T> makeReverseIterator() {return PIMapIteratorReverse<Key, T>(*this);}
|
||||
|
||||
size_t size() const {return pim_content.size();}
|
||||
inline size_t size() const {return pim_content.size();}
|
||||
|
||||
int size_s() const {return pim_content.size_s();}
|
||||
inline int size_s() const {return pim_content.size_s();}
|
||||
|
||||
size_t length() const {return pim_content.size();}
|
||||
inline size_t length() const {return pim_content.size();}
|
||||
|
||||
bool isEmpty() const {return (pim_content.size() == 0);}
|
||||
inline bool isEmpty() const {return (pim_content.size() == 0);}
|
||||
|
||||
bool isNotEmpty() const {return (pim_content.size() > 0);}
|
||||
inline bool isNotEmpty() const {return (pim_content.size() > 0);}
|
||||
|
||||
T & operator [](const Key & key) {
|
||||
inline T & operator [](const Key & key) {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
if (f) return pim_content[pim_index[i].index];
|
||||
@@ -266,9 +266,10 @@ public:
|
||||
pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
|
||||
return pim_content.back();
|
||||
}
|
||||
T at(const Key & key) const {return value(key);}
|
||||
|
||||
T take(const Key & key) const {
|
||||
inline T at(const Key & key) const {return value(key);}
|
||||
|
||||
inline T take(const Key & key) const {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
if (!f) return T();
|
||||
@@ -277,7 +278,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
|
||||
inline PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
|
||||
#ifndef NDEBUG
|
||||
if (&other == this) {
|
||||
printf("error with PIMap<%s, %s>::<<\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T));
|
||||
@@ -300,28 +301,28 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator ==(const PIMap<Key, T> & t) const {
|
||||
inline bool operator ==(const PIMap<Key, T> & t) const {
|
||||
return (pim_content == t.pim_content && pim_index == t.pim_index);
|
||||
}
|
||||
bool operator !=(const PIMap<Key, T> & t) const {
|
||||
inline bool operator !=(const PIMap<Key, T> & t) const {
|
||||
return (pim_content != t.pim_content || pim_index != t.pim_index);
|
||||
}
|
||||
bool contains(const Key & key) const {
|
||||
inline bool contains(const Key & key) const {
|
||||
bool f(false); _find(key, f);
|
||||
return f;
|
||||
}
|
||||
|
||||
bool containsValue(const T & value) const {
|
||||
inline bool containsValue(const T & value) const {
|
||||
return pim_content.contains(value);
|
||||
}
|
||||
|
||||
PIMap<Key, T> & reserve(size_t new_size) {
|
||||
inline PIMap<Key, T> & reserve(size_t new_size) {
|
||||
pim_content.reserve(new_size);
|
||||
pim_index.reserve(new_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PIMap<Key, T> & remove(const Key & key) {
|
||||
inline PIMap<Key, T> & remove(const Key & key) {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
if (f) _remove(i);
|
||||
@@ -329,7 +330,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
PIMap<Key, T> & removeWhere(std::function<bool(const Key & key, const T & value)> test) {
|
||||
inline PIMap<Key, T> & removeWhere(std::function<bool(const Key & key, const T & value)> test) {
|
||||
for (int i = 0; i < pim_index.size_s(); ++i) {
|
||||
if (pim_index[i].key, pim_content[pim_index[i].index]) {
|
||||
_remove(i);
|
||||
@@ -338,20 +339,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
PIMap<Key, T> & erase(const Key & key) {return remove(key);}
|
||||
inline PIMap<Key, T> & erase(const Key & key) {return remove(key);}
|
||||
|
||||
PIMap<Key, T> & clear() {
|
||||
inline PIMap<Key, T> & clear() {
|
||||
pim_content.clear();
|
||||
pim_index.clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(PIMap<Key, T> & other) {
|
||||
inline void swap(PIMap<Key, T> & other) {
|
||||
pim_content.swap(other.pim_content);
|
||||
pim_index.swap(other.pim_index);
|
||||
}
|
||||
|
||||
PIMap<Key, T> & insert(const Key & key, const T & value) {
|
||||
inline PIMap<Key, T> & insert(const Key & key, const T & value) {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
if (f) {
|
||||
@@ -362,7 +363,8 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
PIMap<Key, T> & insert(const Key & key, T && value) {
|
||||
|
||||
inline PIMap<Key, T> & insert(const Key & key, T && value) {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
if (f) {
|
||||
@@ -373,7 +375,8 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
PIMap<Key, T> & insert(const PIPair<Key, T> & pair) {
|
||||
|
||||
inline PIMap<Key, T> & insert(const PIPair<Key, T> & pair) {
|
||||
bool f(false);
|
||||
ssize_t i = _find(pair.first, f);
|
||||
if (f) {
|
||||
@@ -384,7 +387,8 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
PIMap<Key, T> & insert(PIPair<Key, T> && pair) {
|
||||
|
||||
inline PIMap<Key, T> & insert(PIPair<Key, T> && pair) {
|
||||
bool f(false);
|
||||
Key k(std::move(pair.first));
|
||||
ssize_t i = _find(k, f);
|
||||
@@ -397,16 +401,16 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
T value(const Key & key, const T & default_ = T()) const {
|
||||
inline T value(const Key & key, const T & default_ = T()) const {
|
||||
bool f(false);
|
||||
ssize_t i = _find(key, f);
|
||||
if (!f) return default_;
|
||||
return pim_content[pim_index[i].index];
|
||||
}
|
||||
|
||||
PIVector<T> values() const {return pim_content;}
|
||||
inline PIVector<T> values() const {return pim_content;}
|
||||
|
||||
Key key(const T & value_, const Key & default_ = Key()) const {
|
||||
inline Key key(const T & value_, const Key & default_ = Key()) const {
|
||||
for (int i = 0; i < pim_index.size_s(); ++i) {
|
||||
if (pim_content[pim_index[i].index] == value_) {
|
||||
return pim_index[i].key;
|
||||
@@ -415,7 +419,7 @@ public:
|
||||
return default_;
|
||||
}
|
||||
|
||||
PIVector<Key> keys() const {
|
||||
inline PIVector<Key> keys() const {
|
||||
PIVector<Key> ret;
|
||||
ret.reserve(pim_index.size());
|
||||
for (int i = 0; i < pim_index.size_s(); ++i) {
|
||||
@@ -424,7 +428,7 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void forEach(std::function<void(const Key & key, const T & value)> f) const {
|
||||
inline void forEach(std::function<void(const Key & key, const T & value)> f) const {
|
||||
for (int i = 0; i < pim_index.size_s(); ++i) {
|
||||
f(pim_index[i].key, pim_content[pim_index[i].index]);
|
||||
}
|
||||
@@ -465,7 +469,7 @@ private:
|
||||
template <typename P, typename Key1, typename T1>
|
||||
friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<typename PIMap<Key1, T1>::MapIndex> & v);
|
||||
|
||||
ssize_t _binarySearch(ssize_t first, ssize_t last, const Key & key, bool & found) const {
|
||||
inline ssize_t _binarySearch(ssize_t first, ssize_t last, const Key & key, bool & found) const {
|
||||
ssize_t mid;
|
||||
while (first <= last) {
|
||||
mid = (first + last) / 2;
|
||||
@@ -477,7 +481,7 @@ private:
|
||||
return first;
|
||||
}
|
||||
|
||||
ssize_t _find(const Key & k, bool & found) const {
|
||||
inline ssize_t _find(const Key & k, bool & found) const {
|
||||
if (pim_index.isEmpty()) {
|
||||
found = false;
|
||||
return 0;
|
||||
@@ -485,7 +489,7 @@ private:
|
||||
return _binarySearch(0, pim_index.size_s() - 1, k, found);
|
||||
}
|
||||
|
||||
void _remove(ssize_t index) {
|
||||
inline void _remove(ssize_t index) {
|
||||
size_t ci = pim_index[index].index, bi = pim_index.size() - 1;
|
||||
pim_index.remove(index);
|
||||
for (size_t i = 0; i < pim_index.size(); ++i) {
|
||||
@@ -498,18 +502,18 @@ private:
|
||||
pim_content.resize(pim_index.size());
|
||||
}
|
||||
|
||||
const value_type _pair(ssize_t index) const {
|
||||
inline const value_type _pair(ssize_t index) const {
|
||||
if (index < 0 || index >= pim_index.size_s()) return value_type();
|
||||
return value_type(pim_index[index].key, pim_content[pim_index[index].index]);
|
||||
}
|
||||
|
||||
Key & _key(ssize_t index) {return pim_index[index].key;}
|
||||
inline Key & _key(ssize_t index) {return pim_index[index].key;}
|
||||
|
||||
const Key & _key(ssize_t index) const {return pim_index[index].key;}
|
||||
inline const Key & _key(ssize_t index) const {return pim_index[index].key;}
|
||||
|
||||
T & _value(ssize_t index) {return pim_content[pim_index[index].index];}
|
||||
inline T & _value(ssize_t index) {return pim_content[pim_index[index].index];}
|
||||
|
||||
const T & _value(ssize_t index) const {return pim_content[pim_index[index].index];}
|
||||
inline const T & _value(ssize_t index) const {return pim_content[pim_index[index].index];}
|
||||
|
||||
|
||||
PIVector<T> pim_content;
|
||||
@@ -549,19 +553,19 @@ template <typename Key, typename T>
|
||||
class PIMapIteratorConst {
|
||||
typedef PIMap<Key, T> MapType;
|
||||
public:
|
||||
PIMapIteratorConst(const PIMap<Key, T> & map): m(map), pos(-1) {}
|
||||
inline PIMapIteratorConst(const PIMap<Key, T> & map): m(map), pos(-1) {}
|
||||
|
||||
//! \~english Returns current key.
|
||||
//! \~russian Возвращает ключ текущего элемента.
|
||||
//! \~\sa \a value()
|
||||
const Key & key() const {
|
||||
inline const Key & key() const {
|
||||
return m._key(pos);
|
||||
}
|
||||
|
||||
//! \~english Returns current value.
|
||||
//! \~russian Возвращает значение текущего элемента.
|
||||
//! \~\sa \a key()
|
||||
const T & value() const {
|
||||
inline const T & value() const {
|
||||
return m._value(pos);
|
||||
}
|
||||
|
||||
@@ -625,19 +629,19 @@ template <typename Key, typename T>
|
||||
class PIMapIteratorConstReverse {
|
||||
typedef PIMap<Key, T> MapType;
|
||||
public:
|
||||
PIMapIteratorConstReverse(const PIMap<Key, T> & map): m(map), pos(m.size_s()) {}
|
||||
inline PIMapIteratorConstReverse(const PIMap<Key, T> & map): m(map), pos(m.size_s()) {}
|
||||
|
||||
//! \~english Returns current key.
|
||||
//! \~russian Возвращает ключ текущего элемента.
|
||||
//! \~\sa \a value()
|
||||
const Key & key() const {
|
||||
inline const Key & key() const {
|
||||
return m._key(pos);
|
||||
}
|
||||
|
||||
//! \~english Returns current value.
|
||||
//! \~russian Возвращает значение текущего элемента.
|
||||
//! \~\sa \a key()
|
||||
const T & value() const {
|
||||
inline const T & value() const {
|
||||
return m._value(pos);
|
||||
}
|
||||
|
||||
@@ -701,19 +705,19 @@ template <typename Key, typename T>
|
||||
class PIMapIterator {
|
||||
typedef PIMap<Key, T> MapType;
|
||||
public:
|
||||
PIMapIterator(PIMap<Key, T> & map): m(map), pos(-1) {}
|
||||
inline PIMapIterator(PIMap<Key, T> & map): m(map), pos(-1) {}
|
||||
|
||||
//! \~english Returns current key.
|
||||
//! \~russian Возвращает ключ текущего элемента.
|
||||
//! \~\sa \a value()
|
||||
const Key & key() const {
|
||||
inline const Key & key() const {
|
||||
return m._key(pos);
|
||||
}
|
||||
|
||||
//! \~english Returns current value.
|
||||
//! \~russian Возвращает значение текущего элемента.
|
||||
//! \~\sa \a key()
|
||||
T & value() {
|
||||
inline T & value() {
|
||||
return m._value(pos);
|
||||
}
|
||||
|
||||
@@ -777,19 +781,19 @@ template <typename Key, typename T>
|
||||
class PIMapIteratorReverse {
|
||||
typedef PIMap<Key, T> MapType;
|
||||
public:
|
||||
PIMapIteratorReverse(PIMap<Key, T> & map): m(map), pos(m.size_s()) {}
|
||||
inline PIMapIteratorReverse(PIMap<Key, T> & map): m(map), pos(m.size_s()) {}
|
||||
|
||||
//! \~english Returns current key.
|
||||
//! \~russian Возвращает ключ текущего элемента.
|
||||
//! \~\sa \a value()
|
||||
const Key & key() const {
|
||||
inline const Key & key() const {
|
||||
return m._key(pos);
|
||||
}
|
||||
|
||||
//! \~english Returns current value.
|
||||
//! \~russian Возвращает значение текущего элемента.
|
||||
//! \~\sa \a key()
|
||||
T & value() {
|
||||
inline T & value() {
|
||||
return m._value(pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ template<typename T>
|
||||
class PIQueue: public PIDeque<T> {
|
||||
public:
|
||||
PIQueue() {}
|
||||
virtual ~PIQueue() {}
|
||||
PIDeque<T> & enqueue(const T & v) {PIDeque<T>::push_front(v); return *this;}
|
||||
PIDeque<T> & enqueue(T && v) {PIDeque<T>::push_front(std::move(v)); return *this;}
|
||||
T dequeue() {return PIDeque<T>::take_back();}
|
||||
|
||||
@@ -42,8 +42,6 @@ public:
|
||||
//! Contructs an empty set
|
||||
PISet() {}
|
||||
|
||||
virtual ~PISet() {;}
|
||||
|
||||
//! Contructs set with one element "value"
|
||||
PISet(const T & value) {_CSet::insert(value, 0);}
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
template<typename T>
|
||||
class PIStack: public PIVector<T> {
|
||||
public:
|
||||
PIStack() {;}
|
||||
virtual ~PIStack() {;}
|
||||
PIStack() {}
|
||||
PIVector<T> & push(const T & v) {PIVector<T>::push_back(v); return *this;}
|
||||
PIVector<T> & push(T && v) {PIVector<T>::push_back(std::move(v)); return *this;}
|
||||
T pop() {return PIVector<T>::take_back();}
|
||||
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
v._reset();
|
||||
}
|
||||
|
||||
inline virtual ~PIVector() {
|
||||
inline ~PIVector() {
|
||||
PIINTROSPECTION_CONTAINER_DELETE(T)
|
||||
PIINTROSPECTION_CONTAINER_FREE(T, (piv_rsize))
|
||||
deleteT(piv_data, piv_size);
|
||||
|
||||
@@ -39,17 +39,21 @@ template <typename T>
|
||||
class PIVector2D {
|
||||
public:
|
||||
inline PIVector2D() {rows_ = cols_ = 0;}
|
||||
|
||||
inline PIVector2D(size_t rows, size_t cols, const T & f = T()) {
|
||||
rows_ = rows;
|
||||
cols_ = cols;
|
||||
mat.resize(rows*cols, f);
|
||||
}
|
||||
|
||||
inline PIVector2D(size_t rows, size_t cols, const PIVector<T> & v) : rows_(rows), cols_(cols), mat(v) {
|
||||
mat.resize(rows*cols);
|
||||
}
|
||||
|
||||
inline PIVector2D(size_t rows, size_t cols, PIVector<T> && v) : rows_(rows), cols_(cols), mat(std::move(v)) {
|
||||
mat.resize(rows*cols);
|
||||
}
|
||||
|
||||
inline PIVector2D(const PIVector<PIVector<T>> & v) {
|
||||
rows_ = v.size();
|
||||
if (rows_) {
|
||||
@@ -64,13 +68,21 @@ public:
|
||||
}
|
||||
|
||||
inline size_t rows() const {return rows_;}
|
||||
|
||||
inline size_t cols() const {return cols_;}
|
||||
|
||||
inline size_t size() const {return mat.size();}
|
||||
|
||||
inline ssize_t size_s() const {return mat.size_s();}
|
||||
|
||||
inline size_t length() const {return mat.length();}
|
||||
|
||||
inline size_t capacity() const {return mat.capacity();}
|
||||
|
||||
inline bool isEmpty() const {return mat.isEmpty();}
|
||||
|
||||
inline bool isNotEmpty() const {return mat.isNotEmpty();}
|
||||
|
||||
class Row {
|
||||
friend class PIVector2D<T>;
|
||||
private:
|
||||
@@ -243,16 +255,19 @@ public:
|
||||
}
|
||||
inline bool operator !=(const PIVector2D<T> & t) const {return !(*this == t);}
|
||||
|
||||
PIVector<PIVector<T> > toVectors() const {
|
||||
inline PIVector<PIVector<T> > toVectors() const {
|
||||
PIVector<PIVector<T> > ret;
|
||||
ret.reserve(rows_);
|
||||
for(size_t i = 0; i < rows_; ++i)
|
||||
ret << PIVector<T>(mat.data(i*cols_), cols_);
|
||||
return ret;
|
||||
}
|
||||
PIVector<T> toPlainVector() const {return mat;}
|
||||
PIVector<T> & plainVector() {return mat;}
|
||||
const PIVector<T> & plainVector() const {return mat;}
|
||||
|
||||
inline PIVector<T> toPlainVector() const {return mat;}
|
||||
|
||||
inline PIVector<T> & plainVector() {return mat;}
|
||||
|
||||
inline const PIVector<T> & plainVector() const {return mat;}
|
||||
|
||||
inline void swap(PIVector2D<T> & other) {
|
||||
mat.swap(other.mat);
|
||||
@@ -275,11 +290,16 @@ public:
|
||||
mat.clear();
|
||||
}
|
||||
|
||||
void forEach(std::function<void(const T &)> f) const {
|
||||
template <typename ST>
|
||||
inline PIVector2D<ST> map(std::function<ST(const T & e)> f) const {
|
||||
return PIVector2D<ST>(rows_, cols_, mat.map(f));
|
||||
}
|
||||
|
||||
inline void forEach(std::function<void(const T &)> f) const {
|
||||
mat.forEach(f);
|
||||
}
|
||||
|
||||
PIVector2D<T> & forEach(std::function<void(T &)> f) {
|
||||
inline PIVector2D<T> & forEach(std::function<void(T &)> f) {
|
||||
mat.forEach(f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ extern PIP_EXPORT char * __utf8name__;
|
||||
class PIP_EXPORT PIChar
|
||||
{
|
||||
friend class PIString;
|
||||
friend PICout PIP_EXPORT operator <<(PICout s, const PIChar & v);
|
||||
friend PICout operator <<(PICout s, const PIChar & v);
|
||||
public:
|
||||
//! \~english Contructs Ascii symbol
|
||||
//! \~russian Создает символ Ascii
|
||||
PIChar(char c) {ch = c; ch &= 0xFF;}
|
||||
PIChar(char c) {ch = c;}
|
||||
|
||||
//! \~english Contructs ascii symbol
|
||||
//! \~russian Создает символ Ascii
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
//! \relatesalso PIChar
|
||||
//! \~english Output operator to \a PICout
|
||||
//! \~russian Оператор вывода в \a PICout
|
||||
PICout PIP_EXPORT operator <<(PICout s, const PIChar & v);
|
||||
PIP_EXPORT PICout operator <<(PICout s, const PIChar & v);
|
||||
|
||||
//! \relatesalso PIChar
|
||||
//! \~english Compare operator
|
||||
|
||||
@@ -154,21 +154,13 @@ DWORD PICout::__Private__::smode = 0;
|
||||
#endif
|
||||
|
||||
PICout::PICout(int controls): fo_(true), cc_(false), fc_(false), act_(true), cnb_(10), co_(controls) {
|
||||
buffer_ = nullptr;
|
||||
init();
|
||||
}
|
||||
|
||||
PICout::PICout(bool active): fo_(true), cc_(false), fc_(false), act_(active), cnb_(10), co_(PICoutManipulators::DefaultControls) {
|
||||
buffer_ = nullptr;
|
||||
if (act_)
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
PICout::PICout(PIString * buffer, int id, PIFlags<PICoutManipulators::PICoutControl> controls): fo_(true), cc_(false),
|
||||
fc_(false), act_(true), cnb_(10), co_(controls) {
|
||||
init();
|
||||
buffer_ = buffer;
|
||||
id_ = id;
|
||||
if (act_) init();
|
||||
}
|
||||
|
||||
|
||||
@@ -182,14 +174,16 @@ PICout::~PICout() {
|
||||
if (fc_) applyFormat(PICoutManipulators::Default);
|
||||
if (cc_) return;
|
||||
newLine();
|
||||
if ((co_ & NoLock) != NoLock)
|
||||
if ((co_ & NoLock) != NoLock) {
|
||||
PICout::__mutex__().unlock();
|
||||
if (buffer_)
|
||||
}
|
||||
if (buffer_) {
|
||||
((NotifierObject*)Notifier::object())->finished(id_, buffer_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PICout PICout::operator <<(const PICoutAction v) {
|
||||
PICout & PICout::operator <<(PICoutAction v) {
|
||||
if (!act_) return *this;
|
||||
#ifdef WINDOWS
|
||||
CONSOLE_SCREEN_BUFFER_INFO sbi;
|
||||
@@ -198,8 +192,9 @@ PICout PICout::operator <<(const PICoutAction v) {
|
||||
#endif
|
||||
switch (v) {
|
||||
case PICoutManipulators::Flush:
|
||||
if (!buffer_ && isOutputDeviceActive(StdOut))
|
||||
if (!buffer_ && isOutputDeviceActive(StdOut)) {
|
||||
std::cout << std::flush;
|
||||
}
|
||||
break;
|
||||
case PICoutManipulators::Backspace:
|
||||
if (isOutputDeviceActive(StdOut)) {
|
||||
@@ -275,7 +270,7 @@ PICout PICout::operator <<(const PICoutAction v) {
|
||||
}
|
||||
|
||||
|
||||
PICout PICout::operator <<(const PICoutManipulators::PICoutFormat v) {
|
||||
PICout & PICout::operator <<(PICoutManipulators::PICoutFormat v) {
|
||||
switch (v) {
|
||||
case PICoutManipulators::Bin: cnb_ = 2; break;
|
||||
case PICoutManipulators::Oct: cnb_ = 8; break;
|
||||
@@ -287,7 +282,7 @@ PICout PICout::operator <<(const PICoutManipulators::PICoutFormat v) {
|
||||
}
|
||||
|
||||
|
||||
PICout PICout::operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v) {
|
||||
PICout & PICout::operator <<(PIFlags<PICoutManipulators::PICoutFormat> v) {
|
||||
if (v[PICoutManipulators::Bin]) cnb_ = 2;
|
||||
if (v[PICoutManipulators::Oct]) cnb_ = 8;
|
||||
if (v[PICoutManipulators::Dec]) cnb_ = 10;
|
||||
@@ -338,40 +333,73 @@ PICout PICout::operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v)
|
||||
if (PICout::isOutputDeviceActive(PICout::StdOut)) std::cout << (v);\
|
||||
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g');\
|
||||
}\
|
||||
}\
|
||||
return *this;
|
||||
|
||||
|
||||
PICout & PICout::operator <<(const PIString & v) {
|
||||
space();
|
||||
quote();
|
||||
write(v);
|
||||
quote();
|
||||
return *this;
|
||||
}
|
||||
|
||||
PICout & PICout::operator <<(const char * v) {
|
||||
if (!act_ || !v) return *this;
|
||||
if (v[0] == '\0') return *this;
|
||||
space();
|
||||
quote();
|
||||
write(v);
|
||||
quote();
|
||||
return *this;
|
||||
}
|
||||
|
||||
PICout PICout::operator <<(const char * v) {if (!act_ || !v) return *this; if (v[0] == '\0') return *this; space(); quote(); write(v); quote(); return *this;}
|
||||
PICout & PICout::operator <<(bool v) {
|
||||
if (!act_) return *this;
|
||||
space();
|
||||
if (v) write("true");
|
||||
else write("false");
|
||||
return *this;
|
||||
}
|
||||
|
||||
PICout PICout::operator <<(const bool v) {if (!act_) return *this; space(); if (v) write("true"); else write("false"); return *this;}
|
||||
PICout & PICout::operator <<(char v) {
|
||||
if (!act_) return *this;
|
||||
space();
|
||||
write(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PICout PICout::operator <<(const char v) {if (!act_) return *this; space(); write(v); return *this;}
|
||||
PICout & PICout::operator <<(uchar v) {PIINTCOUT(ushort(v))}
|
||||
|
||||
PICout PICout::operator <<(const uchar v) {PIINTCOUT(ushort(v))}
|
||||
PICout & PICout::operator <<(short int v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const short int v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(ushort v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const ushort v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(int v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const int v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(uint v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const uint v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(long v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const long v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(ulong v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const ulong v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(llong v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const llong v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(ullong v) {PIINTCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const ullong v) {PIINTCOUT(v)}
|
||||
PICout & PICout::operator <<(float v) {if (!act_) return *this; space(); PIFLOATCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const float v) {if (!act_) return *this; space(); PIFLOATCOUT(v) return *this;}
|
||||
PICout & PICout::operator <<(double v) {if (!act_) return *this; space(); PIFLOATCOUT(v)}
|
||||
|
||||
PICout PICout::operator <<(const double v) {if (!act_) return *this; space(); PIFLOATCOUT(v) return *this;}
|
||||
PICout & PICout::operator <<(void * v) {
|
||||
if (!act_) return *this;
|
||||
space();
|
||||
write("0x" + PIString::fromNumber(ullong(v), 16));
|
||||
return *this;
|
||||
}
|
||||
|
||||
PICout PICout::operator <<(const void * v) {if (!act_) return *this; space(); write("0x" + PIString::fromNumber(ullong(v), 16)); return *this;}
|
||||
|
||||
PICout PICout::operator <<(const PIObject * v) {
|
||||
PICout & PICout::operator <<(const PIObject * v) {
|
||||
if (!act_) return *this;
|
||||
space();
|
||||
if (v == 0) write("PIObject*(0x0)");
|
||||
@@ -382,7 +410,7 @@ PICout PICout::operator <<(const PIObject * v) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
PICout PICout::operator <<(const PICoutSpecialChar v) {
|
||||
PICout & PICout::operator <<(PICoutSpecialChar v) {
|
||||
if (!act_) return *this;
|
||||
switch (v) {
|
||||
case Null:
|
||||
@@ -581,11 +609,11 @@ void PICout::init() {
|
||||
}
|
||||
attr_ = __Private__::dattr;
|
||||
#endif
|
||||
buffer_ = nullptr;
|
||||
id_ = 0;
|
||||
if ((co_ & NoLock) != NoLock)
|
||||
if ((co_ & NoLock) != NoLock) {
|
||||
PICout::__mutex__().lock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PICout::applyFormat(PICoutFormat f) {
|
||||
@@ -686,3 +714,11 @@ void PICout::setOutputDevices(PICout::OutputDevices d) {
|
||||
bool PICout::isOutputDeviceActive(PICout::OutputDevice d) {
|
||||
return devs[d];
|
||||
}
|
||||
|
||||
|
||||
PICout PICout::withExternalBuffer(PIString * buffer, int id, PIFlags<PICoutManipulators::PICoutControl> controls) {
|
||||
PICout c(controls);
|
||||
c.buffer_ = buffer;
|
||||
c.id_ = id;
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -140,10 +140,6 @@ public:
|
||||
//! \~russian Конструктор по умолчанию (AddSpaces и AddNewLine), но если не \"active\" то будет неактивным
|
||||
PICout(bool active);
|
||||
|
||||
//! \~english Construct with external buffer and ID "id". See \a Notifier for details
|
||||
//! \~russian Конструктор с внешним буфером и ID "id". Подробнее \a Notifier
|
||||
PICout(PIString * buffer, int id = 0, PIFlags<PICoutManipulators::PICoutControl> controls = PICoutManipulators::AddSpaces | PICoutManipulators::AddNewLine);
|
||||
|
||||
PICout(const PICout & other);
|
||||
|
||||
~PICout();
|
||||
@@ -176,86 +172,87 @@ public:
|
||||
|
||||
//! \~english Output operator for strings with <tt>"const char * "</tt> type
|
||||
//! \~russian Оператор вывода для строк <tt>"const char * "</tt>
|
||||
PICout operator <<(const char * v);
|
||||
PICout & operator <<(const char * v);
|
||||
|
||||
// ! Output operator for strings with <tt>"std::string"</tt> type
|
||||
//PICout operator <<(const std::string & v);
|
||||
//! \~english Output operator for \a PIString
|
||||
//! \~russian Оператор вывода для \a PIString
|
||||
PICout & operator <<(const PIString & v);
|
||||
|
||||
//! \~english Output operator for boolean values
|
||||
//! \~russian Оператор вывода для логических значений
|
||||
PICout operator <<(const bool v);
|
||||
PICout & operator <<(bool v);
|
||||
|
||||
//! \~english Output operator for <tt>"char"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"char"</tt> значений
|
||||
PICout operator <<(const char v);
|
||||
PICout & operator <<(char v);
|
||||
|
||||
//! \~english Output operator for <tt>"unsigned char"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"unsigned char"</tt> значений
|
||||
PICout operator <<(const uchar v);
|
||||
PICout & operator <<(uchar v);
|
||||
|
||||
//! \~english Output operator for <tt>"short"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"short"</tt> значений
|
||||
PICout operator <<(const short v);
|
||||
PICout & operator <<(short v);
|
||||
|
||||
//! \~english Output operator for <tt>"unsigned short"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"unsigned short"</tt> значений
|
||||
PICout operator <<(const ushort v);
|
||||
PICout & operator <<(ushort v);
|
||||
|
||||
//! \~english Output operator for <tt>"int"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"int"</tt> значений
|
||||
PICout operator <<(const int v);
|
||||
PICout & operator <<(int v);
|
||||
|
||||
//! \~english Output operator for <tt>"unsigned int"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"unsigned int"</tt> значений
|
||||
PICout operator <<(const uint v);
|
||||
PICout & operator <<(uint v);
|
||||
|
||||
//! \~english Output operator for <tt>"long"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"long"</tt> значений
|
||||
PICout operator <<(const long v);
|
||||
PICout & operator <<(long v);
|
||||
|
||||
//! \~english Output operator for <tt>"unsigned long"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"unsigned long"</tt> значений
|
||||
PICout operator <<(const ulong v);
|
||||
PICout & operator <<(ulong v);
|
||||
|
||||
//! \~english Output operator for <tt>"long long"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"long long"</tt> значений
|
||||
PICout operator <<(const llong v);
|
||||
PICout & operator <<(llong v);
|
||||
|
||||
//! \~english Output operator for <tt>"unsigned long long"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"unsigned long long"</tt> значений
|
||||
PICout operator <<(const ullong v);
|
||||
PICout & operator <<(ullong v);
|
||||
|
||||
//! \~english Output operator for <tt>"float"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"float"</tt> значений
|
||||
PICout operator <<(const float v);
|
||||
PICout & operator <<(float v);
|
||||
|
||||
//! \~english Output operator for <tt>"double"</tt> values
|
||||
//! \~russian Оператор вывода для <tt>"double"</tt> значений
|
||||
PICout operator <<(const double v);
|
||||
PICout & operator <<(double v);
|
||||
|
||||
//! \~english Output operator for pointers
|
||||
//! \~russian Оператор вывода для указателей
|
||||
PICout operator <<(const void * v);
|
||||
PICout & operator <<(void * v);
|
||||
|
||||
//! \~english Output operator for PIObject and ancestors
|
||||
//! \~russian Оператор вывода для PIObject и наследников
|
||||
PICout operator <<(const PIObject * v);
|
||||
PICout & operator <<(const PIObject * v);
|
||||
|
||||
//! \~english Output operator for \a PICoutSpecialChar values
|
||||
//! \~russian Оператор вывода для \a PICoutSpecialChar
|
||||
PICout operator <<(const PICoutManipulators::PICoutSpecialChar v);
|
||||
PICout & operator <<(PICoutManipulators::PICoutSpecialChar v);
|
||||
|
||||
//! \~english Output operator for \a PIFlags<PICoutFormat> values
|
||||
//! \~russian Оператор вывода для \a PIFlags<PICoutFormat>
|
||||
PICout operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v);
|
||||
PICout & operator <<(PIFlags<PICoutManipulators::PICoutFormat> v);
|
||||
|
||||
//! \~english Output operator for \a PICoutFormat values
|
||||
//! \~russian Оператор вывода для \a PICoutFormat
|
||||
PICout operator <<(const PICoutManipulators::PICoutFormat v);
|
||||
PICout & operator <<(PICoutManipulators::PICoutFormat v);
|
||||
|
||||
//! \~english Do some action
|
||||
//! \~russian Делает действие
|
||||
PICout operator <<(const PICoutManipulators::PICoutAction v);
|
||||
PICout & operator <<(PICoutManipulators::PICoutAction v);
|
||||
|
||||
//! \~english Set control flag "c" is "on" state
|
||||
//! \~russian Установить флаг "c" в "on" состояние
|
||||
@@ -348,6 +345,11 @@ public:
|
||||
//! \~russian Возвращает активно ли устройство вывода "d"
|
||||
static bool isOutputDeviceActive(OutputDevice d);
|
||||
|
||||
|
||||
//! \~english Construct with external buffer and ID "id". See \a Notifier for details
|
||||
//! \~russian Конструктор с внешним буфером и ID "id". Подробнее \a Notifier
|
||||
static PICout withExternalBuffer(PIString * buffer, int id = 0, PIFlags<PICoutManipulators::PICoutControl> controls = PICoutManipulators::AddSpaces | PICoutManipulators::AddNewLine);
|
||||
|
||||
static PIMutex & __mutex__();
|
||||
static PIString & __string__();
|
||||
|
||||
|
||||
@@ -411,6 +411,12 @@ PIString & PIString::operator +=(const char * str) {
|
||||
}
|
||||
|
||||
|
||||
PIString & PIString::operator +=(const PIByteArray & ba) {
|
||||
appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
PIString::~PIString() {
|
||||
deleteData();
|
||||
}
|
||||
@@ -1685,11 +1691,3 @@ PIString versionNormalize(const PIString & v) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PICout operator <<(PICout s, const PIString & v) {
|
||||
s.space();
|
||||
s.quote();
|
||||
s.write(v);
|
||||
s.quote();
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
PIString & operator +=(const char c) {d.push_back(PIChar(c)); return *this;}
|
||||
PIString & operator +=(const char * str);
|
||||
PIString & operator +=(const wchar_t * str);
|
||||
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
|
||||
PIString & operator +=(const PIByteArray & ba);
|
||||
PIString & operator +=(const PIString & str);
|
||||
PIString & operator +=(const PIConstChars & str);
|
||||
|
||||
@@ -107,11 +107,11 @@ public:
|
||||
|
||||
//! \~english Contructs string with single character "c".
|
||||
//! \~russian Создает строку из одного символа "c".
|
||||
PIString(const PIChar c) {*this += c;}
|
||||
PIString(const PIChar c) {d.push_back(c);}
|
||||
|
||||
//! \~english Contructs string with single character "c".
|
||||
//! \~russian Создает строку из одного символа "c".
|
||||
PIString(const char c) {*this += PIChar(c);}
|
||||
PIString(const char c) {d.push_back(PIChar(c));}
|
||||
|
||||
//! \~english Contructs string from C-string "str" (system codepage).
|
||||
//! \~russian Создает строку из C-строки "str" (кодировка системы).
|
||||
@@ -1517,12 +1517,6 @@ private:
|
||||
mutable char * data_ = nullptr;
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PICout
|
||||
//! \~english Output operator to \a PICout.
|
||||
//! \~russian Оператор вывода в \a PICout.
|
||||
PIP_EXPORT PICout operator <<(PICout s, const PIString & v);
|
||||
|
||||
//! \relatesalso PIBinaryStream
|
||||
//! \~english Store operator.
|
||||
//! \~russian Оператор сохранения.
|
||||
@@ -1548,11 +1542,11 @@ inline PIString operator +(const char * str, const PIString & f) {return PIStrin
|
||||
|
||||
//! \~english Returns concatenated string.
|
||||
//! \~russian Возвращает соединение строк.
|
||||
inline PIString operator +(const char c, const PIString & f) {return PIChar(c) + f;}
|
||||
inline PIString operator +(const char c, const PIString & f) {return PIString(c) + f;}
|
||||
|
||||
//! \~english Returns concatenated string.
|
||||
//! \~russian Возвращает соединение строк.
|
||||
inline PIString operator +(const PIString & f, const char c) {return f + PIChar(c);}
|
||||
inline PIString operator +(const PIString & f, const char c) {PIString s(f); s.push_back(c); return s;}
|
||||
|
||||
|
||||
//! \relatesalso PIString
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
const char PIFileTransfer::sign[] = {'P', 'F', 'T'};
|
||||
|
||||
PIFileTransfer::PIFileTransfer() {
|
||||
for (uint i = 0; i < sizeof(sign); i++)
|
||||
pftheader.sig[i] = sign[i];
|
||||
for (uint i = 0; i < sizeof(sign); i++) pftheader.sig[i] = sign[i];
|
||||
pftheader.version = __PIFILETRANSFER_VERSION;
|
||||
pftheader.session_id = 0;
|
||||
pftheader.step = pft_None;
|
||||
|
||||
@@ -238,7 +238,15 @@ inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<
|
||||
}
|
||||
|
||||
template<uint Size, typename Type>
|
||||
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << "{"; PIMV_FOR {s << v[i]; if (i < Size - 1) s << ", ";} s << "}"; return s;}
|
||||
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {
|
||||
s << "Vector{";
|
||||
PIMV_FOR {
|
||||
s << v[i];
|
||||
if (i < Size - 1) s << ", ";
|
||||
}
|
||||
s << "}";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
typedef PIMathVectorT<2u, int> PIMathVectorT2i;
|
||||
@@ -510,7 +518,15 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v
|
||||
#endif
|
||||
|
||||
template<typename Type>
|
||||
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
|
||||
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {
|
||||
s << "Vector{";
|
||||
for (uint i = 0; i < v.size(); ++i) {
|
||||
s << v[i];
|
||||
if (i < v.size() - 1) s << ", ";
|
||||
}
|
||||
s << "}";
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename P, typename T>
|
||||
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathVector<T> & v) {s << v.c; return s;}
|
||||
|
||||
20
main.cpp
20
main.cpp
@@ -5,19 +5,9 @@
|
||||
using namespace PICoutManipulators;
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
float a_read[10], a_write[10];
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
a_read [i] = 0.f;
|
||||
a_write[i] = i / 10.f;
|
||||
}
|
||||
|
||||
PIByteArray data;
|
||||
data << PIMemoryBlock(a_write, 10 * sizeof(float));
|
||||
|
||||
piCout << data.toHex();
|
||||
|
||||
data >> PIMemoryBlock(a_read, 10 * sizeof(float));
|
||||
for (int i = 0; i < 10; ++i)
|
||||
piCout << a_read[i];
|
||||
|
||||
//PIMap<int, PIString> v{{1, "xdsa"},{2, "blya"},{3, "\n"}};
|
||||
PIVector<int> x{1,2};
|
||||
piCout << 1 << 2;
|
||||
piCout << 1 << 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user