PICout fix

This commit is contained in:
Бычков Андрей
2022-07-29 18:16:42 +03:00
parent 4725eb96d6
commit ddba8f401b
2 changed files with 8 additions and 13 deletions

View File

@@ -85,7 +85,7 @@ public:
const PIMap<Key, T> * parent; const PIMap<Key, T> * parent;
ssize_t pos; ssize_t pos;
public: public:
iterator(): parent(0), pos(0) {} iterator(): parent(nullptr), pos(0) {}
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);} const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
T & value() {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);} T & value() {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
inline PIPair<Key, T> operator *() const {return PIPair<Key, T>(const_cast<PIMap<Key, T> * >(parent)->_key(pos), const_cast<PIMap<Key, T> * >(parent)->_value(pos));} inline PIPair<Key, T> operator *() const {return PIPair<Key, T>(const_cast<PIMap<Key, T> * >(parent)->_key(pos), const_cast<PIMap<Key, T> * >(parent)->_value(pos));}
@@ -104,7 +104,7 @@ public:
const PIMap<Key, T> * parent; const PIMap<Key, T> * parent;
ssize_t pos; ssize_t pos;
public: public:
reverse_iterator(): parent(0), pos(0) {} reverse_iterator(): parent(nullptr), pos(0) {}
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);} const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);} T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
inline PIPair<Key, T> operator *() const {return PIPair<Key, T>(const_cast<PIMap<Key, T> * >(parent)->_key(pos), const_cast<PIMap<Key, T> * >(parent)->_value(pos));} inline PIPair<Key, T> operator *() const {return PIPair<Key, T>(const_cast<PIMap<Key, T> * >(parent)->_key(pos), const_cast<PIMap<Key, T> * >(parent)->_value(pos));}
@@ -123,9 +123,8 @@ public:
const PIMap<Key, T> * parent; const PIMap<Key, T> * parent;
ssize_t pos; ssize_t pos;
public: public:
const_iterator(): parent(0), pos(0) {} const_iterator(): parent(nullptr), pos(0) {}
const value_type operator *() const {return parent->_pair(pos);} const value_type operator *() const {return parent->_pair(pos);}
//const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);} const Key & key() const {return const_cast<PIMap<Key, T> * >(parent)->_key(pos);}
const T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);} const T & value() const {return const_cast<PIMap<Key, T> * >(parent)->_value(pos);}
void operator ++() {++pos;} void operator ++() {++pos;}
@@ -134,7 +133,6 @@ public:
void operator --(int) {--pos;} void operator --(int) {--pos;}
bool operator ==(const const_iterator & it) const {return (pos == it.pos);} bool operator ==(const const_iterator & it) const {return (pos == it.pos);}
bool operator !=(const const_iterator & it) const {return (pos != it.pos);} bool operator !=(const const_iterator & it) const {return (pos != it.pos);}
//mutable value_type cval;
}; };
class const_reverse_iterator { class const_reverse_iterator {
@@ -144,16 +142,14 @@ public:
const PIMap<Key, T> * parent; const PIMap<Key, T> * parent;
ssize_t pos; ssize_t pos;
public: public:
const_reverse_iterator(): parent(0), pos(0) {} const_reverse_iterator(): parent(nullptr), pos(0) {}
const value_type operator *() const {return parent->_pair(pos);} const value_type operator *() const {return parent->_pair(pos);}
//const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;}
void operator ++() {--pos;} void operator ++() {--pos;}
void operator ++(int) {--pos;} void operator ++(int) {--pos;}
void operator --() {++pos;} void operator --() {++pos;}
void operator --(int) {++pos;} void operator --(int) {++pos;}
bool operator ==(const const_reverse_iterator & it) const {return (pos == it.pos);} bool operator ==(const const_reverse_iterator & it) const {return (pos == it.pos);}
bool operator !=(const const_reverse_iterator & it) const {return (pos != it.pos);} bool operator !=(const const_reverse_iterator & it) const {return (pos != it.pos);}
//mutable value_type cval;
}; };
iterator begin() {return iterator(this, 0);} iterator begin() {return iterator(this, 0);}
@@ -198,8 +194,9 @@ public:
if (other.isEmpty()) return *this; if (other.isEmpty()) return *this;
if (other.size() == 1) {insert(other.pim_index[0].key, other.pim_content[0]); return *this;} if (other.size() == 1) {insert(other.pim_index[0].key, other.pim_content[0]); return *this;}
if (other.size() == 2) {insert(other.pim_index[0].key, other.pim_content[0]); insert(other.pim_index[1].key, other.pim_content[1]); return *this;} if (other.size() == 2) {insert(other.pim_index[0].key, other.pim_content[0]); insert(other.pim_index[1].key, other.pim_content[1]); return *this;}
for (int i = 0; i < other.pim_index.size_s(); ++i) for (int i = 0; i < other.pim_index.size_s(); ++i) {
insert(other.pim_index[i].key, other.pim_content[other.pim_index[i].index]); insert(other.pim_index[i].key, other.pim_content[other.pim_index[i].index]);
}
return *this; return *this;
} }

View File

@@ -330,8 +330,7 @@ PICout PICout::operator <<(const PIFlags<PICoutManipulators::PICoutFormat> & v)
#define PINUMERICCOUT(v) { \ #define PINUMERICCOUT(v) { \
if (!act_) return *this; \ if (!act_) return *this; \
space(); \ space(); \
if (cnb_ == 10) PICOUTTOTARGET(v) \ write(PIString::fromNumber(v, cnb_)); \
else write(PIString::fromNumber(v, cnb_)); \
return *this; \ return *this; \
} }
@@ -543,8 +542,7 @@ PICout & PICout::write(const PIString & s) {
if (buffer_) { if (buffer_) {
buffer_->append(s); buffer_->append(s);
} else { } else {
if (PICout::isOutputDeviceActive(PICout::StdOut)) if (PICout::isOutputDeviceActive(PICout::StdOut)) stdoutPIString(s);
stdoutPIString(s);
if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__().append(s); if (PICout::isOutputDeviceActive(PICout::Buffer)) PICout::__string__().append(s);
} }
return *this; return *this;