picout and clean

This commit is contained in:
Бычков Андрей
2022-08-08 16:44:37 +03:00
parent 8551499a5e
commit 724a2dffcf
16 changed files with 242 additions and 187 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip) project(pip)
set(pip_MAJOR 2) set(pip_MAJOR 2)
set(pip_MINOR 99) set(pip_MINOR 100)
set(pip_REVISION 0) set(pip_REVISION 0)
set(pip_SUFFIX ) set(pip_SUFFIX )
set(pip_COMPANY SHS) set(pip_COMPANY SHS)

View File

@@ -196,7 +196,7 @@ public:
other._reset(); other._reset();
} }
inline virtual ~PIDeque() { inline ~PIDeque() {
PIINTROSPECTION_CONTAINER_DELETE(T) PIINTROSPECTION_CONTAINER_DELETE(T)
PIINTROSPECTION_CONTAINER_FREE(T, (pid_rsize)) PIINTROSPECTION_CONTAINER_FREE(T, (pid_rsize))
deleteT(pid_data + pid_start, pid_size); deleteT(pid_data + pid_start, pid_size);

View File

@@ -91,15 +91,15 @@ public:
//! \~english Constructs an empty map. //! \~english Constructs an empty map.
//! \~russian Создает пустой словарь. //! \~russian Создает пустой словарь.
PIMap() {} inline PIMap() {}
//! \~english Copy constructor. //! \~english Copy constructor.
//! \~russian Копирующий конструктор. //! \~russian Копирующий конструктор.
PIMap(const PIMap<Key, T> & other) {*this = other;} inline PIMap(const PIMap<Key, T> & other) {*this = other;}
//! \~english Move constructor. //! \~english Move constructor.
//! \~russian Перемещающий конструктор. //! \~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 //! \~english Contructs map from
//! [C++11 initializer list](https://en.cppreference.com/w/cpp/utility/initializer_list). //! [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"}}; //! PIMap <int, PIString> m{{1, "a"}, {2, "b"}};
//! piCout << m; // {1, 2, 3} //! piCout << m; // {1, 2, 3}
//! \endcode //! \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) { for (auto i: init_list) {
insert(std::get<0>(i), std::get<1>(i)); insert(std::get<0>(i), std::get<1>(i));
} }
@@ -118,7 +118,7 @@ public:
//! \~english Assign operator. //! \~english Assign operator.
//! \~russian Оператор присваивания. //! \~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; if (this == &other) return *this;
clear(); clear();
pim_content = other.pim_content; pim_content = other.pim_content;
@@ -128,7 +128,7 @@ public:
//! \~english Assign move operator. //! \~english Assign move operator.
//! \~russian Оператор перемещающего присваивания. //! \~russian Оператор перемещающего присваивания.
PIMap<Key, T> & operator =(PIMap<Key, T> && other) { inline PIMap<Key, T> & operator =(PIMap<Key, T> && other) {
swap(other); swap(other);
return *this; 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 //! \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 //! \relatesalso PIMapIterator
PIMapIterator<Key, T> makeIterator() {return PIMapIterator<Key, T>(*this);} inline PIMapIterator<Key, T> makeIterator() {return PIMapIterator<Key, T>(*this);}
//! \relatesalso PIMapIteratorConstReverse //! \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 //! \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); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
if (f) return pim_content[pim_index[i].index]; if (f) return pim_content[pim_index[i].index];
@@ -266,9 +266,10 @@ public:
pim_index.insert(i, MapIndex(key, pim_content.size() - 1)); pim_index.insert(i, MapIndex(key, pim_content.size() - 1));
return pim_content.back(); 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); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
if (!f) return T(); if (!f) return T();
@@ -277,7 +278,7 @@ public:
return ret; return ret;
} }
PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) { inline PIMap<Key, T> & operator <<(const PIMap<Key, T> & other) {
#ifndef NDEBUG #ifndef NDEBUG
if (&other == this) { if (&other == this) {
printf("error with PIMap<%s, %s>::<<\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T)); printf("error with PIMap<%s, %s>::<<\n", __PIP_TYPENAME__(Key), __PIP_TYPENAME__(T));
@@ -300,28 +301,28 @@ public:
return *this; 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); 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); 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); bool f(false); _find(key, f);
return f; return f;
} }
bool containsValue(const T & value) const { inline bool containsValue(const T & value) const {
return pim_content.contains(value); 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_content.reserve(new_size);
pim_index.reserve(new_size); pim_index.reserve(new_size);
return *this; return *this;
} }
PIMap<Key, T> & remove(const Key & key) { inline PIMap<Key, T> & remove(const Key & key) {
bool f(false); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
if (f) _remove(i); 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) { for (int i = 0; i < pim_index.size_s(); ++i) {
if (pim_index[i].key, pim_content[pim_index[i].index]) { if (pim_index[i].key, pim_content[pim_index[i].index]) {
_remove(i); _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_content.clear();
pim_index.clear(); pim_index.clear();
return *this; return *this;
} }
void swap(PIMap<Key, T> & other) { inline void swap(PIMap<Key, T> & other) {
pim_content.swap(other.pim_content); pim_content.swap(other.pim_content);
pim_index.swap(other.pim_index); 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); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
if (f) { if (f) {
@@ -362,7 +363,8 @@ public:
} }
return *this; return *this;
} }
PIMap<Key, T> & insert(const Key & key, T && value) {
inline PIMap<Key, T> & insert(const Key & key, T && value) {
bool f(false); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
if (f) { if (f) {
@@ -373,7 +375,8 @@ public:
} }
return *this; return *this;
} }
PIMap<Key, T> & insert(const PIPair<Key, T> & pair) {
inline PIMap<Key, T> & insert(const PIPair<Key, T> & pair) {
bool f(false); bool f(false);
ssize_t i = _find(pair.first, f); ssize_t i = _find(pair.first, f);
if (f) { if (f) {
@@ -384,7 +387,8 @@ public:
} }
return *this; return *this;
} }
PIMap<Key, T> & insert(PIPair<Key, T> && pair) {
inline PIMap<Key, T> & insert(PIPair<Key, T> && pair) {
bool f(false); bool f(false);
Key k(std::move(pair.first)); Key k(std::move(pair.first));
ssize_t i = _find(k, f); ssize_t i = _find(k, f);
@@ -397,16 +401,16 @@ public:
return *this; 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); bool f(false);
ssize_t i = _find(key, f); ssize_t i = _find(key, f);
if (!f) return default_; if (!f) return default_;
return pim_content[pim_index[i].index]; 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) { for (int i = 0; i < pim_index.size_s(); ++i) {
if (pim_content[pim_index[i].index] == value_) { if (pim_content[pim_index[i].index] == value_) {
return pim_index[i].key; return pim_index[i].key;
@@ -415,7 +419,7 @@ public:
return default_; return default_;
} }
PIVector<Key> keys() const { inline PIVector<Key> keys() const {
PIVector<Key> ret; PIVector<Key> ret;
ret.reserve(pim_index.size()); ret.reserve(pim_index.size());
for (int i = 0; i < pim_index.size_s(); ++i) { for (int i = 0; i < pim_index.size_s(); ++i) {
@@ -424,7 +428,7 @@ public:
return ret; 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) { for (int i = 0; i < pim_index.size_s(); ++i) {
f(pim_index[i].key, pim_content[pim_index[i].index]); f(pim_index[i].key, pim_content[pim_index[i].index]);
} }
@@ -465,7 +469,7 @@ private:
template <typename P, typename Key1, typename T1> template <typename P, typename Key1, typename T1>
friend PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIDeque<typename PIMap<Key1, T1>::MapIndex> & v); 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; ssize_t mid;
while (first <= last) { while (first <= last) {
mid = (first + last) / 2; mid = (first + last) / 2;
@@ -477,7 +481,7 @@ private:
return first; 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()) { if (pim_index.isEmpty()) {
found = false; found = false;
return 0; return 0;
@@ -485,7 +489,7 @@ private:
return _binarySearch(0, pim_index.size_s() - 1, k, found); 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; size_t ci = pim_index[index].index, bi = pim_index.size() - 1;
pim_index.remove(index); pim_index.remove(index);
for (size_t i = 0; i < pim_index.size(); ++i) { for (size_t i = 0; i < pim_index.size(); ++i) {
@@ -498,18 +502,18 @@ private:
pim_content.resize(pim_index.size()); 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(); if (index < 0 || index >= pim_index.size_s()) return value_type();
return value_type(pim_index[index].key, pim_content[pim_index[index].index]); 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; PIVector<T> pim_content;
@@ -549,19 +553,19 @@ template <typename Key, typename T>
class PIMapIteratorConst { class PIMapIteratorConst {
typedef PIMap<Key, T> MapType; typedef PIMap<Key, T> MapType;
public: 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. //! \~english Returns current key.
//! \~russian Возвращает ключ текущего элемента. //! \~russian Возвращает ключ текущего элемента.
//! \~\sa \a value() //! \~\sa \a value()
const Key & key() const { inline const Key & key() const {
return m._key(pos); return m._key(pos);
} }
//! \~english Returns current value. //! \~english Returns current value.
//! \~russian Возвращает значение текущего элемента. //! \~russian Возвращает значение текущего элемента.
//! \~\sa \a key() //! \~\sa \a key()
const T & value() const { inline const T & value() const {
return m._value(pos); return m._value(pos);
} }
@@ -625,19 +629,19 @@ template <typename Key, typename T>
class PIMapIteratorConstReverse { class PIMapIteratorConstReverse {
typedef PIMap<Key, T> MapType; typedef PIMap<Key, T> MapType;
public: 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. //! \~english Returns current key.
//! \~russian Возвращает ключ текущего элемента. //! \~russian Возвращает ключ текущего элемента.
//! \~\sa \a value() //! \~\sa \a value()
const Key & key() const { inline const Key & key() const {
return m._key(pos); return m._key(pos);
} }
//! \~english Returns current value. //! \~english Returns current value.
//! \~russian Возвращает значение текущего элемента. //! \~russian Возвращает значение текущего элемента.
//! \~\sa \a key() //! \~\sa \a key()
const T & value() const { inline const T & value() const {
return m._value(pos); return m._value(pos);
} }
@@ -701,19 +705,19 @@ template <typename Key, typename T>
class PIMapIterator { class PIMapIterator {
typedef PIMap<Key, T> MapType; typedef PIMap<Key, T> MapType;
public: public:
PIMapIterator(PIMap<Key, T> & map): m(map), pos(-1) {} inline PIMapIterator(PIMap<Key, T> & map): m(map), pos(-1) {}
//! \~english Returns current key. //! \~english Returns current key.
//! \~russian Возвращает ключ текущего элемента. //! \~russian Возвращает ключ текущего элемента.
//! \~\sa \a value() //! \~\sa \a value()
const Key & key() const { inline const Key & key() const {
return m._key(pos); return m._key(pos);
} }
//! \~english Returns current value. //! \~english Returns current value.
//! \~russian Возвращает значение текущего элемента. //! \~russian Возвращает значение текущего элемента.
//! \~\sa \a key() //! \~\sa \a key()
T & value() { inline T & value() {
return m._value(pos); return m._value(pos);
} }
@@ -777,19 +781,19 @@ template <typename Key, typename T>
class PIMapIteratorReverse { class PIMapIteratorReverse {
typedef PIMap<Key, T> MapType; typedef PIMap<Key, T> MapType;
public: 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. //! \~english Returns current key.
//! \~russian Возвращает ключ текущего элемента. //! \~russian Возвращает ключ текущего элемента.
//! \~\sa \a value() //! \~\sa \a value()
const Key & key() const { inline const Key & key() const {
return m._key(pos); return m._key(pos);
} }
//! \~english Returns current value. //! \~english Returns current value.
//! \~russian Возвращает значение текущего элемента. //! \~russian Возвращает значение текущего элемента.
//! \~\sa \a key() //! \~\sa \a key()
T & value() { inline T & value() {
return m._value(pos); return m._value(pos);
} }

View File

@@ -33,7 +33,6 @@ template<typename T>
class PIQueue: public PIDeque<T> { class PIQueue: public PIDeque<T> {
public: public:
PIQueue() {} PIQueue() {}
virtual ~PIQueue() {}
PIDeque<T> & enqueue(const T & v) {PIDeque<T>::push_front(v); return *this;} 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;} PIDeque<T> & enqueue(T && v) {PIDeque<T>::push_front(std::move(v)); return *this;}
T dequeue() {return PIDeque<T>::take_back();} T dequeue() {return PIDeque<T>::take_back();}

View File

@@ -42,8 +42,6 @@ public:
//! Contructs an empty set //! Contructs an empty set
PISet() {} PISet() {}
virtual ~PISet() {;}
//! Contructs set with one element "value" //! Contructs set with one element "value"
PISet(const T & value) {_CSet::insert(value, 0);} PISet(const T & value) {_CSet::insert(value, 0);}

View File

@@ -30,8 +30,7 @@
template<typename T> template<typename T>
class PIStack: public PIVector<T> { class PIStack: public PIVector<T> {
public: public:
PIStack() {;} PIStack() {}
virtual ~PIStack() {;}
PIVector<T> & push(const T & v) {PIVector<T>::push_back(v); return *this;} 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;} PIVector<T> & push(T && v) {PIVector<T>::push_back(std::move(v)); return *this;}
T pop() {return PIVector<T>::take_back();} T pop() {return PIVector<T>::take_back();}

View File

@@ -196,7 +196,7 @@ public:
v._reset(); v._reset();
} }
inline virtual ~PIVector() { inline ~PIVector() {
PIINTROSPECTION_CONTAINER_DELETE(T) PIINTROSPECTION_CONTAINER_DELETE(T)
PIINTROSPECTION_CONTAINER_FREE(T, (piv_rsize)) PIINTROSPECTION_CONTAINER_FREE(T, (piv_rsize))
deleteT(piv_data, piv_size); deleteT(piv_data, piv_size);

View File

@@ -39,17 +39,21 @@ template <typename T>
class PIVector2D { class PIVector2D {
public: public:
inline PIVector2D() {rows_ = cols_ = 0;} inline PIVector2D() {rows_ = cols_ = 0;}
inline PIVector2D(size_t rows, size_t cols, const T & f = T()) { inline PIVector2D(size_t rows, size_t cols, const T & f = T()) {
rows_ = rows; rows_ = rows;
cols_ = cols; cols_ = cols;
mat.resize(rows*cols, f); mat.resize(rows*cols, f);
} }
inline PIVector2D(size_t rows, size_t cols, const PIVector<T> & v) : rows_(rows), cols_(cols), mat(v) { inline PIVector2D(size_t rows, size_t cols, const PIVector<T> & v) : rows_(rows), cols_(cols), mat(v) {
mat.resize(rows*cols); mat.resize(rows*cols);
} }
inline PIVector2D(size_t rows, size_t cols, PIVector<T> && v) : rows_(rows), cols_(cols), mat(std::move(v)) { inline PIVector2D(size_t rows, size_t cols, PIVector<T> && v) : rows_(rows), cols_(cols), mat(std::move(v)) {
mat.resize(rows*cols); mat.resize(rows*cols);
} }
inline PIVector2D(const PIVector<PIVector<T>> & v) { inline PIVector2D(const PIVector<PIVector<T>> & v) {
rows_ = v.size(); rows_ = v.size();
if (rows_) { if (rows_) {
@@ -64,13 +68,21 @@ public:
} }
inline size_t rows() const {return rows_;} inline size_t rows() const {return rows_;}
inline size_t cols() const {return cols_;} inline size_t cols() const {return cols_;}
inline size_t size() const {return mat.size();} inline size_t size() const {return mat.size();}
inline ssize_t size_s() const {return mat.size_s();} inline ssize_t size_s() const {return mat.size_s();}
inline size_t length() const {return mat.length();} inline size_t length() const {return mat.length();}
inline size_t capacity() const {return mat.capacity();} inline size_t capacity() const {return mat.capacity();}
inline bool isEmpty() const {return mat.isEmpty();} inline bool isEmpty() const {return mat.isEmpty();}
inline bool isNotEmpty() const {return mat.isNotEmpty();}
class Row { class Row {
friend class PIVector2D<T>; friend class PIVector2D<T>;
private: private:
@@ -243,16 +255,19 @@ public:
} }
inline bool operator !=(const PIVector2D<T> & t) const {return !(*this == t);} 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; PIVector<PIVector<T> > ret;
ret.reserve(rows_); ret.reserve(rows_);
for(size_t i = 0; i < rows_; ++i) for(size_t i = 0; i < rows_; ++i)
ret << PIVector<T>(mat.data(i*cols_), cols_); ret << PIVector<T>(mat.data(i*cols_), cols_);
return ret; return ret;
} }
PIVector<T> toPlainVector() const {return mat;}
PIVector<T> & plainVector() {return mat;} inline PIVector<T> toPlainVector() const {return mat;}
const PIVector<T> & plainVector() const {return mat;}
inline PIVector<T> & plainVector() {return mat;}
inline const PIVector<T> & plainVector() const {return mat;}
inline void swap(PIVector2D<T> & other) { inline void swap(PIVector2D<T> & other) {
mat.swap(other.mat); mat.swap(other.mat);
@@ -275,11 +290,16 @@ public:
mat.clear(); 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); mat.forEach(f);
} }
PIVector2D<T> & forEach(std::function<void(T &)> f) { inline PIVector2D<T> & forEach(std::function<void(T &)> f) {
mat.forEach(f); mat.forEach(f);
return *this; return *this;
} }

View File

@@ -39,11 +39,11 @@ extern PIP_EXPORT char * __utf8name__;
class PIP_EXPORT PIChar class PIP_EXPORT PIChar
{ {
friend class PIString; friend class PIString;
friend PICout PIP_EXPORT operator <<(PICout s, const PIChar & v); friend PICout operator <<(PICout s, const PIChar & v);
public: public:
//! \~english Contructs Ascii symbol //! \~english Contructs Ascii symbol
//! \~russian Создает символ Ascii //! \~russian Создает символ Ascii
PIChar(char c) {ch = c; ch &= 0xFF;} PIChar(char c) {ch = c;}
//! \~english Contructs ascii symbol //! \~english Contructs ascii symbol
//! \~russian Создает символ Ascii //! \~russian Создает символ Ascii
@@ -183,7 +183,7 @@ private:
//! \relatesalso PIChar //! \relatesalso PIChar
//! \~english Output operator to \a PICout //! \~english Output operator to \a PICout
//! \~russian Оператор вывода в \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 //! \relatesalso PIChar
//! \~english Compare operator //! \~english Compare operator

View File

@@ -154,21 +154,13 @@ DWORD PICout::__Private__::smode = 0;
#endif #endif
PICout::PICout(int controls): fo_(true), cc_(false), fc_(false), act_(true), cnb_(10), co_(controls) { PICout::PICout(int controls): fo_(true), cc_(false), fc_(false), act_(true), cnb_(10), co_(controls) {
buffer_ = nullptr;
init(); init();
} }
PICout::PICout(bool active): fo_(true), cc_(false), fc_(false), act_(active), cnb_(10), co_(PICoutManipulators::DefaultControls) { PICout::PICout(bool active): fo_(true), cc_(false), fc_(false), act_(active), cnb_(10), co_(PICoutManipulators::DefaultControls) {
buffer_ = nullptr; buffer_ = nullptr;
if (act_) if (act_) init();
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;
} }
@@ -182,14 +174,16 @@ PICout::~PICout() {
if (fc_) applyFormat(PICoutManipulators::Default); if (fc_) applyFormat(PICoutManipulators::Default);
if (cc_) return; if (cc_) return;
newLine(); newLine();
if ((co_ & NoLock) != NoLock) if ((co_ & NoLock) != NoLock) {
PICout::__mutex__().unlock(); PICout::__mutex__().unlock();
if (buffer_) }
if (buffer_) {
((NotifierObject*)Notifier::object())->finished(id_, buffer_); ((NotifierObject*)Notifier::object())->finished(id_, buffer_);
}
} }
PICout PICout::operator <<(const PICoutAction v) { PICout & PICout::operator <<(PICoutAction v) {
if (!act_) return *this; if (!act_) return *this;
#ifdef WINDOWS #ifdef WINDOWS
CONSOLE_SCREEN_BUFFER_INFO sbi; CONSOLE_SCREEN_BUFFER_INFO sbi;
@@ -198,8 +192,9 @@ PICout PICout::operator <<(const PICoutAction v) {
#endif #endif
switch (v) { switch (v) {
case PICoutManipulators::Flush: case PICoutManipulators::Flush:
if (!buffer_ && isOutputDeviceActive(StdOut)) if (!buffer_ && isOutputDeviceActive(StdOut)) {
std::cout << std::flush; std::cout << std::flush;
}
break; break;
case PICoutManipulators::Backspace: case PICoutManipulators::Backspace:
if (isOutputDeviceActive(StdOut)) { 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) { switch (v) {
case PICoutManipulators::Bin: cnb_ = 2; break; case PICoutManipulators::Bin: cnb_ = 2; break;
case PICoutManipulators::Oct: cnb_ = 8; 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::Bin]) cnb_ = 2;
if (v[PICoutManipulators::Oct]) cnb_ = 8; if (v[PICoutManipulators::Oct]) cnb_ = 8;
if (v[PICoutManipulators::Dec]) cnb_ = 10; 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::StdOut)) std::cout << (v);\
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g');\ if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g');\
}\ }\
} }\
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 PIString & v) {
space();
quote();
write(v);
quote();
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 <<(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_) return *this; space(); write(v); 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 uchar v) {PIINTCOUT(ushort(v))} PICout & PICout::operator <<(char v) {
if (!act_) return *this;
space();
write(v);
return *this;
}
PICout PICout::operator <<(const short int v) {PIINTCOUT(v)} PICout & PICout::operator <<(uchar v) {PIINTCOUT(ushort(v))}
PICout PICout::operator <<(const ushort v) {PIINTCOUT(v)} PICout & PICout::operator <<(short int v) {PIINTCOUT(v)}
PICout PICout::operator <<(const int v) {PIINTCOUT(v)} PICout & PICout::operator <<(ushort v) {PIINTCOUT(v)}
PICout PICout::operator <<(const uint v) {PIINTCOUT(v)} PICout & PICout::operator <<(int v) {PIINTCOUT(v)}
PICout PICout::operator <<(const long v) {PIINTCOUT(v)} PICout & PICout::operator <<(uint v) {PIINTCOUT(v)}
PICout PICout::operator <<(const ulong v) {PIINTCOUT(v)} PICout & PICout::operator <<(long v) {PIINTCOUT(v)}
PICout PICout::operator <<(const llong v) {PIINTCOUT(v)} PICout & PICout::operator <<(ulong v) {PIINTCOUT(v)}
PICout PICout::operator <<(const ullong v) {PIINTCOUT(v)} PICout & PICout::operator <<(llong v) {PIINTCOUT(v)}
PICout PICout::operator <<(const float v) {if (!act_) return *this; space(); PIFLOATCOUT(v) return *this;} PICout & PICout::operator <<(ullong v) {PIINTCOUT(v)}
PICout PICout::operator <<(const double v) {if (!act_) return *this; space(); PIFLOATCOUT(v) return *this;} PICout & PICout::operator <<(float v) {if (!act_) return *this; space(); PIFLOATCOUT(v)}
PICout PICout::operator <<(const void * v) {if (!act_) return *this; space(); write("0x" + PIString::fromNumber(ullong(v), 16)); return *this;} PICout & PICout::operator <<(double v) {if (!act_) return *this; space(); PIFLOATCOUT(v)}
PICout PICout::operator <<(const PIObject * v) { PICout & PICout::operator <<(void * v) {
if (!act_) return *this;
space();
write("0x" + PIString::fromNumber(ullong(v), 16));
return *this;
}
PICout & PICout::operator <<(const PIObject * v) {
if (!act_) return *this; if (!act_) return *this;
space(); space();
if (v == 0) write("PIObject*(0x0)"); if (v == 0) write("PIObject*(0x0)");
@@ -382,7 +410,7 @@ PICout PICout::operator <<(const PIObject * v) {
return *this; return *this;
} }
PICout PICout::operator <<(const PICoutSpecialChar v) { PICout & PICout::operator <<(PICoutSpecialChar v) {
if (!act_) return *this; if (!act_) return *this;
switch (v) { switch (v) {
case Null: case Null:
@@ -581,10 +609,10 @@ void PICout::init() {
} }
attr_ = __Private__::dattr; attr_ = __Private__::dattr;
#endif #endif
buffer_ = nullptr;
id_ = 0; id_ = 0;
if ((co_ & NoLock) != NoLock) if ((co_ & NoLock) != NoLock) {
PICout::__mutex__().lock(); PICout::__mutex__().lock();
}
} }
@@ -686,3 +714,11 @@ void PICout::setOutputDevices(PICout::OutputDevices d) {
bool PICout::isOutputDeviceActive(PICout::OutputDevice d) { bool PICout::isOutputDeviceActive(PICout::OutputDevice d) {
return devs[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;
}

View File

@@ -140,10 +140,6 @@ public:
//! \~russian Конструктор по умолчанию (AddSpaces и AddNewLine), но если не \"active\" то будет неактивным //! \~russian Конструктор по умолчанию (AddSpaces и AddNewLine), но если не \"active\" то будет неактивным
PICout(bool 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(const PICout & other);
~PICout(); ~PICout();
@@ -176,86 +172,87 @@ public:
//! \~english Output operator for strings with <tt>"const char * "</tt> type //! \~english Output operator for strings with <tt>"const char * "</tt> type
//! \~russian Оператор вывода для строк <tt>"const char * "</tt> //! \~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 //! \~english Output operator for \a PIString
//PICout operator <<(const std::string & v); //! \~russian Оператор вывода для \a PIString
PICout & operator <<(const PIString & v);
//! \~english Output operator for boolean values //! \~english Output operator for boolean values
//! \~russian Оператор вывода для логических значений //! \~russian Оператор вывода для логических значений
PICout operator <<(const bool v); PICout & operator <<(bool v);
//! \~english Output operator for <tt>"char"</tt> values //! \~english Output operator for <tt>"char"</tt> values
//! \~russian Оператор вывода для <tt>"char"</tt> значений //! \~russian Оператор вывода для <tt>"char"</tt> значений
PICout operator <<(const char v); PICout & operator <<(char v);
//! \~english Output operator for <tt>"unsigned char"</tt> values //! \~english Output operator for <tt>"unsigned char"</tt> values
//! \~russian Оператор вывода для <tt>"unsigned char"</tt> значений //! \~russian Оператор вывода для <tt>"unsigned char"</tt> значений
PICout operator <<(const uchar v); PICout & operator <<(uchar v);
//! \~english Output operator for <tt>"short"</tt> values //! \~english Output operator for <tt>"short"</tt> values
//! \~russian Оператор вывода для <tt>"short"</tt> значений //! \~russian Оператор вывода для <tt>"short"</tt> значений
PICout operator <<(const short v); PICout & operator <<(short v);
//! \~english Output operator for <tt>"unsigned short"</tt> values //! \~english Output operator for <tt>"unsigned short"</tt> values
//! \~russian Оператор вывода для <tt>"unsigned short"</tt> значений //! \~russian Оператор вывода для <tt>"unsigned short"</tt> значений
PICout operator <<(const ushort v); PICout & operator <<(ushort v);
//! \~english Output operator for <tt>"int"</tt> values //! \~english Output operator for <tt>"int"</tt> values
//! \~russian Оператор вывода для <tt>"int"</tt> значений //! \~russian Оператор вывода для <tt>"int"</tt> значений
PICout operator <<(const int v); PICout & operator <<(int v);
//! \~english Output operator for <tt>"unsigned int"</tt> values //! \~english Output operator for <tt>"unsigned int"</tt> values
//! \~russian Оператор вывода для <tt>"unsigned int"</tt> значений //! \~russian Оператор вывода для <tt>"unsigned int"</tt> значений
PICout operator <<(const uint v); PICout & operator <<(uint v);
//! \~english Output operator for <tt>"long"</tt> values //! \~english Output operator for <tt>"long"</tt> values
//! \~russian Оператор вывода для <tt>"long"</tt> значений //! \~russian Оператор вывода для <tt>"long"</tt> значений
PICout operator <<(const long v); PICout & operator <<(long v);
//! \~english Output operator for <tt>"unsigned long"</tt> values //! \~english Output operator for <tt>"unsigned long"</tt> values
//! \~russian Оператор вывода для <tt>"unsigned long"</tt> значений //! \~russian Оператор вывода для <tt>"unsigned long"</tt> значений
PICout operator <<(const ulong v); PICout & operator <<(ulong v);
//! \~english Output operator for <tt>"long long"</tt> values //! \~english Output operator for <tt>"long long"</tt> values
//! \~russian Оператор вывода для <tt>"long long"</tt> значений //! \~russian Оператор вывода для <tt>"long long"</tt> значений
PICout operator <<(const llong v); PICout & operator <<(llong v);
//! \~english Output operator for <tt>"unsigned long long"</tt> values //! \~english Output operator for <tt>"unsigned long long"</tt> values
//! \~russian Оператор вывода для <tt>"unsigned long long"</tt> значений //! \~russian Оператор вывода для <tt>"unsigned long long"</tt> значений
PICout operator <<(const ullong v); PICout & operator <<(ullong v);
//! \~english Output operator for <tt>"float"</tt> values //! \~english Output operator for <tt>"float"</tt> values
//! \~russian Оператор вывода для <tt>"float"</tt> значений //! \~russian Оператор вывода для <tt>"float"</tt> значений
PICout operator <<(const float v); PICout & operator <<(float v);
//! \~english Output operator for <tt>"double"</tt> values //! \~english Output operator for <tt>"double"</tt> values
//! \~russian Оператор вывода для <tt>"double"</tt> значений //! \~russian Оператор вывода для <tt>"double"</tt> значений
PICout operator <<(const double v); PICout & operator <<(double v);
//! \~english Output operator for pointers //! \~english Output operator for pointers
//! \~russian Оператор вывода для указателей //! \~russian Оператор вывода для указателей
PICout operator <<(const void * v); PICout & operator <<(void * v);
//! \~english Output operator for PIObject and ancestors //! \~english Output operator for PIObject and ancestors
//! \~russian Оператор вывода для PIObject и наследников //! \~russian Оператор вывода для PIObject и наследников
PICout operator <<(const PIObject * v); PICout & operator <<(const PIObject * v);
//! \~english Output operator for \a PICoutSpecialChar values //! \~english Output operator for \a PICoutSpecialChar values
//! \~russian Оператор вывода для \a PICoutSpecialChar //! \~russian Оператор вывода для \a PICoutSpecialChar
PICout operator <<(const PICoutManipulators::PICoutSpecialChar v); PICout & operator <<(PICoutManipulators::PICoutSpecialChar v);
//! \~english Output operator for \a PIFlags<PICoutFormat> values //! \~english Output operator for \a PIFlags<PICoutFormat> values
//! \~russian Оператор вывода для \a PIFlags<PICoutFormat> //! \~russian Оператор вывода для \a PIFlags<PICoutFormat>
PICout operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v); PICout & operator <<(PIFlags<PICoutManipulators::PICoutFormat> v);
//! \~english Output operator for \a PICoutFormat values //! \~english Output operator for \a PICoutFormat values
//! \~russian Оператор вывода для \a PICoutFormat //! \~russian Оператор вывода для \a PICoutFormat
PICout operator <<(const PICoutManipulators::PICoutFormat v); PICout & operator <<(PICoutManipulators::PICoutFormat v);
//! \~english Do some action //! \~english Do some action
//! \~russian Делает действие //! \~russian Делает действие
PICout operator <<(const PICoutManipulators::PICoutAction v); PICout & operator <<(PICoutManipulators::PICoutAction v);
//! \~english Set control flag "c" is "on" state //! \~english Set control flag "c" is "on" state
//! \~russian Установить флаг "c" в "on" состояние //! \~russian Установить флаг "c" в "on" состояние
@@ -348,6 +345,11 @@ public:
//! \~russian Возвращает активно ли устройство вывода "d" //! \~russian Возвращает активно ли устройство вывода "d"
static bool isOutputDeviceActive(OutputDevice 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 PIMutex & __mutex__();
static PIString & __string__(); static PIString & __string__();

View File

@@ -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() { PIString::~PIString() {
deleteData(); deleteData();
} }
@@ -1685,11 +1691,3 @@ PIString versionNormalize(const PIString & v) {
return ret; return ret;
} }
PICout operator <<(PICout s, const PIString & v) {
s.space();
s.quote();
s.write(v);
s.quote();
return s;
}

View File

@@ -73,7 +73,7 @@ public:
PIString & operator +=(const char c) {d.push_back(PIChar(c)); return *this;} PIString & operator +=(const char c) {d.push_back(PIChar(c)); return *this;}
PIString & operator +=(const char * str); PIString & operator +=(const char * str);
PIString & operator +=(const wchar_t * 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 PIString & str);
PIString & operator +=(const PIConstChars & str); PIString & operator +=(const PIConstChars & str);
@@ -107,11 +107,11 @@ public:
//! \~english Contructs string with single character "c". //! \~english Contructs string with single character "c".
//! \~russian Создает строку из одного символа "c". //! \~russian Создает строку из одного символа "c".
PIString(const PIChar c) {*this += c;} PIString(const PIChar c) {d.push_back(c);}
//! \~english Contructs string with single character "c". //! \~english Contructs string with single character "c".
//! \~russian Создает строку из одного символа "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). //! \~english Contructs string from C-string "str" (system codepage).
//! \~russian Создает строку из C-строки "str" (кодировка системы). //! \~russian Создает строку из C-строки "str" (кодировка системы).
@@ -1517,12 +1517,6 @@ private:
mutable char * data_ = nullptr; 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 //! \relatesalso PIBinaryStream
//! \~english Store operator. //! \~english Store operator.
//! \~russian Оператор сохранения. //! \~russian Оператор сохранения.
@@ -1548,11 +1542,11 @@ inline PIString operator +(const char * str, const PIString & f) {return PIStrin
//! \~english Returns concatenated string. //! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк. //! \~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. //! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк. //! \~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 //! \relatesalso PIString

View File

@@ -22,8 +22,7 @@
const char PIFileTransfer::sign[] = {'P', 'F', 'T'}; const char PIFileTransfer::sign[] = {'P', 'F', 'T'};
PIFileTransfer::PIFileTransfer() { PIFileTransfer::PIFileTransfer() {
for (uint i = 0; i < sizeof(sign); i++) for (uint i = 0; i < sizeof(sign); i++) pftheader.sig[i] = sign[i];
pftheader.sig[i] = sign[i];
pftheader.version = __PIFILETRANSFER_VERSION; pftheader.version = __PIFILETRANSFER_VERSION;
pftheader.session_id = 0; pftheader.session_id = 0;
pftheader.step = pft_None; pftheader.step = pft_None;

View File

@@ -238,7 +238,15 @@ inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<
} }
template<uint Size, typename Type> 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; typedef PIMathVectorT<2u, int> PIMathVectorT2i;
@@ -510,7 +518,15 @@ inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v
#endif #endif
template<typename Type> 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> template <typename P, typename T>
inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathVector<T> & v) {s << v.c; return s;} inline PIBinaryStream<P> & operator <<(PIBinaryStream<P> & s, const PIMathVector<T> & v) {s << v.c; return s;}

View File

@@ -5,19 +5,9 @@
using namespace PICoutManipulators; using namespace PICoutManipulators;
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
float a_read[10], a_write[10]; //PIMap<int, PIString> v{{1, "xdsa"},{2, "blya"},{3, "\n"}};
for (int i = 0; i < 10; ++i) { PIVector<int> x{1,2};
a_read [i] = 0.f; piCout << 1 << 2;
a_write[i] = i / 10.f; piCout << 1 << 2;
} return 0;
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];
} }