cpp11 branch merged back to to trunk

git-svn-id: svn://ultimatepp.org/upp/trunk@7047 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-03-16 16:33:48 +00:00
parent 3f6132b553
commit 51687976c2
155 changed files with 1887 additions and 1038 deletions

View file

@ -213,8 +213,8 @@ void CodeEditor::CopyWord() {
if(iscidl(GetChar(p)) || (p > 0 && iscidl(GetChar(--p)))) {
int e = GetLength();
int f = p;
while(--p >= 0 && iscidl(GetChar(p)));
++p;
while(--p >= 0 && iscidl(GetChar(p))) {}
++p;
while(++f < e && iscidl(GetChar(f)));
WString txt = GetW(p, f - p);
WriteClipboardUnicodeText(txt);

View file

@ -70,7 +70,6 @@ private:
Vector<LnInfo> li;
LineInfoRem li_removed;
int sy;
CodeEditor *editor;
int ptrline[2];
Image ptrimg[2];
@ -114,7 +113,7 @@ public:
LineInfo GetLineInfo() const;
void SetLineInfo(const LineInfo& li, int total);
LineInfoRem & GetLineInfoRem() { return li_removed; }
void SetLineInfoRem(pick_ LineInfoRem& li) { li_removed = li; }
void SetLineInfoRem(LineInfoRem pick_ li) { li_removed = pick(li); }
void SetAnnotation(int line, const Image& img, const String& ann);
String GetAnnotation(int line) const;
@ -492,7 +491,7 @@ public:
LineInfo GetLineInfo() const { return bar.GetLineInfo(); }
void SetLineInfo(const LineInfo& lf);
LineInfoRem GetLineInfoRem() { return LineInfoRem(bar.GetLineInfoRem(), 0); }
void SetLineInfoRem(pick_ LineInfoRem& lf) { bar.SetLineInfoRem(LineInfoRem(lf, 0)); }
void SetLineInfoRem(LineInfoRem pick_ lf) { bar.SetLineInfoRem(LineInfoRem(lf, 0)); }
double GetStatEditTime() const { return stat_edit_time; }
void Renumber() { bar.Renumber(GetLineCount()); }
void ClearBreakpoints() { bar.ClearBreakpoints(); }

View file

@ -32,7 +32,7 @@ void Renumber(LineInfo& lf)
}
l += r.count;
}
lf = tf;
lf = pick(tf);
}
void ClearBreakpoints(LineInfo& lf)
@ -130,7 +130,7 @@ void EditorBar::Paint(Draw& w)
}
}
}
previf = nextif;
previf = pick(nextif);
}
if(editor->GetMarkLines()) {
int width = CodeEditorImg::Breakpoint().GetWidth() >> 1;

View file

@ -307,6 +307,7 @@ void CodeEditor::InitKeywords()
"byte", "word", "dword", "__countof", "pick_", "wchar", "NULL", "Null",
"int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", "qword",
"INTERLOCKED_", "INTERLOCKED", "ONCELOCK", "ONCELOCK_", "INITBLOCK", "EXITBLOCK",
"rval_", "rval_default",
NULL
};
static const char *usc[] = {

View file

@ -1547,7 +1547,7 @@ void SortByKey(Map& map, const Less& less)
typename Map::KeyContainer k = map.PickKeys();
typename Map::ValueContainer v = map.PickValues();
IndexSort(k, v, less);
map = Map(k, v);
map = Map(pick(k), pick(v));
}
template <class Map>
@ -1562,7 +1562,7 @@ void SortByValue(Map& map, const Less& less)
typename Map::KeyContainer k = map.PickKeys();
typename Map::ValueContainer v = map.PickValues();
IndexSort(v, k, less);
map = Map(k, v);
map = Map(pick(k), pick(v));
}
template <class Map>
@ -1577,7 +1577,7 @@ void StableSortByKey(Map& map, const Less& less)
typename Map::KeyContainer k = map.PickKeys();
typename Map::ValueContainer v = map.PickValues();
StableIndexSort(k, v, less);
map = Map(k, v);
map = Map(pick(k), pick(v));
}
template <class Map>
@ -1592,7 +1592,7 @@ void StableSortByValue(Map& map, const Less& less)
typename Map::KeyContainer k = map.PickKeys();
typename Map::ValueContainer v = map.PickValues();
StableIndexSort(v, k, less);
map = Map(k, v);
map = Map(pick(k), pick(v));
}
template <class Map>
@ -1601,13 +1601,12 @@ void StableSortByValue(Map& map)
StableSortByValue(map, StdLess<typename Map::ValueType>());
}
template <class Index, class Less>
void SortIndex(Index& index, const Less& less)
{
typename Index::ValueContainer k = index.PickKeys();
Sort(k, less);
index = Index(k);
index = Index(pick(k));
}
template <class Index>
@ -1621,7 +1620,7 @@ void StableSortIndex(Index& index, const Less& less)
{
typename Index::ValueContainer k = index.PickKeys();
StableSort(k, less);
index = Index(k);
index = Index(pick(k));
}
template <class Index>

View file

@ -15,8 +15,8 @@ protected:
T *AddHead0() { AssertMoveable<T>(); Add0(); return &vector[start = Ix(alloc - 1)/*(start + alloc - 1) % alloc*/]; }
T *AddTail0() { AssertMoveable<T>(); Add0(); return &vector[EI()]; }
void Free();
void Pick(pick_ BiVector& x) { vector = x.vector; start = x.start; items = x.items;
alloc = x.alloc; ((BiVector&)x).items = -1; }
void Pick(BiVector rval_ x) { vector = pick(x.vector); start = x.start; items = x.items;
alloc = x.alloc; ((BiVector&)x).items = -1; }
void Copy(T *dst, int start, int count) const;
public:
@ -28,8 +28,8 @@ public:
T& AddTail() { return *new(AddTail0()) T; }
void AddHead(const T& x) { new(AddHead0()) T(x); }
void AddTail(const T& x) { new(AddTail0()) T(x); }
void AddHeadPick(pick_ T& x) { new(AddHead0()) T(x); }
void AddTailPick(pick_ T& x) { new(AddTail0()) T(x); }
void AddHeadPick(T rval_ x) { new(AddHead0()) T(x); }
void AddTailPick(T rval_ x) { new(AddTail0()) T(x); }
T& Head() { ASSERT(items > 0); return vector[start]; }
T& Tail() { ASSERT(items > 0); return vector[EI()]; }
const T& Head() const { ASSERT(items > 0); return vector[start]; }
@ -46,13 +46,21 @@ public:
#ifdef UPP
void Serialize(Stream& s);
String ToString() const;
bool operator==(const BiVector<T>& b) const { return IsEqualArray(*this, b); }
bool operator!=(const BiVector<T>& b) const { return !operator==(b); }
int Compare(const BiVector<T>& b) const { return CompareArray(*this, b); }
bool operator<=(const BiVector<T>& x) const { return Compare(x) <= 0; }
bool operator>=(const BiVector<T>& x) const { return Compare(x) >= 0; }
bool operator<(const BiVector<T>& x) const { return Compare(x) < 0; }
bool operator>(const BiVector<T>& x) const { return Compare(x) > 0; }
#endif
bool IsPicked() const { return items < 0; }
BiVector(const BiVector& src, int) { DeepCopy0(src); }
BiVector(pick_ BiVector& src) { Pick(src); }
void operator=(pick_ BiVector& src) { Free(); Pick(src); }
BiVector(BiVector rval_ src) { Pick(pick(src)); }
void operator=(BiVector rval_ src) { Free(); Pick(pick(src)); }
BiVector() { start = items = alloc = 0; vector = NULL; }
~BiVector() { Free(); } // gcc4.0 workaround!!
@ -93,8 +101,8 @@ public:
T& AddTail() { T *q = new T; bv.AddTail(q); return *q; }
void AddHead(const T& x) { bv.AddHead(DeepCopyNew(x)); }
void AddTail(const T& x) { bv.AddTail(DeepCopyNew(x)); }
void AddHeadPick(pick_ T& x) { bv.AddHead(new T(x)); }
void AddTailPick(pick_ T& x) { bv.AddTail(new T(x)); }
void AddHeadPick(T rval_ x) { bv.AddHead(new T(x)); }
void AddTailPick(T rval_ x) { bv.AddTail(new T(x)); }
T& AddHead(T *newt) { bv.AddHead(newt); return *newt; }
T& AddTail(T *newt) { bv.AddTail(newt); return *newt; }
template <class TT> TT& CreateHead() { TT *q = new TT; bv.AddHead(q); return *q; }
@ -117,14 +125,22 @@ public:
#ifdef UPP
void Serialize(Stream& s);
String ToString() const;
bool operator==(const BiArray<T>& b) const { return IsEqualArray(*this, b); }
bool operator!=(const BiArray<T>& b) const { return !operator==(b); }
int Compare(const BiArray<T>& b) const { return CompareArray(*this, b); }
bool operator<=(const BiArray<T>& x) const { return Compare(x) <= 0; }
bool operator>=(const BiArray<T>& x) const { return Compare(x) >= 0; }
bool operator<(const BiArray<T>& x) const { return Compare(x) < 0; }
bool operator>(const BiArray<T>& x) const { return Compare(x) > 0; }
#endif
bool IsPicked() const { return bv.IsPicked(); }
BiArray(const BiArray& v, int) { DeepCopy0(v); }
BiArray(pick_ BiArray& src) : bv(src.bv) {}
void operator=(pick_ BiArray& src) { Free(); bv = src.bv; }
BiArray(BiArray rval_ src) : bv(pick(src.bv)) {}
void operator=(BiArray rval_ src) { Free(); bv = pick(src.bv); }
BiArray() {}
~BiArray() { Free(); }

View file

@ -18,6 +18,8 @@ struct Complex : std::complex<double>
bool operator==(const Complex& c) const { return (const C&)(*this) == (const C&)c; }
bool operator!=(const Complex& c) const { return (const C&)(*this) != (const C&)c; }
int Compare(const Complex& c) const { NEVER(); return 0; }
void Serialize(Stream& s);
void Xmlize(XmlIO& xio);
void Jsonize(JsonIO& jio);
@ -32,9 +34,16 @@ template<> inline dword ValueTypeNo(const Complex*) { return COMPLEX_V; }
inline const Complex& Nvl(const Complex& a, const Complex& b) { return IsNull(a) ? b : a; }
template<>
inline bool IsPolyEqual(const Complex& x, const Value& v) {
return IsNumber(v) && x.imag() == 0 && x.real() == (double)v;
}
template<>
inline int PolyCompare(const Complex& a, const Value& b)
{
NEVER(); return 0;
}
VALUE_COMPARE(Complex)
NTL_MOVEABLE(Complex)

View file

@ -332,6 +332,7 @@ class JsonIO;
#include "Vcont.hpp"
#include "Map.hpp"
#include "InVector.hpp"
#include "InMap.hpp"
#if (defined(HEAPDBG) || defined(TESTLEAKS)) && defined(PLATFORM_POSIX)
extern int sMemDiagInitCount;

View file

@ -91,6 +91,7 @@ file
Hash.cpp optimize_speed,
InVector.h,
InVector.hpp,
InMap.hpp,
Tuple.h,
Other.h,
Concretes readonly separator,

View file

@ -378,10 +378,36 @@ inline bool IsFin(double d) { return !IsNaN(d) && !IsInf(d); }
#define OFFSETOF(clss, mbr) ((int)(uintptr_t)&(((clss *)1)->mbr) - 1)
template <typename T>
T clone(const T& x) { T c(x, 1); return c; }
#ifdef CPP_11
#define pick_
#define rval_ &&
#define rval_default(T) T(T&&) = default; T& operator=(T&&) = default;
template <typename T>
T&& pick(T& x) { return static_cast<T&&>(x); }
#else
template <class T>
T& pick(T& x) { return x; }
#ifdef COMPILER_MSC
#define pick_
#define rval_ &
#else
#define pick_ const
#define rval_ const &
#endif
#define rval_default(T)
template <typename T>
T& pick(const T& x) { return const_cast<T&>(x); }
#endif
#define init_
@ -566,7 +592,7 @@ int CPU_Cores();
bool IsDecentMachine();
template <class T>
inline void Swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
inline void Swap(T& a, T& b) { T tmp = pick(a); a = pick(b); b = pick(tmp); }
#if defined(CPU_UNALIGNED) && defined(CPU_LE)
inline int Peek16le(const void *ptr) { return *(const word *)ptr; }

View file

@ -6,7 +6,7 @@ protected:
public:
T& Add(const K& k, const T& x) { key.Add(k); return value.Add(x); }
T& AddPick(const K& k, pick_ T& x) { key.Add(k); return value.AddPick(x); }
T& AddPick(const K& k, T rval_ x) { key.Add(k); return value.AddPick(x); }
T& Add(const K& k) { key.Add(k); return value.Add(); }
void Finish() { IndexSort(key, value, Less()); Shrink(); }
@ -36,16 +36,17 @@ public:
void Serialize(Stream& s);
void Xmlize(XmlIO& xio);
void Jsonize(JsonIO& jio);
String ToString() const;
#endif
void Swap(FixedAMap& x) { UPP::Swap(value, x.value); UPP::Swap(key, x.key); }
const Vector<K>& GetKeys() const { return key; }
Vector<K> PickKeys() pick_ { return key; }
Vector<K> PickKeys() { return pick(key); }
const V& GetValues() const { return value; }
V& GetValues() { return value; }
V PickValues() pick_ { return value; }
V PickValues() { return pick(value); }
bool IsPicked() const { return value.IsPicked() || key.IsPicked(); }
@ -53,7 +54,7 @@ public:
FixedAMap() {}
FixedAMap(const FixedAMap& s, int) : key(s.key, 0), value(s.value, 0) {}
FixedAMap(pick_ Vector<K>& key, pick_ V& val) : key(key), value(val) {}
FixedAMap(Vector<K> rval_ key, V rval_ val) : key(key), value(val) {}
typedef Vector<K> KeyContainer;
typedef K KeyType;
@ -82,7 +83,7 @@ class FixedVectorMap : public MoveableAndDeepCopyOption<FixedVectorMap<K, T, Les
typedef FixedAMap< K, T, Vector<T>, Less > B;
public:
FixedVectorMap(const FixedVectorMap& s, int) : FixedAMap<K, T, Vector<T>, Less>(s, 1) {}
FixedVectorMap(pick_ Vector<K>& key, pick_ Vector<T>& val) : FixedAMap<K, T, Vector<T>, Less>(key, val) {}
FixedVectorMap(Vector<K> rval_ key, Vector<T> rval_ val) : FixedAMap<K, T, Vector<T>, Less>(key, val) {}
FixedVectorMap() {}
friend void Swap(FixedVectorMap& a, FixedVectorMap& b) { a.B::Swap(b); }
@ -103,7 +104,7 @@ public:
template <class TT> TT& Create(const K& k) { TT *q = new TT; B::key.Add(k); return static_cast<TT&>(B::value.Add(q)); }
FixedArrayMap(const FixedArrayMap& s, int) : FixedAMap<K, T, Array<T>, Less>(s, 1) {}
FixedArrayMap(pick_ Vector<K>& ndx, pick_ Array<T>& val) : FixedAMap<K, T, Array<T>, Less>(ndx, val) {}
FixedArrayMap(Vector<K> rval_ ndx, Array<T> rval_ val) : FixedAMap<K, T, Array<T>, Less>(ndx, val) {}
FixedArrayMap() {}
friend void Swap(FixedArrayMap& a, FixedArrayMap& b) { a.B::Swap(b); }

View file

@ -81,6 +81,9 @@ struct Size_ : Moveable< Size_<T> > {
void Jsonize(JsonIO& jio) { jio("cx", cx)("cy", cy); }
void Xmlize(XmlIO& xio) { xio.Attr("cx", cx).Attr("cy", cy); }
int Compare(const Size_&) const { NEVER(); return 0; }
int PolyCompare(const Value&) const { NEVER(); return 0; }
#ifdef PLATFORM_WIN32
operator SIZE*() { ASSERT(sizeof(*this) == sizeof(SIZE)); return (SIZE*)this; }
operator const SIZE*() const { ASSERT(sizeof(*this) == sizeof(SIZE)); return (SIZE*)this; }
@ -187,6 +190,9 @@ struct Point_ : Moveable< Point_<T> > {
void Jsonize(JsonIO& jio) { jio("x", x)("y", y); }
void Xmlize(XmlIO& xio) { xio.Attr("x", x).Attr("y", y); }
int Compare(const Point_&) const { NEVER(); return 0; }
int PolyCompare(const Value&) const { NEVER(); return 0; }
#ifdef PLATFORM_WIN32
operator POINT*() { ASSERT(sizeof(*this) == sizeof(POINT)); return (POINT*)this; }
operator const POINT*() const { ASSERT(sizeof(*this) == sizeof(POINT)); return (POINT*)this; }
@ -370,6 +376,9 @@ struct Rect_ : Moveable< Rect_<T> > {
void Jsonize(JsonIO& jio) { jio("left", left)("top", top)("right", right)("bottom", bottom); }
void Xmlize(XmlIO& xio) { xio.Attr("left", left).Attr("top", top).Attr("right", right).Attr("bottom", bottom); }
int Compare(const Rect_&) const { NEVER(); return 0; }
int PolyCompare(const Value&) const { NEVER(); return 0; }
#ifdef PLATFORM_WIN32
operator const RECT*() const { ASSERT(sizeof(*this) == sizeof(RECT)); return (RECT*)this; }
operator RECT*() { ASSERT(sizeof(*this) == sizeof(RECT)); return (RECT*)this; }

View file

@ -57,9 +57,9 @@ HashBase::HashBase()
mcount = 0;
}
HashBase::HashBase(pick_ HashBase& b)
: hash(b.hash),
link(b.link)
HashBase::HashBase(HashBase rval_ b)
: hash(pick(b.hash)),
link(pick(b.link))
{
map = b.map;
mcount = b.mcount;
@ -67,10 +67,10 @@ HashBase::HashBase(pick_ HashBase& b)
const_cast<HashBase &>(b).map = NULL;
}
void HashBase::operator=(pick_ HashBase& b)
void HashBase::operator=(HashBase rval_ b)
{
hash = b.hash;
link = b.link;
hash = pick(b.hash);
link = pick(b.link);
Free();
map = b.map;
mcount = b.mcount;

View file

@ -1,6 +1,3 @@
template <class K, class T, class Less, class Data>
class SortedAMap;
template <class T> struct Slaved_InVector__;
template <class T> struct Slaved_InArray__;
@ -15,7 +12,6 @@ struct InVectorSlave__ {
virtual void RemoveBlk(int blki, int n) = 0;
virtual void Index(int blki, int n) = 0;
virtual void Reindex() = 0;
// virtual void Serialize(Stream& s) = 0;
virtual void Shrink() = 0;
};
@ -25,7 +21,8 @@ public:
class ConstIterator;
class Iterator;
template <class K, class TT, class Less, class Data> friend class SortedAMap;
template <class K, class TT, class Lss, class Data> friend class SortedAMap;
template <class K, class TT, class Less> friend class SortedVectorMap;
template <class TT> friend struct Slaved_InVector__;
template <class TT> friend struct Slaved_InArray__;
@ -71,7 +68,7 @@ private:
void SetBegin(ConstIterator& it) const;
void SetEnd(ConstIterator& it) const;
void Chk() const { ASSERT_(!IsPicked(), "Broken pick semantics"); }
void Chk() const { ASSERT_(!IsPicked(), "Broken rval_ semantics"); }
#ifdef flagIVTEST
void Check(int blki, int offset) const;
@ -148,6 +145,14 @@ public:
void Serialize(Stream& s) { StreamContainer(s, *this); }
void Xmlize(XmlIO& xio, const char *itemtag = "item");
void Jsonize(JsonIO& jio);
String ToString() const;
bool operator==(const InVector<T>& b) const { return IsEqualArray(*this, b); }
bool operator!=(const InVector<T>& b) const { return !operator==(b); }
int Compare(const InVector<T>& b) const { return CompareArray(*this, b); }
bool operator<=(const InVector<T>& x) const { return Compare(x) <= 0; }
bool operator>=(const InVector<T>& x) const { return Compare(x) >= 0; }
bool operator<(const InVector<T>& x) const { return Compare(x) < 0; }
bool operator>(const InVector<T>& x) const { return Compare(x) > 0; }
#endif
friend void Swap(InVector& a, InVector& b) { a.Swap(b); }
@ -236,7 +241,7 @@ public:
template <class T>
class InArray : public MoveableAndDeepCopyOption< InVector<T> > {
template <class K, class TT, class Less, class Data> friend class SortedAMap;
// template <class K, class TT, class Less, class Data> friend class SortedAMap;
template <class TT> friend struct Slaved_InArray__;
public:
@ -347,15 +352,26 @@ public:
bool IsPicked() const { return iv.IsPicked(); }
InArray() {}
InArray(InArray rval_ v) : iv(pick(v.iv)) {}
InArray& operator=(InArray rval_ v) { Free(); iv.operator=(pick(v.iv)); return *this; }
InArray(const InArray& v, int);
~InArray() { Free(); }
void Swap(InArray& b) { iv.Swap(b.iv); }
#ifdef UPP
void Serialize(Stream& s) { StreamContainer(s, *this); }
void Serialize(Stream& s) { StreamContainer(s, *this); }
void Xmlize(XmlIO& xio, const char *itemtag = "item");
void Jsonize(JsonIO& jio);
String ToString() const;
bool operator==(const InArray<T>& b) const { return IsEqualArray(*this, b); }
bool operator!=(const InArray<T>& b) const { return !operator==(b); }
int Compare(const InArray<T>& b) const { return CompareArray(*this, b); }
bool operator<=(const InArray<T>& x) const { return Compare(x) <= 0; }
bool operator>=(const InArray<T>& x) const { return Compare(x) >= 0; }
bool operator<(const InArray<T>& x) const { return Compare(x) < 0; }
bool operator>(const InArray<T>& x) const { return Compare(x) > 0; }
#endif
friend void Swap(InArray& a, InArray& b) { a.Swap(b); }
@ -439,6 +455,7 @@ template <class T, class Less = StdLess<T> >
class SortedIndex : MoveableAndDeepCopyOption< SortedIndex<T, Less> > {
InVector<T> iv;
template <class K, class TT, class Lss> friend class SortedVectorMap;
template <class K, class TT, class Lss, class Data> friend class SortedAMap;
public:
@ -479,16 +496,25 @@ public:
const InVector<T>& GetKeys() const { return iv; }
SortedIndex() {}
SortedIndex(const SortedIndex& s, int) : iv(s.iv, 1) {}
bool IsPicked() const { return iv.IsPicked(); }
void Swap(SortedIndex& a) { iv.Swap(a.iv); }
#ifdef UPP
void Serialize(Stream& s) { iv.Serialize(s); }
void Xmlize(XmlIO& xio, const char *itemtag = "key") { iv.Xmlize(xio, itemtag); }
void Jsonize(JsonIO& jio) { iv.Jsonize(jio); }
String ToString() const;
bool operator==(const SortedIndex& b) const { return IsEqualArray(*this, b); }
bool operator!=(const SortedIndex& b) const { return !operator==(b); }
int Compare(const SortedIndex& b) const { return CompareArray(*this, b); }
bool operator<=(const SortedIndex& x) const { return Compare(x) <= 0; }
bool operator>=(const SortedIndex& x) const { return Compare(x) >= 0; }
bool operator<(const SortedIndex& x) const { return Compare(x) < 0; }
bool operator>(const SortedIndex& x) const { return Compare(x) > 0; }
#endif
friend void Swap(SortedIndex& a, SortedIndex& b){ a.Swap(b); }
@ -497,13 +523,13 @@ public:
};
template <class K, class T, class Less, class Data>
class SortedAMap : MoveableAndDeepCopyOption< SortedAMap<K, T, Less, Data> > {
class SortedAMap {
protected:
SortedIndex<K, Less> key;
Data value;
Data value;
void SetSlave() { key.iv.SetSlave(&value); }
T& At(int i) const { int blki = key.iv.FindBlock(i); return value.Get(blki, i); }
void SetSlave() { key.iv.SetSlave(&value); }
T& At(int i) const { return (T&)value.data[i]; }
public:
int FindLowerBound(const K& k) const { return key.FindLowerBound(k); }
@ -516,14 +542,16 @@ public:
T& Get(const K& k) { return At(Find(k)); }
const T& Get(const K& k) const { return At(Find(k)); }
const T& Get(const K& k, const T& d) const { int i = Find(k); return i >= 0 ? value[i] : d; }
const T& Get(const K& k, const T& d) const { int i = Find(k); return i >= 0 ? At(i) : d; }
T *FindPtr(const K& k) { int i = Find(k); return i >= 0 ? &value[i] : NULL; }
const T *FindPtr(const K& k) const { int i = Find(k); return i >= 0 ? &value[i] : NULL; }
T *FindPtr(const K& k) { int i = Find(k); return i >= 0 ? &At(i) : NULL; }
const T *FindPtr(const K& k) const { int i = Find(k); return i >= 0 ? &At(i) : NULL; }
const K& GetKey(int i) const { return key[i]; }
const T& operator[](int i) const { return At(i); }
T& operator[](int i) { return At(i); }
const K& GetKey(int i) const { return key[i]; }
int GetCount() const { return key.GetCount(); }
bool IsEmpty() const { return key.IsEmpty(); }
void Clear() { key.Clear(); }
@ -533,22 +561,19 @@ public:
void Remove(int i, int count) { key.Remove(i, count); }
int RemoveKey(const K& k) { return key.RemoveKey(k); }
void Drop(int n = 1) { key.Drop(n); }
T& Top() { return value.Top(); }
const T& Top() const { return value.Top(); }
const K& TopKey() const { return key.Top(); }
K PopKey() { K h = TopKey(); Drop(); return h; }
void Trim(int n) { key.Trim(n); }
void Swap(SortedAMap& x) { Swap(value, x.value); Swap(key, x.key); }
bool IsPicked() const { return value.IsPicked() || key.IsPicked(); }
const SortedIndex<K>& GetIndex() const { return key; }
const InVector<K>& GetKeys() const { return key.GetKeys(); }
SortedAMap() { SetSlave(); }
SortedAMap(const SortedAMap& s, int) : key(s.key, 0), value(s.value, 0) { SetSlave(); }
bool IsPicked() const { return value.data.IsPicked() || key.IsPicked(); }
String ToString() const;
bool operator==(const SortedAMap& b) const { return IsEqualMap(*this, b); }
bool operator!=(const SortedAMap& b) const { return !operator==(b); }
int Compare(const SortedAMap& b) const { return CompareMap(*this, b); }
bool operator<=(const SortedAMap& x) const { return Compare(x) <= 0; }
bool operator>=(const SortedAMap& x) const { return Compare(x) >= 0; }
bool operator<(const SortedAMap& x) const { return Compare(x) < 0; }
bool operator>(const SortedAMap& x) const { return Compare(x) > 0; }
typedef K KeyType;
@ -557,24 +582,13 @@ public:
KeyConstIterator KeyBegin() const { return key.Begin(); }
KeyConstIterator KeyEnd() const { return key.End(); }
KeyConstIterator KeyGetIter(int pos) const { return key.GetIter(pos); }
typedef T ValueType;
typedef typename Data::Type::ConstIterator ConstIterator;
typedef typename Data::Type::Iterator Iterator;
Iterator Begin() { return value.data.Begin(); }
Iterator End() { return value.data.End(); }
Iterator GetIter(int pos) { return value.data.GetIter(pos); }
ConstIterator Begin() const { return value.data.Begin(); }
ConstIterator End() const { return value.data.End(); }
ConstIterator GetIter(int pos) const { return value.data.GetIter(pos); }
};
template <class T>
struct Slaved_InVector__ : InVectorSlave__ {
typedef InVector<T> Type;
InVector<T> data;
const T *ptr;
T *res;
virtual void Clear() { data.Clear(); }
virtual void Count(int n) { data.count += n; }
@ -593,28 +607,29 @@ struct Slaved_InVector__ : InVectorSlave__ {
};
template <class K, class T, class Less = StdLess<K> >
class SortedVectorMap : public MoveableAndDeepCopyOption<SortedVectorMap<K, T, Less> >,
public SortedAMap<K, T, Less, Slaved_InVector__<T> > {
typedef SortedAMap<K, T, Less, Slaved_InVector__<T> > B;
class SortedVectorMap : public SortedAMap<K, T, Less, Slaved_InVector__<T> >,
public MoveableAndDeepCopyOption<SortedVectorMap<K, T, Less> > {
typedef Slaved_InVector__<T> Data;
typedef SortedAMap<K, T, Less, Data> B;
public:
T& Add(const K& k, const T& x) { B::value.ptr = &x; B::key.Add(k); return *(T*)B::value.ptr; }
T& Add(const K& k) { B::value.ptr = NULL; B::key.Add(k); return *(T*)B::value.ptr; }
T& Add(const K& k) { B::key.Add(k); return *B::value.res; }
T& Add(const K& k, const T& x) { B::key.Add(k); *B::value.res = x; return *B::value.res; }
int FindAdd(const K& k) { B::value.ptr = NULL; return B::key.FindAdd(k); }
int FindAdd(const K& k, const T& init) { B::value.ptr = &init; return B::key.FindAdd(k); }
int FindAdd(const K& k) { return B::key.FindAdd(k); }
int FindAdd(const K& k, const T& init);
T& GetAdd(const K& k) { return B::At(FindAdd(k)); }
T& GetAdd(const K& k, const T& x) { return B::At(FindAdd(k, x)); }
T Pop() { T h = B::Top(); B::Drop(); return h; }
SortedVectorMap& operator()(const K& k, const T& v) { Add(k, v); return *this; }
const InVector<T>& GetValues() const { return B::value.data; }
SortedVectorMap() { B::SetSlave(); }
SortedVectorMap(SortedVectorMap rval_);
SortedVectorMap& operator=(SortedVectorMap rval_);
SortedVectorMap(const SortedVectorMap& s, int);
SortedVectorMap(const SortedVectorMap& s, int) : B(s, 1) {}
SortedVectorMap() {}
void Swap(SortedVectorMap& x);
#ifdef UPP
void Serialize(Stream& s);
@ -622,10 +637,21 @@ public:
void Jsonize(JsonIO& jio);
#endif
const InVector<T>& GetValues() const { return B::value.data; }
friend void Swap(SortedVectorMap& a, SortedVectorMap& b) { a.Swap(b); }
typedef typename B::ConstIterator ConstIterator;
typedef typename B::Iterator Iterator;
typedef T ValueType;
typedef typename Data::Type::ConstIterator ConstIterator;
typedef typename Data::Type::Iterator Iterator;
Iterator Begin() { return B::value.data.Begin(); }
Iterator End() { return B::value.data.End(); }
Iterator GetIter(int pos) { return B::value.data.GetIter(pos); }
ConstIterator Begin() const { return B::value.data.Begin(); }
ConstIterator End() const { return B::value.data.End(); }
ConstIterator GetIter(int pos) const { return B::value.data.GetIter(pos); }
STL_MAP_COMPATIBILITY(SortedVectorMap<K _cm_ T _cm_ Less>)
};
@ -633,8 +659,7 @@ template <class T>
struct Slaved_InArray__ : InVectorSlave__ {
typedef InArray<T> Type;
InArray<T> data;
T *ptr;
bool mk;
T *res;
virtual void Clear() { data.Clear(); }
virtual void Count(int n) { data.iv.count += n; }
@ -651,23 +676,22 @@ struct Slaved_InArray__ : InVectorSlave__ {
T& Get(int blki, int i) const { return *(T*)data.iv.data[blki][i]; }
T *Detach(int i) { T *x = data.iv[i]; data.iv[i] = NULL; return x; }
Slaved_InArray__() { mk = false; }
};
template <class K, class T, class Less = StdLess<K> >
class SortedArrayMap : public MoveableAndDeepCopyOption<SortedArrayMap<K, T, Less> >,
public SortedAMap<K, T, Less, Slaved_InArray__<T> > {
typedef SortedAMap<K, T, Less, Slaved_InArray__<T> > B;
typedef Slaved_InArray__<T> Data;
typedef SortedAMap<K, T, Less, Data> B;
public:
T& Add(const K& k, const T& x) { B::value.ptr = new T(x); B::key.Add(k); return *(T*)B::value.ptr; }
T& Add(const K& k) { B::value.ptr = new T; B::key.Add(k); return *(T*)B::value.ptr; }
T& Add(const K& k, T *newt) { B::value.ptr = newt; B::key.Add(k); return *newt; }
template <class TT> TT& Create(const K& k) { TT *q = new TT; B::value.ptr = q; B::key.Add(k); return *q; }
T& Add(const K& k, const T& x) { B::value.res = DeepCopyNew(x); B::key.Add(k); return *(T*)B::value.res; }
T& Add(const K& k) { B::value.res = NULL; B::key.Add(k); return *(T*)B::value.res; }
T& Add(const K& k, T *newt) { B::value.res = newt; B::key.Add(k); return *newt; }
template <class TT> TT& Create(const K& k) { TT *q = new TT(); B::value.res = q; B::key.Add(k); return *q; }
int FindAdd(const K& k) { B::value.ptr = NULL; return B::key.FindAdd(k); }
int FindAdd(const K& k, const T& init) { B::value.ptr = (T*)&init; B::value.mk = true; int x = B::key.FindAdd(k); B::value.mk = false; return x; }
int FindAdd(const K& k) { B::value.res = NULL; return B::key.FindAdd(k); }
int FindAdd(const K& k, const T& init);
T& GetAdd(const K& k) { return B::At(FindAdd(k)); }
T& GetAdd(const K& k, const T& x) { return B::At(FindAdd(k, x)); }
@ -679,8 +703,10 @@ public:
SortedArrayMap& operator()(const K& k, const T& v) { Add(k, v); return *this; }
SortedArrayMap(const SortedArrayMap& s, int) : B(s, 1) {}
SortedArrayMap() {}
SortedArrayMap() { B::SetSlave(); }
SortedArrayMap(SortedArrayMap rval_);
SortedArrayMap& operator=(SortedArrayMap rval_);
SortedArrayMap(const SortedArrayMap& s, int);
#ifdef UPP
void Serialize(Stream& s);
@ -688,9 +714,21 @@ public:
void Jsonize(JsonIO& jio);
#endif
void Swap(SortedArrayMap& x);
friend void Swap(SortedArrayMap& a, SortedArrayMap& b) { a.Swap(b); }
typedef typename B::ConstIterator ConstIterator;
typedef typename B::Iterator Iterator;
typedef T ValueType;
typedef typename Data::Type::ConstIterator ConstIterator;
typedef typename Data::Type::Iterator Iterator;
Iterator Begin() { return B::value.data.Begin(); }
Iterator End() { return B::value.data.End(); }
Iterator GetIter(int pos) { return B::value.data.GetIter(pos); }
ConstIterator Begin() const { return B::value.data.Begin(); }
ConstIterator End() const { return B::value.data.End(); }
ConstIterator GetIter(int pos) const { return B::value.data.GetIter(pos); }
STL_MAP_COMPATIBILITY(SortedArrayMap<K _cm_ T _cm_ HashFn>)
};

View file

@ -310,7 +310,7 @@ void InVector<T>::InsertN(int ii, int n)
template <class T>
void InVector<T>::Join(int blki)
{
data[blki].AppendPick(data[blki + 1]);
data[blki].AppendPick(pick(data[blki + 1]));
data.Remove(blki + 1);
}
@ -434,6 +434,7 @@ InVector<T>::InVector(const InVector<T>& v, int)
blk_high = v.blk_high;
blk_low = v.blk_low;
serial = NewInVectorSerial();
slave = v.slave;
}
template <class T>
@ -631,13 +632,14 @@ void InVector<T>::ConstIterator::PrevBlk()
template <typename T>
void InVector<T>::Swap(InVector& b)
{
Swap(data, b.data);
Swap(index, b.index);
Swap(count, b.count);
Swap(hcount, b.hcount);
Swap(serial, b.serial);
Swap(blk_high, b.blk_high);
Swap(blk_low, b.blk_low);
Upp::Swap(data, b.data);
Upp::Swap(index, b.index);
Upp::Swap(count, b.count);
Upp::Swap(hcount, b.hcount);
Upp::Swap(serial, b.serial);
Upp::Swap(blk_high, b.blk_high);
Upp::Swap(blk_low, b.blk_low);
Upp::Swap(slave, b.slave);
}
#ifdef UPP
@ -652,6 +654,13 @@ void InVector<T>::Jsonize(JsonIO& jio)
{
JsonizeArray<InVector<T>, T>(jio, *this);
}
template <class T>
String InVector<T>::ToString() const
{
return AsStringArray(*this);
}
#endif
template <class T>
@ -785,7 +794,7 @@ InArray<T>::InArray(const InArray& v, int)
ConstIterator s = v.Begin();
IVIter it = iv.Begin();
while(n--)
*it++ = new T(*s++);
*it++ = DeepCopyNew(*s++);
}
#ifdef UPP
@ -800,161 +809,13 @@ void InArray<T>::Jsonize(JsonIO& jio)
{
JsonizeArray<InArray<T>, T>(jio, *this);
}
#endif
template <class T, class Less>
int SortedIndex<T, Less>::FindAdd(const T& key)
{
int i = FindLowerBound(key);
if(i == GetCount() || Less()(key, iv[i]))
iv.Insert(i, key);
return i;
}
template <class T, class Less>
int SortedIndex<T, Less>::FindNext(int i) const
{
return i + 1 < iv.GetCount() && !Less()(iv[i], iv[i + 1]) ? i + 1 : -1;
}
template <class T, class Less>
int SortedIndex<T, Less>::FindLast(const T& x) const
{
int i = iv.FindUpperBound(x, Less());
return i > 0 && !Less()(iv[i - 1], x) ? i - 1 : -1;
}
template <class T, class Less>
int SortedIndex<T, Less>::FindPrev(int i) const
{
return i > 0 && !Less()(iv[i - 1], iv[i]) ? i - 1 : -1;
}
template <class T, class Less>
int SortedIndex<T, Less>::RemoveKey(const T& x)
{
int l = FindLowerBound(x);
int count = FindUpperBound(x) - l;
Remove(l, count);
return count;
}
template <class T>
void Slaved_InVector__<T>::Insert(int blki, int pos)
String InArray<T>::ToString() const
{
if(ptr)
data.data[blki].Insert(pos, *ptr);
else
data.data[blki].Insert(pos);
ptr = &data.data[blki][pos];
return AsStringArray(*this);
}
template <class T>
void Slaved_InVector__<T>::Split(int blki, int nextsize)
{
Vector<T>& x = data.data.Insert(blki + 1);
x.InsertSplit(0, data.data[blki], nextsize);
data.data[blki].Shrink();
}
template <class T>
void Slaved_InVector__<T>::AddFirst()
{
if(ptr)
data.data.Add().Add(*ptr);
else
data.data.Add().Add();
ptr = &data.data[0][0];
}
template <class T>
void Slaved_InArray__<T>::Insert(int blki, int pos)
{
data.iv.data[blki].Insert(pos, mk ? new T(*ptr) : ptr ? ptr : new T);
}
template <class T>
void Slaved_InArray__<T>::Split(int blki, int nextsize)
{
Vector< typename InArray<T>::PointerType >& x = data.iv.data.Insert(blki + 1);
x.InsertSplit(0, data.iv.data[blki], nextsize);
}
template <class T>
void Slaved_InArray__<T>::Remove(int blki, int pos, int n)
{
Vector< typename InArray<T>::PointerType >& b = data.iv.data[blki];
for(int i = 0; i < n; i++)
if(b[i + pos])
delete (T *)b[i + pos];
b.Remove(pos, n);
}
template <class T>
void Slaved_InArray__<T>::AddFirst()
{
data.iv.data.Add().Add(mk ? new T(*ptr) : ptr ? ptr : new T);
}
#ifdef UPP
template <class K, class T>
void StreamSortedMap(Stream& s, T& cont)
{
int n = cont.GetCount();
s / n;
if(n < 0) {
s.LoadError();
return;
}
if(s.IsLoading()) {
cont.Clear();
while(n--) {
K key;
s % key;
s % cont.Add(key);
}
}
else
for(int i = 0; i < cont.GetCount(); i++) {
K key = cont.GetKey(i);
s % key;
s % cont[i];
}
}
template <class K, class T, class Less>
void SortedVectorMap<K, T, Less>::Serialize(Stream& s) {
StreamSortedMap<K, SortedVectorMap<K, T, Less> >(s, *this);
}
template <class K, class T, class Less>
void SortedVectorMap<K, T, Less>::Xmlize(XmlIO& xio)
{
XmlizeSortedMap<K, T, SortedVectorMap<K, T, Less> >(xio, "key", "value", *this);
}
template <class K, class T, class Less>
void SortedVectorMap<K, T, Less>::Jsonize(JsonIO& jio)
{
JsonizeSortedMap<SortedVectorMap<K, T, Less>, K, T>(jio, *this, "key", "value");
}
template <class K, class T, class Less>
void SortedArrayMap<K, T, Less>::Serialize(Stream& s) {
StreamSortedMap<K, SortedArrayMap<K, T, Less> >(s, *this);
}
template <class K, class T, class Less>
void SortedArrayMap<K, T, Less>::Xmlize(XmlIO& xio)
{
XmlizeSortedMap<K, T, SortedArrayMap<K, T, Less> >(xio, "key", "value", *this);
}
template <class K, class T, class Less>
void SortedArrayMap<K, T, Less>::Jsonize(JsonIO& jio)
{
JsonizeSortedMap<SortedArrayMap<K, T, Less>, K, T>(jio, *this, "key", "value");
}
#endif
#ifdef LLOG

View file

@ -63,8 +63,8 @@ public:
HashBase();
~HashBase();
HashBase(pick_ HashBase& b);
void operator=(pick_ HashBase& b);
HashBase(HashBase rval_ b);
void operator=(HashBase rval_ b);
HashBase(const HashBase& b, int);
void operator<<=(const HashBase& b);
@ -166,15 +166,24 @@ public:
void Serialize(Stream& s);
void Xmlize(XmlIO& xio, const char *itemtag = "key");
void Jsonize(JsonIO& jio);
String ToString() const;
bool operator==(const AIndex& b) const { return IsEqualArray(*this, b); }
bool operator!=(const AIndex& b) const { return !operator==(b); }
int Compare(const AIndex& b) const { return CompareArray(*this, b); }
bool operator<=(const AIndex& x) const { return Compare(x) <= 0; }
bool operator>=(const AIndex& x) const { return Compare(x) >= 0; }
bool operator<(const AIndex& x) const { return Compare(x) < 0; }
bool operator>(const AIndex& x) const { return Compare(x) > 0; }
#endif
V PickKeys() pick_ { return key; }
V PickKeys() { return pick(key); }
const V& GetKeys() const { return key; }
bool IsPicked(void) const { return key.IsPicked(); }
// Pick assignment & copy. Picked source can only Clear(), ~AIndex(), operator=, operator<<=
AIndex& operator=(pick_ V& s);
AIndex& operator=(V rval_ s);
// AIndex& operator=(AIndex rval_ s) = default;
AIndex& operator<<=(const V& s);
// Standard container interface
@ -191,7 +200,7 @@ public:
friend int GetCount(const AIndex& v) { return v.GetCount(); }
protected:
AIndex(pick_ V& s);
AIndex(V rval_ s);
AIndex(const V& s, int);
AIndex() {}
AIndex(const AIndex& s, int);
@ -205,12 +214,13 @@ public:
T Pop() { T x = B::Top(); B::Drop(); return x; }
Index() {}
Index(pick_ Index& s) : B(s) {}
Index(Index rval_ s) : B(pick(s)) {}
Index(const Index& s, int) : B(s, 1) {}
explicit Index(pick_ Vector<T>& s) : B(s){}
explicit Index(Vector<T> rval_ s) : B(pick(s)) {}
Index(const Vector<T>& s, int) : B(s, 1) {}
Index& operator=(pick_ Vector<T>& x) { B::operator=(x); return *this; }
Index& operator=(Vector<T> rval_ x) { B::operator=(pick(x)); return *this; }
Index& operator=(Index<T> rval_ x) { B::operator=(pick(x)); return *this; }
friend void Swap(Index& a, Index& b) { a.B::Swap(b); }
@ -237,14 +247,15 @@ public:
T *Detach(int i) { B::hash.Remove(i); return B::key.Detach(i); }
ArrayIndex() {}
ArrayIndex(pick_ ArrayIndex& s) : B(s) {}
ArrayIndex(const ArrayIndex& s, int) : B(s, 1) {}
explicit ArrayIndex(pick_ Array<T>& s) : B(s) {}
ArrayIndex(const Array<T>& s, int) : B(s, 1) {}
ArrayIndex(ArrayIndex rval_ s) : B(pick(s)) {}
ArrayIndex(const ArrayIndex& s, int) : B(s, 1) {}
explicit ArrayIndex(Array<T> rval_ s) : B(pick(s)) {}
ArrayIndex(const Array<T>& s, int) : B(s, 1) {}
ArrayIndex& operator=(pick_ Array<T>& x) { B::operator=(x); return *this; }
ArrayIndex& operator=(Array<T> rval_ x) { B::operator=(pick(x)); return *this; }
ArrayIndex& operator=(ArrayIndex<T> rval_ x) { B::operator=(pick(x)); return *this; }
friend void Swap(ArrayIndex& a, ArrayIndex& b) { a.B::Swap(b); }
friend void Swap(ArrayIndex& a, ArrayIndex& b) { a.B::Swap(b); }
typedef typename B::ConstIterator ConstIterator; // GCC bug (?)
STL_INDEX_COMPATIBILITY(ArrayIndex<T _cm_ HashFn>)

View file

@ -220,7 +220,7 @@ void JsonizeArray(JsonIO& io, T& array)
Jsonize(jio, array[i]);
jio.Put(va[i]);
}
io.Set(ValueArray(va));
io.Set(ValueArray(pick(va)));
}
}
@ -249,7 +249,7 @@ void JsonizeMap(JsonIO& io, T& map, const char *keyid, const char *valueid)
item.Add(valueid, StoreAsJsonValue(map[i]));
va[i] = item;
}
io.Set(ValueArray(va));
io.Set(ValueArray(pick(va)));
}
}
@ -276,7 +276,7 @@ void JsonizeSortedMap(JsonIO& io, T& map, const char *keyid, const char *valueid
item.Add(valueid, StoreAsJsonValue(map[i]));
va[i] = item;
}
io.Set(ValueArray(va));
io.Set(ValueArray(pick(va)));
}
}
@ -305,7 +305,7 @@ void JsonizeStringMap(JsonIO& io, T& map)
index.Add(StoreAsJsonValue(map.GetKey(i)));
values.Add(StoreAsJsonValue(map[i]));
}
ValueMap vm(index, values);
ValueMap vm(pick(index), pick(values));
io.Set(vm);
}
}
@ -339,7 +339,7 @@ void JsonizeIndex(JsonIO& io, T& index)
for(int i = 0; i < index.GetCount(); i++)
if(!index.IsUnlinked(i))
va.Add(StoreAsJsonValue(index[i]));
io.Set(ValueArray(va));
io.Set(ValueArray(pick(va)));
}
}

View file

@ -120,7 +120,7 @@ void LogOut::Create(bool append)
::GetUserNameA(user, &w);
#endif
#else //#
const char *procexepath_();
const char *procexepath_(void);
strcpy(exe, procexepath_());
const char *uenv = getenv("USER");
strcpy(user, uenv ? uenv : "boot");

View file

@ -6,7 +6,7 @@ protected:
public:
T& Add(const K& k, const T& x) { key.Add(k); return value.Add(x); }
T& AddPick(const K& k, pick_ T& x) { key.Add(k); return value.AddPick(x); }
T& AddPick(const K& k, T rval_ x) { key.Add(k); return value.AddPick(pick(x)); }
T& Add(const K& k) { key.Add(k); return value.Add(); }
int Find(const K& k, unsigned h) const { return key.Find(k, h); }
@ -18,15 +18,15 @@ public:
int FindAdd(const K& k);
int FindAdd(const K& k, const T& init);
int FindAddPick(const K& k, pick_ T& init);
int FindAddPick(const K& k, T rval_ init);
int Put(const K& k, const T& x);
int PutPick(const K& k, pick_ T& x);
int PutPick(const K& k, T rval_ x);
T& Put(const K& k);
int FindPut(const K& k);
int FindPut(const K& k, const T& init);
int FindPutPick(const K& k, pick_ T& init);
int FindPutPick(const K& k, T rval_ init);
T& Get(const K& k) { return value[Find(k)]; }
const T& Get(const K& k) const { return value[Find(k)]; }
@ -35,12 +35,12 @@ public:
T& GetAdd(const K& k);
T& GetAdd(const K& k, const T& x);
T& GetAddPick(const K& k, pick_ T& x);
T& GetAddPick(const K& k, T rval_ x);
T& GetPut(const K& k);
T& GetPut(const K& k, const T& x);
T& GetPutPick(const K& k, pick_ T& x);
T& GetPutPick(const K& k, T rval_ x);
void SetKey(int i, const K& k) { key.Set(i, k); }
@ -87,19 +87,27 @@ public:
void Serialize(Stream& s);
void Xmlize(XmlIO& xio);
void Jsonize(JsonIO& jio);
String ToString() const;
bool operator==(const AMap& b) const { ASSERT(!HasUnlinked()); return IsEqualMap(*this, b); }
bool operator!=(const AMap& b) const { return !operator==(b); }
int Compare(const AMap& b) const { ASSERT(!HasUnlinked()); return CompareMap(*this, b); }
bool operator<=(const AMap& x) const { return Compare(x) <= 0; }
bool operator>=(const AMap& x) const { return Compare(x) >= 0; }
bool operator<(const AMap& x) const { return Compare(x) < 0; }
bool operator>(const AMap& x) const { return Compare(x) > 0; }
#endif
void Swap(AMap& x) { UPP::Swap(value, x.value);
UPP::Swap(key, x.key); }
const Index<K, HashFn>& GetIndex() const { return key; }
Index<K, HashFn> PickIndex() pick_ { return key; }
Index<K, HashFn> PickIndex() { return pick(key); }
const Vector<K>& GetKeys() const { return key.GetKeys(); }
Vector<K> PickKeys() pick_ { return key.PickKeys(); }
Vector<K> PickKeys() { return key.PickKeys(); }
const V& GetValues() const { return value; }
V& GetValues() { return value; }
V PickValues() pick_ { return value; }
V PickValues() { return pick(value); }
bool IsPicked() const { return value.IsPicked() || key.IsPicked(); }
@ -107,8 +115,8 @@ public:
AMap() {}
AMap(const AMap& s, int) : key(s.key, 0), value(s.value, 0) {}
AMap(pick_ Index<K, HashFn>& ndx, pick_ V& val) : key(ndx), value(val) {}
AMap(pick_ Vector<K>& ndx, pick_ V& val) : key(ndx), value(val) {}
AMap(Index<K, HashFn> rval_ ndx, V rval_ val) : key(pick(ndx)), value(pick(val)) {}
AMap(Vector<K> rval_ ndx, V rval_ val) : key(pick(ndx)), value(pick(val)) {}
typedef Vector<K> KeyContainer;
typedef K KeyType;
@ -141,8 +149,8 @@ public:
T Pop() { T h = B::Top(); B::Drop(); return h; }
VectorMap(const VectorMap& s, int) : AMap<K, T, Vector<T>, HashFn>(s, 1) {}
VectorMap(pick_ Index<K, HashFn>& ndx, pick_ Vector<T>& val) : AMap<K, T, Vector<T>, HashFn>(ndx, val) {}
VectorMap(pick_ Vector<K>& ndx, pick_ Vector<T>& val) : AMap<K, T, Vector<T>, HashFn>(ndx, val) {}
VectorMap(Index<K, HashFn> rval_ ndx, Vector<T> rval_ val) : AMap<K, T, Vector<T>, HashFn>(pick(ndx), pick(val)) {}
VectorMap(Vector<K> rval_ ndx, Vector<T> rval_ val) : AMap<K, T, Vector<T>, HashFn>(pick(ndx), pick(val)) {}
VectorMap() {}
friend void Swap(VectorMap& a, VectorMap& b) { a.B::Swap(b); }
@ -170,8 +178,8 @@ public:
T *Swap(int i, T *newt) { return B::value.Swap(i, newt); }
ArrayMap(const ArrayMap& s, int) : AMap<K, T, Array<T>, HashFn>(s, 1) {}
ArrayMap(pick_ Index<K, HashFn>& ndx, pick_ Array<T>& val) : AMap<K, T, Array<T>, HashFn>(ndx, val) {}
ArrayMap(pick_ Vector<K>& ndx, pick_ Array<T>& val) : AMap<K, T, Array<T>, HashFn>(ndx, val) {}
ArrayMap(Index<K, HashFn> rval_ ndx, Array<T> rval_ val) : AMap<K, T, Array<T>, HashFn>(pick(ndx), pick(val)) {}
ArrayMap(Vector<K> rval_ ndx, Array<T> rval_ val) : AMap<K, T, Array<T>, HashFn>(pick(ndx), pick(val)) {}
ArrayMap() {}
friend void Swap(ArrayMap& a, ArrayMap& b) { a.B::Swap(b); }
@ -187,8 +195,8 @@ class SegtorMap : public MoveableAndDeepCopyOption< SegtorMap<K, T, NBLK, HashFn
typedef AMap< K, T, Segtor<T, NBLK>, HashFn > B;
public:
SegtorMap(const SegtorMap& s, int) : AMap<K, T, Segtor<T, NBLK>, HashFn>(s, 1) {}
SegtorMap(pick_ Index<K, HashFn>& ndx, pick_ Segtor<T>& val) : AMap<K, T, Segtor<T, NBLK>, HashFn>(ndx, val) {}
SegtorMap(pick_ Vector<K>& ndx, pick_ Segtor<T>& val) : AMap<K, T, Segtor<T, NBLK>, HashFn>(ndx, val) {}
SegtorMap(Index<K, HashFn> rval_ ndx, Segtor<T> rval_ val) : AMap<K, T, Segtor<T, NBLK>, HashFn>(pick(ndx), pick(val)) {}
SegtorMap(Vector<K> rval_ ndx, Segtor<T> rval_ val) : AMap<K, T, Segtor<T, NBLK>, HashFn>(pick(ndx), pick(val)) {}
SegtorMap() {}
friend void Swap(SegtorMap& a, SegtorMap& b) { a.B::Swap(b); }

View file

@ -100,8 +100,8 @@ void AIndex<T, V, HashFn>::Hash() {
}
template <class T, class V, class HashFn>
AIndex<T, V, HashFn>& AIndex<T, V, HashFn>::operator=(pick_ V& s) {
key = s;
AIndex<T, V, HashFn>& AIndex<T, V, HashFn>::operator=(V rval_ s) {
key = pick(s);
hash.Clear();
Hash();
return *this;
@ -116,7 +116,7 @@ AIndex<T, V, HashFn>& AIndex<T, V, HashFn>::operator<<=(const V& s) {
}
template <class T, class V, class HashFn>
AIndex<T, V, HashFn>::AIndex(pick_ V& s) : key(s) {
AIndex<T, V, HashFn>::AIndex(V rval_ s) : key(pick(s)) {
Hash();
}
@ -246,6 +246,13 @@ void AIndex<T, V, HashFn>::Jsonize(JsonIO& jio)
{
JsonizeIndex<AIndex<T, V, HashFn>, T>(jio, *this);
}
template <class T, class V, class HashFn>
String AIndex<T, V, HashFn>::ToString() const
{
return AsStringArray(*this);
}
#endif
template <class T, class V, class HashFn>
@ -390,7 +397,7 @@ int AMap<K, T, V, HashFn>::FindAdd(const K& k, const T& x) {
}
template <class K, class T, class V, class HashFn>
int AMap<K, T, V, HashFn>::FindAddPick(const K& k, pick_ T& x) {
int AMap<K, T, V, HashFn>::FindAddPick(const K& k, T rval_ x) {
unsigned hash = key.hashfn(k);
int i = Find(k, hash);
if(i < 0) {
@ -415,7 +422,7 @@ int AMap<K, T, V, HashFn>::Put(const K& k, const T& x)
}
template <class K, class T, class V, class HashFn>
int AMap<K, T, V, HashFn>::PutPick(const K& k, pick_ T& x)
int AMap<K, T, V, HashFn>::PutPick(const K& k, T rval_ x)
{
int i = key.Put(k);
if(i < value.GetCount())
@ -470,7 +477,7 @@ int AMap<K, T, V, HashFn>::FindPut(const K& k, const T& init)
}
template <class K, class T, class V, class HashFn>
int AMap<K, T, V, HashFn>::FindPutPick(const K& k, pick_ T& init)
int AMap<K, T, V, HashFn>::FindPutPick(const K& k, T rval_ init)
{
unsigned hash = key.hashfn(k);
int i = Find(k, hash);
@ -502,7 +509,7 @@ T& AMap<K, T, V, HashFn>::GetAdd(const K& k, const T& x) {
}
template <class K, class T, class V, class HashFn>
T& AMap<K, T, V, HashFn>::GetAddPick(const K& k, pick_ T& x) {
T& AMap<K, T, V, HashFn>::GetAddPick(const K& k, T rval_ x) {
unsigned hash = key.hashfn(k);
int i = Find(k, hash);
if(i >= 0) return value[i];
@ -522,7 +529,7 @@ T& AMap<K, T, V, HashFn>::GetPut(const K& k, const T& x) {
}
template <class K, class T, class V, class HashFn>
T& AMap<K, T, V, HashFn>::GetPutPick(const K& k, pick_ T& x) {
T& AMap<K, T, V, HashFn>::GetPutPick(const K& k, T rval_ x) {
return value[FindAddPick(k, x)];
}
@ -544,6 +551,23 @@ void AMap<K, T, V, HashFn>::Jsonize(JsonIO& jio)
{
JsonizeMap<AMap<K, T, V, HashFn>, K, T>(jio, *this, "key", "value");
}
template <class K, class T, class V, class HashFn>
String AMap<K, T, V, HashFn>::ToString() const
{
String r;
r = "{";
for(int i = 0; i < GetCount(); i++) {
if(i)
r << ", ";
if(IsUnlinked(i))
r << "UNLINKED ";
r << GetKey(i) << ": " << (*this)[i];
}
r << '}';
return r;
}
#endif
template <class K, class T, class V, class HashFn>
@ -585,4 +609,19 @@ void FixedAMap<K, T, V, Less>::Jsonize(JsonIO& jio)
{
JsonizeSortedMap<FixedAMap<K, T, V, Less>, K, T>(jio, *this, "key", "value");
}
template <class K, class T, class V, class Less>
String FixedAMap<K, T, V, Less>::ToString() const
{
String r;
r = "{";
for(int i = 0; i < GetCount(); i++) {
if(i)
r << ", ";
r << GetKey(i) << ": " << (*this)[i];
}
r << '}';
return r;
}
#endif

View file

@ -26,16 +26,16 @@ class One : MoveableAndDeepCopyOption< One<T> > {
void Free() { if(ptr && ptr != (T*)1) delete ptr; }
void Chk() const { ASSERT(ptr != (T*)1); }
void ChkP() const { Chk(); ASSERT(ptr); }
void Pick(pick_ One<T>& data) { T *p = data.ptr; data.ptr = (T*)1; ptr = p; }
void Pick(One<T> rval_ data) { T *p = data.ptr; data.ptr = (T*)1; ptr = p; }
public:
void Attach(T *data) { Free(); ptr = data; }
T *Detach() pick_ { ChkP(); T *t = ptr; ptr = NULL; return t; }
T *operator-() pick_ { return Detach(); }
T *Detach() { ChkP(); T *t = ptr; ptr = NULL; return t; }
T *operator-() { return Detach(); }
void Clear() { Free(); ptr = NULL; }
void operator=(T *data) { Attach(data); }
void operator=(pick_ One<T>& d) { Free(); Pick(d); }
void operator=(One<T> rval_ d) { Free(); Pick(pick(d)); }
const T *operator->() const { ChkP(); return ptr; }
T *operator->() { ChkP(); return ptr; }
@ -53,9 +53,11 @@ public:
operator bool() const { return ptr; }
String ToString() const { return ptr ? AsString(*ptr) : "<empty>"; }
One() { ptr = NULL; }
One(T *newt) { ptr = newt; }
One(pick_ One<T>& p) { Pick(p); }
One(One<T> rval_ p) { Pick(pick(p)); }
One(const One<T>& p, int) { ptr = p.IsEmpty() ? NULL : DeepCopyNew(*p); }
~One() { Free(); }
};
@ -77,7 +79,7 @@ class Any : Moveable<Any> {
BaseData *ptr;
void Chk() const { ASSERT(ptr != (void *)1); }
void Pick(pick_ Any& s) { ptr = s.ptr; const_cast<Any&>(s).ptr = (BaseData *)1; }
void Pick(Any rval_ s) { ptr = s.ptr; const_cast<Any&>(s).ptr = (BaseData *)1; }
public:
template <class T> T& Create() { Clear(); Data<T> *x = new Data<T>; ptr = x; return x->data; }
@ -90,8 +92,8 @@ public:
bool IsEmpty() const { return ptr == NULL; }
bool IsPicked() const { return ptr == (void *)1; }
void operator=(pick_ Any& s) { Clear(); Pick(s); }
Any(pick_ Any& s) { Pick(s); }
void operator=(Any rval_ s) { Clear(); Pick(pick(s)); }
Any(Any rval_ s) { Pick(pick(s)); }
Any() { ptr = NULL; }
~Any() { Clear(); }
@ -117,8 +119,8 @@ public:
Buffer(size_t size, const T& init) { ptr = new T[size]; Fill(ptr, ptr + size, init); }
~Buffer() { if(ptr) delete[] ptr; }
void operator=(pick_ Buffer& v) { if(ptr) delete[] ptr; ptr = v.ptr; v.ptr = NULL; }
Buffer(pick_ Buffer& v) { ptr = v.ptr; v.ptr = NULL; }
void operator=(Buffer rval_ v) { if(ptr) delete[] ptr; ptr = v.ptr; v.ptr = NULL; }
Buffer(Buffer rval_ v) { ptr = v.ptr; v.ptr = NULL; }
};
class Bits : Moveable<Bits> {
@ -136,8 +138,8 @@ public:
Bits() { bp = NULL; alloc = 0; }
~Bits() { Clear(); }
Bits(pick_ Bits& b) { alloc = b.alloc; bp = b.bp; b.alloc = -1; }
void operator=(pick_ Bits& b) { Clear(); alloc = b.alloc; bp = b.bp; b.alloc = -1; }
Bits(Bits rval_ b) { alloc = b.alloc; bp = b.bp; b.alloc = -1; }
void operator=(Bits rval_ b) { Clear(); alloc = b.alloc; bp = b.bp; b.alloc = -1; }
};
//# System dependent
@ -150,7 +152,7 @@ class Mitor : Moveable< Mitor<T> > {
byte elem0[sizeof(T)];
T& Get(int i) const;
void Pick(pick_ Mitor& m);
void Pick(Mitor rval_ m);
void Copy(const Mitor& m);
void Chk() const { ASSERT(count != 2); }
@ -163,11 +165,11 @@ public:
void Clear();
void Shrink();
Mitor(pick_ Mitor& m) { Pick(m); }
void operator=(pick_ Mitor& m) { Clear(); Pick(m); }
Mitor(Mitor rval_ m) { Pick(m); }
void operator=(Mitor rval_ m) { Clear(); Pick(pick(m)); }
Mitor(Mitor& m, int) { Copy(m); }
void operator<<=(const Mitor& m) { Clear(); Copy(m); }
void operator<<=(const Mitor& m) { Clear(); Copy(pick(m)); }
Mitor() { count = 0; }
~Mitor() { Clear(); }
@ -181,7 +183,7 @@ T& Mitor<T>::Get(int i) const
}
template <class T>
void Mitor<T>::Pick(pick_ Mitor& m)
void Mitor<T>::Pick(Mitor rval_ m)
{
m.Chk();
vector = m.vector;

View file

@ -270,8 +270,8 @@ public:
WithDeepCopy(const T& a) : T(a, 1) {}
WithDeepCopy(const WithDeepCopy& a) : T(a, 1) {}
WithDeepCopy& operator=(const WithDeepCopy& a) { (T&)*this <<= a; return *this; }
WithDeepCopy(int, pick_ T& a) : T(a) {}
WithDeepCopy& operator^=(pick_ T& a) { (T&)*this = a; return *this; }
WithDeepCopy(int, T rval_ a) : T(a) {}
WithDeepCopy& operator^=(T rval_ a) { (T&)*this = pick(a); return *this; }
WithDeepCopy() {}
};
@ -518,3 +518,57 @@ inline unsigned GetHashValue(T *ptr) { return GetPtr
template <class T> inline const T& ntl_max(const T& a, const T& b) { return a > b ? a : b; }
template <int size>
struct Data_S_ : Moveable< Data_S_<size> >
{
byte filler[size];
};
template <class C>
bool IsEqualArray(const C& a, const C& b)
{
if(a.GetCount() != b.GetCount())
return false;
for(int i = 0; i < a.GetCount(); i++)
if(!(a[i] == b[i]))
return false;
return true;
}
template <class C>
int CompareArray(const C& a, const C& b)
{
int n = min(a.GetCount(), b.GetCount());
for(int i = 0; i < n; i++) {
int q = SgnCompare(a[i], b[i]);
if(q)
return q;
}
return SgnCompare(a.GetCount(), b.GetCount());
}
template <class C>
bool IsEqualMap(const C& a, const C& b)
{
if(a.GetCount() != b.GetCount())
return false;
for(int i = 0; i < a.GetCount(); i++)
if(a.GetKey(i) != b.GetKey(i) || a[i] != b[i])
return false;
return true;
}
template <class C>
int CompareMap(const C& a, const C& b)
{
int n = min(a.GetCount(), b.GetCount());
for(int i = 0; i < n; i++) {
int q = SgnCompare(a.GetKey(i), b.GetKey(i));
if(q)
return q;
q = SgnCompare(a[i], b[i]);
if(q)
return q;
}
return SgnCompare(a.GetCount(), b.GetCount());
}

View file

@ -17,6 +17,9 @@ struct Tuple2 {
void Serialize(Stream& s) { s % a % b; }
String ToString() const { return String().Cat() << '(' << a << ", " << b << ')'; }
template <typename AA, typename BB>
operator Tuple2<AA, BB>() const { Tuple2<AA, BB> t; t.a = (AA)a; t.b = (BB)b; return t; }
};
template<typename A, typename B>
@ -55,6 +58,9 @@ struct Tuple3 {
void Serialize(Stream& s) { s % a % b % c; }
String ToString() const { return String().Cat() << '(' << a << ", " << b << ", " << c << ')'; }
template <typename AA, typename BB, typename CC>
operator Tuple3<AA, BB, CC>() const { Tuple3<AA, BB, CC> t; t.a = (AA)a; t.b = (BB)b; t.c = (CC)c; return t; }
};
template<typename A, typename B, typename C>
@ -96,6 +102,9 @@ struct Tuple4 {
void Serialize(Stream& s) { s % a % b % c % d; }
String ToString() const { return String().Cat() << '(' << a << ", " << b << ", " << c << ", " << d << ')'; }
template <typename AA, typename BB, typename CC, typename DD>
operator Tuple4<AA, BB, CC, DD>() const { Tuple4<AA, BB, CC, DD> t; t.a = (AA)a; t.b = (BB)b; t.c = (CC)c; t.d = (DD)d; return t; }
};
template<typename A, typename B, typename C, typename D>
@ -127,3 +136,45 @@ inline T *FindTuple(T *x, int n, const U& key) {
}
return NULL;
}
template <typename A, typename B>
struct Tie2 {
A& a;
B& b;
void operator=(const Tuple2<A, B>& s) { a = s.a; b = s.b; }
Tie2(A& a, B& b) : a(a), b(b) {}
};
template <typename A, typename B>
Tie2<A, B> Tie(A& a, B& b) { return Tie2<A, B>(a, b); }
template <typename A, typename B, typename C>
struct Tie3 {
A& a;
B& b;
C& c;
void operator=(const Tuple3<A, B, C>& s) { a = s.a; b = s.b; c = s.c; }
Tie3(A& a, B& b, C& c) : a(a), b(b), c(c) {}
};
template <typename A, typename B, typename C>
Tie3<A, B, C> Tie(A& a, B& b, C& c) { return Tie3<A, B, C>(a, b, c); }
template <typename A, typename B, typename C, typename D>
struct Tie4 {
A& a;
B& b;
C& c;
D& d;
void operator=(const Tuple4<A, B, C, D>& s) { a = s.a; b = s.b; c = s.c; d = s.d; }
Tie4(A& a, B& b, C& c, D& d) : a(a), b(b), c(c), d(d) {}
};
template <typename A, typename B, typename C, typename D>
Tie4<A, B, C, D> Tie(A& a, B& b, C& c, D& d) { return Tie4<A, B, C, D>(a, b, c, d); }

View file

@ -90,6 +90,39 @@ bool Value::operator==(const Value& v) const {
return svo[st]->IsEqual(&data, &v.data);
}
int Value::PolyCompare(const Value& v) const
{
int st = data.GetSpecial();
if(st == REF)
return ptr()->PolyCompare(v);
if(st != VOIDV)
return svo[st]->PolyCompare(&data, v);
return 0;
}
int Value::Compare(const Value& v) const
{
if(IsString() && v.IsString())
return SgnCompare(data, v.data);
bool a = IsNull();
bool b = v.IsNull();
if(a || b)
return SgnCompare(b, a);
int st = data.GetSpecial();
if(GetType() == v.GetType()) {
if(st == REF)
return ptr()->Compare(v.ptr());
if(st != VOIDV)
return svo[st]->Compare(&data, &v.data);
}
if(st != VOIDV) {
int q = PolyCompare(v);
if(q) return q; // Perhaps optimize this
return v.PolyCompare(*this);
}
return 0;
}
static bool sIsSame(const Value& a, const Value& b)
{
if(a.Is<ValueMap>() && b.Is<ValueMap>()) {

View file

@ -62,6 +62,8 @@ public:
unsigned GetHashValue() const { return 0; }
bool operator==(const T&) const { NEVER(); return false; }
String ToString() const { return typeid(T).name(); }
int Compare(const T&) const { NEVER(); return 0; }
int PolyCompare(const Value&) const { NEVER(); return 0; }
operator ValueTypeRef();
};
@ -92,6 +94,8 @@ public:
virtual bool IsEqual(const Void *p) { return false; }
virtual bool IsPolyEqual(const Value& v) { return false; }
virtual String AsString() const { return ""; }
virtual int Compare(const Void *p) { return 0; }
virtual int PolyCompare(const Value& p) { return 0; }
Void() { refcount = 1; }
virtual ~Void() {}
@ -108,6 +112,8 @@ public:
bool (*IsEqual)(const void *p1, const void *p2);
bool (*IsPolyEqual)(const void *p, const Value& v);
String (*AsString)(const void *p);
int (*Compare)(const void *p1, const void *p2);
int (*PolyCompare)(const void *p1, const Value& p2);
};
protected:
@ -164,6 +170,8 @@ protected:
String GetName() const;
int PolyCompare(const Value& v) const;
#if defined(_DEBUG) && defined(COMPILER_GCC)
uint32 magic[4];
void Magic() { magic[0] = 0xc436d851; magic[1] = 0x72f67c76; magic[2] = 0x3e5e10fd; magic[3] = 0xc90d370b; }
@ -217,6 +225,12 @@ public:
bool operator!=(const Value& v) const { return !operator==(v); }
bool IsSame(const Value& v) const;
int Compare(const Value& v) const;
bool operator<=(const Value& x) const { return Compare(x) <= 0; }
bool operator>=(const Value& x) const { return Compare(x) >= 0; }
bool operator<(const Value& x) const { return Compare(x) < 0; }
bool operator>(const Value& x) const { return Compare(x) > 0; }
String ToString() const;
String GetTypeName() const { return GetName(); }
@ -250,7 +264,7 @@ template <class T> Value SvoToValue(const T& x) { return Value(x, Val
template <class T> Value RichToValue(const T& data);
template <class T> Value RawToValue(const T& data);
template <class T> Value RawPickToValue(pick_ T& data);
template <class T> Value RawPickToValue(T rval_ data);
template <class T> Value RawDeepToValue(const T& data);
template <class T> T& CreateRawValue(Value& v);

View file

@ -37,6 +37,57 @@ inline bool IsPolyEqual(const WString& x, const Value& v) {
return v.GetType() == STRING_V && WString(v) == x;
}
template<class T>
inline int PolyCompare(const T& a, const Value& b)
{
return a.PolyCompare(b);
}
template<>
inline int PolyCompare(const WString& x, const Value& v) {
return IsString(v) && SgnCompare(x, WString(v));
}
template<>
inline int PolyCompare(const String& x, const Value& v) {
return IsString(v) && SgnCompare((WString)x, (WString)v);
}
template<>
inline int PolyCompare(const bool& x, const Value& v) {
return v.Is<int64>() ? SgnCompare((int64)x, (int64)v)
: IsNumber(v) ? SgnCompare((double)x, (double)v)
: 0;
}
template<>
inline int PolyCompare(const int& x, const Value& v) {
return v.Is<int64>() ? SgnCompare((int64)x, (int64)v)
: IsNumber(v) ? SgnCompare((double)x, (double)v)
: 0;
}
template<>
inline int PolyCompare(const int64& x, const Value& v) {
return v.Is<double>() ? SgnCompare((double)x, (double)v)
: IsNumber(v) ? SgnCompare((int64)x, (int64)v)
: 0;
}
inline int PolyCompare(const double& x, const Value& v) {
return IsNumber(v) ? SgnCompare((double)x, (double)v) : 0;
}
template<>
inline int PolyCompare(const Date& x, const Value& v) {
return v.Is<Time>() && SgnCompare(ToTime(x), Time(v));
}
template<>
inline int PolyCompare(const Time& x, const Value& v) {
return v.Is<Date>() && SgnCompare(ToTime(x), Time(v));
}
template<>
inline unsigned ValueGetHashValue(const bool& x) {
return UPP::GetHashValue((int64)x);
@ -78,10 +129,10 @@ public:
const T& Get() const { return v; }
T& Get() { return v; }
RawValueRep(const T& v) : v(v) {}
RawValueRep(pick_ T& v, VPICK) : v(v) {}
RawValueRep(const T& v, VDEEP) : v(v, 1) {}
RawValueRep() {}
RawValueRep(const T& v) : v(v) {}
RawValueRep(T rval_ v, VPICK) : v(pick(v)) {}
RawValueRep(const T& v, VDEEP) : v(v, 1) {}
RawValueRep() {}
};
template <class T>
@ -96,6 +147,9 @@ public:
return static_cast<const RawValueRep<T> *>(p)->Get() == this->v; }
virtual bool IsPolyEqual(const Value& b) { return UPP::IsPolyEqual(this->v, b); }
virtual String AsString() const { return UPP::AsString(this->v); }
virtual int Compare(const Value::Void *p) { ASSERT(dynamic_cast<const RawValueRep<T> *>(p));
return SgnCompare(this->v, static_cast<const RawValueRep<T> *>(p)->Get()); }
virtual int PolyCompare(const Value& b) { return Upp::PolyCompare(this->v, b); }
RichValueRep(const T& v) : RawValueRep<T>(v) {}
RichValueRep() {}
@ -113,13 +167,16 @@ struct SvoFn {
static bool IsEqual(const void *p1, const void *p2) { return *(T*)p1 == *(T*)p2; }
static bool IsPolyEqual(const void *p, const Value& v) { return UPP::IsPolyEqual(*(T*)p, v); }
static String AsString(const void *p) { return UPP::AsString(*(T*)p); }
static int Compare(const void *p1, const void *p2) { return SgnCompare(*(T*)p1, *(T*)p2); }
static int PolyCompare(const void *p1, const Value& p2) { return UPP::PolyCompare(*(T*)p1, p2); }
};
#define SVO_FN(id, T) \
static Value::Sval id = { \
SvoFn<T>::IsNull, SvoFn<T>::Serialize, SvoFn<T>::Xmlize, SvoFn<T>::Jsonize, \
SvoFn<T>::GetHashValue, SvoFn<T>::IsEqual, \
SvoFn<T>::IsPolyEqual, SvoFn<T>::AsString \
SvoFn<T>::IsPolyEqual, SvoFn<T>::AsString, \
SvoFn<T>::Compare, SvoFn<T>::PolyCompare \
};
template <class T>
@ -276,10 +333,10 @@ inline Value RawToValue(const T& data)
}
template <class T>
inline Value RawPickToValue(pick_ T& data)
inline Value RawPickToValue(T rval_ data)
{
typedef RawValueRep<T> R;
return Value(new R(data, R::PICK));
return Value(new R(pick(data), R::PICK));
}
template <class T>

View file

@ -80,11 +80,21 @@ bool ValueArray::Data::IsEqual(const Value::Void *p)
return sCmp(((Data *)p)->data, data);
}
int ValueArray::Data::Compare(const Value::Void *p)
{
return CompareArray(data, ((Data *)p)->data);
}
bool ValueArray::operator==(const ValueArray& v) const
{
return sCmp(data->data, v.data->data);
}
int ValueArray::Compare(const ValueArray& b) const
{
return CompareArray(data->data, b.data->data);
}
static String sAsString(const Vector<Value>& v)
{
String s;
@ -129,9 +139,9 @@ ValueArray::ValueArray(const ValueArray& v) {
data->Retain();
}
ValueArray::ValueArray(pick_ Vector<Value>& v)
ValueArray::ValueArray(Vector<Value> rval_ v)
{
Create() = v;
Create() = pick(v);
}
ValueArray::ValueArray(const Vector<Value>& v, int deep)
@ -327,7 +337,8 @@ unsigned ValueMap::Data::GetHashValue() const {
return w;
}
static bool sIsEqual(const Index<Value>& a, const Index<Value>& b) {
static bool sIsEqual(const Index<Value>& a, const Index<Value>& b)
{
if(&a == &b) return true;
if(a.GetCount() != b.GetCount()) return false;
for(int i = 0; i < a.GetCount(); i++) {
@ -336,14 +347,36 @@ static bool sIsEqual(const Index<Value>& a, const Index<Value>& b) {
return true;
}
bool ValueMap::Data::IsEqual(const Value::Void *p) {
bool ValueMap::Data::IsEqual(const Value::Void *p)
{
return sIsEqual(((Data *)p)->key, key) && ((Data *)p)->value == value;
}
bool ValueMap::operator==(const ValueMap& v) const {
bool ValueMap::operator==(const ValueMap& v) const
{
return sIsEqual(data->key, v.data->key) && data->value == v.data->value;
}
int ValueMap::Data::Compare(const Value::Void *p)
{
Data *b = (Data *)p;
int n = min(key.GetCount(), b->key.GetCount());
for(int i = 0; i < n; i++) {
int q = SgnCompare(key[i], b->key[i]);
if(q)
return q;
q = SgnCompare(value[i], b->value[i]);
if(q)
return q;
}
return SgnCompare(key.GetCount(), b->key.GetCount());
}
int ValueMap::Compare(const ValueMap& b) const
{
return data->Compare((Value::Void *)b.data);
}
String ValueMap::Data::AsString() const
{
String s;
@ -391,11 +424,11 @@ ValueMap::ValueMap(const ValueMap& v)
data->Retain();
}
ValueMap::ValueMap(pick_ Index<Value>& k, pick_ Vector<Value>& v)
ValueMap::ValueMap(Index<Value> rval_ k, Vector<Value> rval_ v)
{
Data& d = Create();
d.key = k;
d.value = ValueArray(v);
d.key = pick(k);
d.value = ValueArray(pick(v));
}
ValueMap::ValueMap(const Index<Value>& k, const Vector<Value>& v, int deep)
@ -403,7 +436,7 @@ ValueMap::ValueMap(const Index<Value>& k, const Vector<Value>& v, int deep)
Data& d = Create();
d.key <<= k;
Vector<Value> _v(v, 0);
d.value = ValueArray(_v);
d.value = ValueArray(pick(_v));
}
ValueMap::operator Value() const {

View file

@ -196,6 +196,7 @@ class ValueArray : public ValueType<ValueArray, VALUEARRAY_V, Moveable<ValueArra
virtual unsigned GetHashValue() const;
virtual bool IsEqual(const Value::Void *p);
virtual String AsString() const;
virtual int Compare(const Value::Void *p);
int GetRefCount() const { return AtomicRead(refcount); }
@ -215,7 +216,7 @@ class ValueArray : public ValueType<ValueArray, VALUEARRAY_V, Moveable<ValueArra
public:
ValueArray() { Init0(); }
ValueArray(const ValueArray& v);
explicit ValueArray(pick_ Vector<Value>& values);
explicit ValueArray(Vector<Value> rval_ values);
explicit ValueArray(const Vector<Value>& values, int deep);
~ValueArray();
@ -254,8 +255,14 @@ public:
void Xmlize(XmlIO& xio);
String ToString() const;
bool operator==(const ValueArray& v) const;
bool operator!=(const ValueArray& v) const { return !operator==(v); }
bool operator==(const ValueArray& v) const;
bool operator!=(const ValueArray& v) const { return !operator==(v); }
int Compare(const ValueArray& b) const;
bool operator<=(const ValueArray& x) const { return Compare(x) <= 0; }
bool operator>=(const ValueArray& x) const { return Compare(x) >= 0; }
bool operator<(const ValueArray& x) const { return Compare(x) < 0; }
bool operator>(const ValueArray& x) const { return Compare(x) > 0; }
};
template<>
@ -271,6 +278,7 @@ class ValueMap : public ValueType<ValueMap, VALUEMAP_V, Moveable<ValueMap> >{
virtual unsigned GetHashValue() const;
virtual bool IsEqual(const Value::Void *p);
virtual String AsString() const;
virtual int Compare(const Value::Void *p);
const Value& Get(const Value& key) const;
@ -291,7 +299,7 @@ class ValueMap : public ValueType<ValueMap, VALUEMAP_V, Moveable<ValueMap> >{
public:
ValueMap() { Init0(); }
ValueMap(const ValueMap& v);
ValueMap(pick_ Index<Value>& k, pick_ Vector<Value>& v);
ValueMap(Index<Value> rval_ k, Vector<Value> rval_ v);
ValueMap(const Index<Value>& k, const Vector<Value>& v, int deep);
~ValueMap();
@ -364,6 +372,12 @@ public:
bool operator==(const ValueMap& v) const;
bool operator!=(const ValueMap& v) const { return !operator==(v); }
int Compare(const ValueMap& b) const;
bool operator<=(const ValueMap& x) const { return Compare(x) <= 0; }
bool operator>=(const ValueMap& x) const { return Compare(x) >= 0; }
bool operator<(const ValueMap& x) const { return Compare(x) < 0; }
bool operator>(const ValueMap& x) const { return Compare(x) > 0; }
};
class ValueGen {

View file

@ -19,31 +19,31 @@ class Vector : public MoveableAndDeepCopyOption< Vector<T> > {
static T *RawAlloc(int& n);
#ifdef _DEBUG
static Vector& SetPicked(pick_ Vector& v) { BreakWhenPicked((void *)&v); Vector& p = (Vector&)(v); p.items = -1; p.vector = NULL; return p; }
static Vector& SetPicked(Vector rval_ v) { BreakWhenPicked((void *)&v); Vector& p = (Vector&)(v); p.items = -1; p.vector = NULL; return p; }
#else
static Vector& SetPicked(pick_ Vector& v) { Vector& p = (Vector&)(v); p.items = -1; p.vector = NULL; return p; }
static Vector& SetPicked(Vector rval_ v) { Vector& p = (Vector&)(v); p.items = -1; p.vector = NULL; return p; }
#endif
void Pick(pick_ Vector<T>& v);
void Pick(Vector<T> rval_ v);
T *Rdd() { return vector + items++; }
void Free();
void __DeepCopy(const Vector& src);
T& Get(int i) const { ASSERT(i >= 0 && i < items); return vector[i]; }
void Chk() const { ASSERT_(items >= 0, "Broken pick semantics"); }
void Chk() const { ASSERT_(items >= 0, "Broken rval_ semantics"); }
void ReAlloc(int alloc);
void ReAllocF(int alloc);
void Grow();
void GrowF();
T& GrowAdd(const T& x);
T& GrowAddPick(pick_ T& x);
T& GrowAddPick(T rval_ x);
void RawInsert(int q, int count);
public:
T& Add() { Chk(); if(items >= alloc) GrowF(); return *(::new(vector + items++) T); }
T& Add(const T& x) { Chk(); return items < alloc ? DeepCopyConstruct(Rdd(), x) : GrowAdd(x); }
T& AddPick(pick_ T& x) { Chk(); return items < alloc ? *(::new(Rdd()) T(x)) : GrowAddPick(x); }
T& AddPick(T rval_ x) { Chk(); return items < alloc ? *(::new(Rdd()) T(pick(x))) : GrowAddPick(pick(x)); }
void AddN(int n);
const T& operator[](int i) const { return Get(i); }
T& operator[](int i) { return Get(i); }
@ -72,14 +72,14 @@ public:
T& Insert(int i) { InsertN(i); return Get(i); }
void Insert(int i, const T& x, int count);
T& Insert(int i, const T& x) { Insert(i, x, 1); return Get(i); }
T& InsertPick(int i, pick_ T& x);
T& InsertPick(int i, T rval_ x);
void Insert(int i, const Vector& x);
void Insert(int i, const Vector& x, int offset, int count);
void InsertPick(int i, pick_ Vector& x);
void InsertPick(int i, Vector rval_ x);
void InsertSplit(int i, Vector<T>& v, int from);
void Append(const Vector& x) { Insert(GetCount(), x); }
void Append(const Vector& x, int o, int c) { Insert(GetCount(), x, o, c); }
void AppendPick(pick_ Vector& x) { InsertPick(GetCount(), x); }
void AppendPick(Vector rval_ x) { InsertPick(GetCount(), pick(x)); }
int GetIndex(const T& item) const; //deprecated
void Swap(int i1, int i2) { UPP::Swap(Get(i1), Get(i2)); }
@ -92,12 +92,20 @@ public:
operator const T*() const { return (T*)vector; }
Vector& operator<<(const T& x) { Add(x); return *this; }
Vector& operator|(pick_ T& x) { AddPick(x); return *this; }
Vector& operator|(T rval_ x) { AddPick(x); return *this; }
#ifdef UPP
void Serialize(Stream& s) { StreamContainer(s, *this); }
void Xmlize(XmlIO& xio, const char *itemtag = "item");
void Jsonize(JsonIO& jio);
String ToString() const;
bool operator==(const Vector<T>& b) const { return IsEqualArray(*this, b); }
bool operator!=(const Vector<T>& b) const { return !operator==(b); }
int Compare(const Vector<T>& b) const { return CompareArray(*this, b); }
bool operator<=(const Vector<T>& x) const { return Compare(x) <= 0; }
bool operator>=(const Vector<T>& x) const { return Compare(x) >= 0; }
bool operator<(const Vector<T>& x) const { return Compare(x) < 0; }
bool operator>(const Vector<T>& x) const { return Compare(x) > 0; }
#endif
Vector() { vector = NULL; items = alloc = 0; }
@ -108,15 +116,19 @@ public:
// << ", " << typeid(T).name()); //TODO remove
Free();
return; // Constraints:
T t(*vector); // T must have transfer constructor (also GCC 4.0 bug workaround)
T t(pick(*vector)); // T must have transfer constructor (also GCC 4.0 bug workaround)
AssertMoveable(&t); // T must be moveable
}
// Pick assignment & copy. Picked source can only do Clear(), ~Vector(), operator=, operator <<=
Vector(pick_ Vector& v) { Pick(v); }
void operator=(pick_ Vector& v) { Free(); Pick(v); }
Vector(Vector rval_ v) { Pick(pick(v)); }
void operator=(Vector rval_ v) { Free(); Pick(pick(v)); }
bool IsPicked() const { return items < 0; }
#ifdef CPP_11
void Insert(int i, std::initializer_list<T> init);
#endif
// Deep copy
Vector(const Vector& v, int) { __DeepCopy(v); }
@ -169,7 +181,7 @@ protected:
public:
T& Add() { T *q = new T; vector.Add(q); return *q; }
T& Add(const T& x) { T *q = DeepCopyNew(x); vector.Add(q); return *q; }
T& AddPick(pick_ T& x) { T *q = new T(x); vector.Add(q); return *q; }
T& AddPick(T rval_ x) { T *q = new T(pick(x)); vector.Add(q); return *q; }
T& Add(T *newt) { vector.Add(newt); return *newt; }
template<class TT> TT& Create() { TT *q = new TT; Add(q); return *q; }
const T& operator[](int i) const { return Get(i); }
@ -199,13 +211,13 @@ public:
T& Insert(int i) { InsertN(i); return Get(i); }
void Insert(int i, const T& x, int count);
T& Insert(int i, const T& x) { Insert(i, x, 1); return Get(i); }
T& InsertPick(int i, pick_ T& x);
T& InsertPick(int i, T rval_ x);
void Insert(int i, const Array& x);
void Insert(int i, const Array& x, int offset, int count);
void Append(const Array& x) { Insert(GetCount(), x); }
void Append(const Array& x, int o, int c) { Insert(GetCount(), x, o, c); }
void InsertPick(int i, pick_ Array& x) { vector.InsertPick(i, x.vector); }
void AppendPick(pick_ Array& x) { InsertPick(GetCount(), x); }
void InsertPick(int i, Array rval_ x) { vector.InsertPick(i, pick(x.vector)); }
void AppendPick(Array rval_ x) { InsertPick(GetCount(), pick(x)); }
int GetIndex(const T& item) const;
void Swap(int i1, int i2) { UPP::Swap(vector[i1], vector[i2]); }
void Move(int i1, int i2);
@ -225,7 +237,7 @@ public:
Array& operator<<(const T& x) { Add(x); return *this; }
Array& operator<<(T *newt) { Add(newt); return *this; }
Array& operator|(pick_ T& x) { AddPick(x); return *this; }
Array& operator|(T rval_ x) { AddPick(x); return *this; }
bool IsPicked() const { return vector.IsPicked(); }
@ -233,14 +245,22 @@ public:
void Serialize(Stream& s) { StreamContainer(s, *this); }
void Xmlize(XmlIO& xio, const char *itemtag = "item");
void Jsonize(JsonIO& jio);
String ToString() const;
bool operator==(const Array<T>& b) const { return IsEqualArray(*this, b); }
bool operator!=(const Array<T>& b) const { return !operator==(b); }
int Compare(const Array<T>& b) const { return CompareArray(*this, b); }
bool operator<=(const Array<T>& x) const { return Compare(x) <= 0; }
bool operator>=(const Array<T>& x) const { return Compare(x) >= 0; }
bool operator<(const Array<T>& x) const { return Compare(x) < 0; }
bool operator>(const Array<T>& x) const { return Compare(x) > 0; }
#endif
Array() {}
~Array() { Free(); }
// Pick assignment & copy. Picked source can only Clear(), ~Vector(), operator=, operator<<=
Array(pick_ Array& v) : vector(v.vector) {}
void operator=(pick_ Array& v) { Free(); vector = v.vector; }
Array(Array rval_ v) : vector(pick(v.vector)) {}
void operator=(Array rval_ v) { Free(); vector = pick(v.vector); }
// Deep copy
Array(const Array& v, int) { __DeepCopy(v); }
@ -376,7 +396,7 @@ protected:
public:
T& Add() { return *::new(Add0()) T; }
T& Add(const T& x) { return DeepCopyConstruct(Add0(), x); }
T& AddPick(pick_ T& x) { return *(::new(Add0()) T(x)); }
T& AddPick(T rval_ x) { return *(::new(Add0()) T(x)); }
T& operator[](int i) { return Get(i); }
const T& operator[](int i) const { return Get(i); }
int GetCount() const { return items; }
@ -401,7 +421,7 @@ public:
void Swap(Segtor& b) { block.Swap(b.block); Swap(items, b.items); }
Segtor& operator<<(const T& x) { Add(x); return *this; }
Segtor& operator|(pick_ T& x) { AddPick(x); return *this; }
Segtor& operator|(T rval_ x) { AddPick(x); return *this; }
bool IsPicked() const { return block.IsPicked(); }
@ -410,7 +430,7 @@ public:
#endif
Segtor() { items = 0; }
Segtor(pick_ Segtor& s) : block(s.block), items(s.items) {}
Segtor(Segtor rval_ s) : block(s.block), items(s.items) {}
Segtor(const Segtor& s, int);
~Segtor();

View file

@ -38,12 +38,12 @@ void Vector<T>::GrowF()
}
template <class T>
void Vector<T>::Pick(pick_ Vector<T>& v)
void Vector<T>::Pick(Vector<T> rval_ v)
{
vector = v.vector;
items = v.items;
alloc = v.alloc;
SetPicked(v);
SetPicked(pick(v));
}
template <class T>
@ -99,11 +99,11 @@ T& Vector<T>::GrowAdd(const T& x) {
}
template <class T>
T& Vector<T>::GrowAddPick(pick_ T& x) {
T& Vector<T>::GrowAddPick(T rval_ x) {
T *prev = vector;
Grow();
T *q = Rdd();
::new(q) T(x);
::new(q) T(pick(x));
RawFree(prev);
return *q;
}
@ -200,11 +200,6 @@ void Vector<T>::Remove(int q, int count) {
items -= count;
}
template <int size>
class Data_S_ {
byte filler[size];
};
template <class T>
void Vector<T>::Remove(const int *sorted_list, int n)
{
@ -273,7 +268,7 @@ void Vector<T>::Insert(int q, const T& x, int count) {
}
template <class T>
T& Vector<T>::InsertPick(int q, pick_ T& x)
T& Vector<T>::InsertPick(int q, T rval_ x)
{
ASSERT(&x < vector || &x > vector + items);
RawInsert(q, 1);
@ -289,6 +284,17 @@ void Vector<T>::Insert(int q, const Vector& x, int offset, int count) {
DeepCopyConstructArray(vector + q, x.vector + offset, x.vector + offset + count);
}
#ifdef CPP_11
template <class T>
void Vector<T>::Insert(int i, std::initializer_list<T> init)
{
RawInsert(i, init.size());
T *t = vector + i;
for(auto q : init)
DeepCopyConstruct(t++, q);
}
#endif
template <class T>
void Vector<T>::Insert(int q, const Vector& x) {
if(!x.GetCount()) return;
@ -296,7 +302,7 @@ void Vector<T>::Insert(int q, const Vector& x) {
}
template <class T>
void Vector<T>::InsertPick(int i, pick_ Vector<T>& v) {
void Vector<T>::InsertPick(int i, Vector<T> rval_ v) {
Chk();
v.Chk();
ASSERT(!vector || v.vector != vector);
@ -305,7 +311,7 @@ void Vector<T>::InsertPick(int i, pick_ Vector<T>& v) {
memcpy(vector + i, v.vector, sizeof(T) * v.items);
}
RawFree(v.vector);
SetPicked(v);
SetPicked(pick(v));
}
template <class T>
@ -350,6 +356,27 @@ void Vector<T>::Jsonize(JsonIO& jio)
{
JsonizeArray<Vector<T>, T>(jio, *this);
}
template <class C>
String AsStringArray(const C& v)
{
String r;
r << '[';
for(int i = 0; i < v.GetCount(); i++) {
if(i)
r << ", ";
r << v[i];
}
r << ']';
return r;
}
template <class T>
String Vector<T>::ToString() const
{
return AsStringArray(*this);
}
#endif
// ------------------
@ -477,10 +504,10 @@ void Array<T>::Insert(int i, const T& x, int count) {
}
template <class T>
T& Array<T>::InsertPick(int i, pick_ T& x)
T& Array<T>::InsertPick(int i, T rval_ x)
{
vector.InsertN(i, 1);
vector[i] = new T(x);
vector[i] = new T(pick(x));
return Get(i);
}
@ -515,6 +542,13 @@ void Array<T>::Jsonize(JsonIO& jio)
{
JsonizeArray<Array<T>, T>(jio, *this);
}
template <class T>
String Array<T>::ToString() const
{
return AsStringArray(*this);
}
#endif
// ------------------
@ -744,6 +778,13 @@ void BiVector<T>::Serialize(Stream& s) {
for(int i = 0; i < items; i++)
s % operator[](i);
}
template <class T>
String BiVector<T>::ToString() const
{
return AsStringArray(*this);
}
#endif
// ------------------
@ -778,4 +819,11 @@ void BiArray<T>::Serialize(Stream& s) {
for(int i = 0; i < bv.GetCount(); i++)
s % operator[](i);
}
template <class T>
String BiArray<T>::ToString() const
{
return AsStringArray(*this);
}
#endif

View file

@ -472,7 +472,7 @@ String XmlParser::ReadTag(bool next)
String h = tagtext;
if(next) {
stack.Add(Nesting(h, npreserve));
attr = nattr;
attr = pick(nattr);
attr1 = nattr1;
attrval1 = nattrval1;
Next();
@ -485,7 +485,7 @@ bool XmlParser::Tag(const char *tag)
if(IsTag() && tagtext == tag) {
LLOG("Tag " << tagtext);
stack.Add(Nesting(tagtext, npreserve));
attr = nattr;
attr = pick(nattr);
attr1 = nattr1;
attrval1 = nattrval1;
Next();
@ -499,7 +499,7 @@ bool XmlParser::Tag(const String& tag)
if(IsTag() && tagtext == tag) {
LLOG("Tag " << tagtext);
stack.Add(Nesting(tagtext, npreserve));
attr = nattr;
attr = pick(nattr);
attr1 = nattr1;
attrval1 = nattrval1;
Next();
@ -584,11 +584,11 @@ bool XmlParser::LoopTag(const char *tag)
return false;
}
VectorMap<String, String> XmlParser::PickAttrs() pick_
VectorMap<String, String> XmlParser::PickAttrs()
{
if(!IsNull(attr1))
const_cast<VectorMap<String, String>&>(attr).Insert(0, attr1, attrval1);
return attr;
pick(const_cast<VectorMap<String, String>&>(attr).Insert(0, attr1, attrval1));
return pick(attr);
}
int XmlParser::Int(const char *id, int def) const
@ -830,14 +830,14 @@ XmlNode& XmlNode::SetAttr(const char *id, const String& text)
return *this;
}
void XmlNode::SetAttrsPick(pick_ VectorMap<String, String>& a)
void XmlNode::SetAttrsPick(VectorMap<String, String> rval_ a)
{
if(a.GetCount() == 0)
attr.Clear();
else {
if(!attr)
attr.Create();
*attr = a;
*attr = pick(a);
}
}
@ -891,7 +891,7 @@ static XmlNode sReadXmlNode(XmlParser& p, ParseXmlFilter *filter, dword style)
if(!Ignore(p, style)) {
XmlNode n = sReadXmlNode(p, filter, style);
if(n.GetType() != XML_DOC) // tag was ignored
m.Add() = n;
m.Add() = pick(n);
}
if(filter)
filter->EndTag();

View file

@ -148,7 +148,7 @@ public:
void Skip();
void SkipEnd();
VectorMap<String, String> PickAttrs() pick_;
VectorMap<String, String> PickAttrs();
int GetLine() const { return line; }
int GetColumn() const { return GetColumn0() + 1; }
@ -212,12 +212,14 @@ public:
int AttrInt(const char *id, int def = Null) const;
XmlNode& SetAttr(const char *id, int val);
void SetAttrsPick(pick_ VectorMap<String, String>& a);
void SetAttrsPick(VectorMap<String, String> rval_ a);
void Shrink();
bool IsPicked() const { return node.IsPicked(); }
rval_default(XmlNode);
XmlNode(const XmlNode& n, int);
XmlNode() { type = XML_DOC; }

View file

@ -132,3 +132,7 @@
#ifdef flagCLR
#define flagUSEMALLOC
#endif
#if __cplusplus >= 201100
#define CPP_11
#endif

View file

@ -130,30 +130,6 @@ st]_[*@4 K][@(0.0.255) `&]_[*@3 k])&]
[s2; Removes all elements with key [%-*@3 k].&]
[s3; &]
[s4; &]
[s5;:SortedAMap`:`:Drop`(int`):%- [@(0.0.255) void]_[* Drop]([@(0.0.255) int]_[*@3 n]_`=_[@3 1])
&]
[s2; Removes [%-*@3 n] last elements.&]
[s3; &]
[s4; &]
[s5;:SortedAMap`:`:Top`(`):%- [*@4 T][@(0.0.255) `&]_[* Top]()&]
[s5;:SortedAMap`:`:Top`(`)const:%- [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[* Top]()_[@(0.0.255) c
onst]&]
[s2; Returns the value of the last element.&]
[s3; &]
[s4; &]
[s5;:SortedAMap`:`:TopKey`(`)const:%- [@(0.0.255) const]_[*@4 K][@(0.0.255) `&]_[* TopKey]()_
[@(0.0.255) const]&]
[s2; Returns the key of the last element.&]
[s3; &]
[s4; &]
[s5;:SortedAMap`:`:PopKey`(`):%- [*@4 K]_[* PopKey]()&]
[s2; Returns the last key and drops it.&]
[s3; &]
[s4; &]
[s5;:SortedAMap`:`:Trim`(int`):%- [@(0.0.255) void]_[* Trim]([@(0.0.255) int]_[*@3 n])&]
[s2; Same as Remove(GetCount() `- [%-*@3 n], [%-*@3 n]).&]
[s3; &]
[s4; &]
[s5;:SortedAMap`:`:Swap`(SortedAMap`&`):%- [@(0.0.255) void]_[* Swap]([_^SortedAMap^ Sorted
AMap][@(0.0.255) `&]_[*@3 x])&]
[s2; Swaps this SortedAMap with another one.&]

View file

@ -89,11 +89,6 @@ from [%-*@3 x].&]
[s2; Removes element at [%-*@3 i] and returns the pointer to value.
This pointer should be deleted by client code.&]
[s3; &]
[s4; &]
[s5;:SortedArrayMap`:`:PopDetach`(`):%- [*@4 T]_`*[* PopDetach]()&]
[s2; Removes the last element and returns the pointer to value. This
pointer should be deleted by client code.&]
[s3; &]
[s4;%- &]
[s5;:SortedArrayMap`:`:operator`(`)`(const K`&`,const T`&`):%- [_^SortedArrayMap^ Sorte
dArrayMap][@(0.0.255) `&]_[* operator()]([@(0.0.255) const]_[*@4 K][@(0.0.255) `&]_[*@3 k],

View file

@ -441,6 +441,31 @@ as part of expression like Foo((Vector<int>() << 1 << 2 << 4)).&]
[s7; [*/ Return value]-|Reference to Vector (`*this).&]
[s3;%- &]
[s4;%- &]
[s5;:Vector`:`:ToString`(`)const:%- [_^String^ String]_[* ToString]()_[@(0.0.255) const]&]
[s2; Converts container into String, mostly for debugging purposes.&]
[s3;%- &]
[s4;%- &]
[s5;:Vector`:`:operator`=`=`(const Vector`<T`>`&`)const:%- [@(0.0.255) bool]_[* operator`=
`=]([@(0.0.255) const]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s5;:Vector`:`:operator`!`=`(const Vector`<T`>`&`)const:%- [@(0.0.255) bool]_[* operator!
`=]([@(0.0.255) const]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s2; Compares two containers for (in)equality, using T`::operator`=`=.&]
[s3; &]
[s4;%- &]
[s5;:Vector`:`:Compare`(const Vector`<T`>`&`)const:%- [@(0.0.255) int]_[* Compare]([@(0.0.255) c
onst]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s5;:Vector`:`:operator`<`=`(const Vector`<T`>`&`)const:%- [@(0.0.255) bool]_[* operator<
`=]([@(0.0.255) const]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s5;:Vector`:`:operator`>`=`(const Vector`<T`>`&`)const:%- [@(0.0.255) bool]_[* operator>
`=]([@(0.0.255) const]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s5;:Vector`:`:operator`<`(const Vector`<T`>`&`)const:%- [@(0.0.255) bool]_[* operator<](
[@(0.0.255) const]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s5;:Vector`:`:operator`>`(const Vector`<T`>`&`)const:%- [@(0.0.255) bool]_[* operator>](
[@(0.0.255) const]_[_^Vector^ Vector]<[*@4 T]>`&_[*@3 b])_[@(0.0.255) const]&]
[s2; Lexicographically compares two containers, using SgnCompare
for elements.&]
[s3; &]
[s4;%- &]
[s5;:Vector`:`:operator`|`(pick`_ T`&`):%- [_^Vector^ Vector][@(0.0.255) `&]_[* operator`|](
[@(0.128.128) pick`_]_[*@4 T][@(0.0.255) `&]_[*@3 x])&]
[s2; Operator replacement of [* void AddPick(pick`_ T`&x)]. By returning

View file

@ -1,18 +1,241 @@
TITLE("Moveable")
COMPRESSED
120,156,237,90,107,115,219,54,22,253,43,152,113,182,149,29,90,33,248,16,41,169,77,155,56,201,76,102,242,232,108,220,246,131,71,83,65,36,100,177,166,72,45,31,146,189,109,243,219,247,92,0,124,72,150,147,204,108,183,253,178,73,155,68,36,238,197,125,158,123,0,249,202,97,143,30,217,150,125,98,127,230,215,228,133,92,138,58,173,102,87,169,19,134,211,36,176,189,169,224,193,244,253,120,250,241,227,199,225,120,236,76,73,21,135,42,110,123,46,119,56,247,108,219,115,2,238,143,237,177,31,242,208,118,3,207,241,3,219,159,108,68,33,214,179,43,17,186,211,179,127,142,32,229,88,254,137,203,93,110,243,145,227,97,149,237,218,142,199,29,159,135,161,199,3,63,116,199,163,209,36,18,155,42,201,179,217,213,130,228,104,51,23,98,118,16,142,60,14,33,207,119,220,192,247,32,236,121,156,227,223,220,15,70,65,48,169,146,42,149,16,226,163,96,42,60,103,122,65,146,158,53,58,129,121,78,0,81,207,241,70,158,27,58,46,15,29,103,52,118,189,177,7,187,185,51,
73,42,9,43,23,144,33,57,18,243,177,161,231,123,220,69,64,188,192,119,177,44,192,223,158,61,230,14,118,13,109,223,199,134,242,182,137,18,5,136,228,70,216,206,9,124,90,29,122,33,119,131,208,241,156,145,3,3,236,0,94,210,238,254,36,150,101,4,57,215,225,211,10,38,77,47,190,247,167,28,194,129,21,156,56,246,216,118,70,193,24,27,194,88,56,236,142,199,220,13,177,161,199,125,155,187,147,40,143,201,73,199,183,93,181,99,136,60,140,160,89,197,196,31,113,24,236,184,33,182,12,184,235,226,79,223,11,131,73,41,41,19,85,94,204,174,206,190,31,216,67,123,232,248,254,41,137,143,33,30,186,158,235,122,163,177,199,109,23,219,64,135,71,241,26,217,200,37,247,157,112,178,16,37,246,172,60,138,172,138,42,167,66,66,224,221,208,119,177,245,8,127,32,169,112,208,69,108,156,177,23,186,110,104,79,162,84,148,101,47,64,103,228,36,231,22,231,39,1,197,213,119,29,111,76,193,113,29,4,216,25,249,99,142,8,251,35,207,118,38,133,252,87,157,20,114,
45,51,132,56,65,109,76,155,244,152,58,132,49,186,14,29,139,59,168,68,127,52,178,41,94,62,170,193,113,125,4,220,230,161,7,139,240,27,41,174,76,41,46,58,31,92,139,187,39,99,199,115,97,201,216,243,16,1,40,224,99,206,185,29,226,55,60,67,92,84,109,112,152,160,156,208,219,107,113,207,226,222,73,128,26,70,166,198,30,109,63,118,41,126,14,194,239,140,108,31,121,112,180,184,67,81,119,30,33,238,220,9,233,127,21,121,238,91,28,205,0,19,185,239,195,111,23,161,118,66,248,238,35,246,174,170,111,30,132,147,119,114,87,190,16,149,52,5,115,118,241,72,87,26,31,89,124,116,98,147,188,31,142,145,64,238,81,252,92,207,27,59,99,215,245,157,177,239,142,108,196,177,212,189,76,194,212,79,170,23,91,37,129,197,3,116,22,124,245,125,120,175,196,224,121,192,201,20,39,28,143,40,10,70,201,252,60,77,50,178,3,149,49,213,197,112,118,241,152,243,128,20,133,104,152,48,28,217,238,24,193,64,12,108,31,149,14,52,8,145,104,228,217,65,27,16,
28,68,55,226,90,206,207,77,171,254,246,203,31,255,120,249,238,252,199,15,236,170,116,166,236,109,190,149,98,145,202,175,102,87,165,223,125,100,81,158,69,114,83,177,66,110,96,9,42,162,100,168,200,36,98,189,34,97,203,188,96,213,221,70,150,172,68,157,203,152,37,25,251,73,70,248,55,91,166,98,139,191,242,37,105,170,4,156,40,74,54,200,196,90,166,119,102,141,197,158,39,205,191,94,103,177,188,101,34,139,205,187,183,98,115,58,100,151,57,147,183,155,20,210,108,183,18,21,75,240,95,169,86,237,86,119,230,83,153,179,100,189,201,139,74,192,160,84,86,172,46,217,50,41,202,138,69,133,68,14,153,96,91,89,220,177,77,145,172,147,42,217,74,179,3,69,246,70,118,214,49,20,13,182,170,84,36,130,105,251,145,125,163,90,138,93,62,53,47,244,199,15,216,52,149,198,217,249,111,230,221,249,239,151,140,205,207,182,234,241,180,125,152,192,52,0,172,136,146,234,110,255,41,149,106,217,60,106,223,108,243,36,102,87,103,236,229,237,6,206,14,78,103,253,29,206,
127,111,84,177,249,183,108,45,110,7,220,98,14,118,109,183,56,157,246,22,95,226,77,38,119,91,99,233,183,108,64,79,78,25,158,177,104,37,138,249,85,167,238,140,149,201,191,101,190,28,92,158,206,103,125,37,72,244,64,153,75,10,236,41,254,254,198,152,206,146,249,227,249,227,211,125,3,207,127,135,241,216,96,208,110,60,191,74,230,179,83,118,57,232,127,108,182,56,35,95,181,220,172,247,126,120,57,159,76,230,31,47,7,123,254,204,255,232,125,136,37,50,46,231,87,243,25,27,144,51,202,179,195,232,35,158,173,243,173,65,221,235,86,225,166,94,164,73,52,217,207,194,179,56,30,160,70,80,78,151,243,175,216,237,129,163,201,114,160,194,192,158,66,119,27,254,189,212,245,237,160,144,180,14,146,28,197,78,199,229,246,244,136,69,200,30,54,205,55,82,205,17,114,83,103,129,172,64,35,86,117,145,177,94,192,166,172,39,217,47,208,193,129,217,93,60,222,253,248,230,205,244,129,210,210,158,169,132,31,51,109,254,241,83,91,124,182,98,246,202,229,179,89,63,150,232,
7,19,57,255,99,106,224,236,114,5,132,64,54,250,150,206,52,88,1,71,226,24,144,5,197,107,5,111,0,153,106,37,105,245,214,172,91,203,245,2,192,176,76,100,26,15,217,235,37,189,47,36,129,78,150,179,53,116,48,96,4,98,69,250,0,177,172,68,236,36,48,104,89,145,178,78,145,117,196,4,250,116,199,226,28,53,7,83,18,236,223,134,190,46,147,236,186,171,33,178,163,90,229,176,64,121,163,63,144,17,26,18,179,10,54,149,144,7,238,205,207,217,66,70,162,46,101,39,206,102,6,177,73,84,100,37,171,114,128,222,230,142,109,69,90,227,33,16,186,13,193,178,200,215,42,8,121,145,92,39,153,72,41,4,57,192,83,0,74,73,144,222,161,136,97,185,72,211,60,2,60,198,44,207,36,153,38,9,102,75,80,72,38,22,24,34,48,7,202,129,160,145,30,21,4,55,100,141,218,90,53,84,81,235,65,65,51,132,28,219,212,197,38,47,165,113,83,164,0,118,99,48,249,121,47,130,173,87,151,100,216,74,108,229,125,221,168,64,36,7,219,138,34,102,23,84,
118,44,77,22,133,128,71,136,218,186,156,208,12,89,215,104,238,5,34,246,68,41,152,159,183,26,18,228,102,134,49,244,46,223,53,147,165,157,41,24,123,73,132,0,153,216,105,35,35,145,145,166,110,24,150,117,180,234,70,204,145,1,242,161,42,40,217,189,214,49,213,77,60,119,250,0,48,245,69,13,56,53,82,183,213,65,31,146,30,3,124,6,238,225,91,42,179,1,45,157,63,230,251,56,143,119,209,230,110,64,66,22,163,21,71,59,255,200,254,253,71,128,172,242,75,173,40,135,244,234,51,134,152,69,71,109,81,32,221,34,228,183,95,102,78,15,77,250,113,254,243,44,165,23,159,194,76,19,187,47,53,235,8,178,81,47,149,82,106,16,88,137,205,70,102,132,8,50,187,223,41,232,240,246,153,222,120,86,18,126,72,133,15,50,158,176,87,196,151,44,42,255,68,35,2,186,187,67,5,52,191,169,251,216,210,117,174,251,210,64,0,213,47,69,171,65,65,106,104,236,167,14,106,13,132,66,37,45,105,154,165,1,2,18,45,243,186,136,100,39,129,102,78,170,14,3,
117,120,103,67,246,12,136,171,132,137,148,21,86,31,31,147,108,155,223,192,112,156,241,250,168,98,118,35,155,107,122,137,224,146,82,242,173,217,173,69,253,22,240,26,175,135,236,69,46,9,232,21,235,68,164,215,108,39,85,40,118,162,212,122,88,138,151,240,236,226,135,31,89,116,23,17,142,255,74,88,2,15,214,66,81,203,38,156,192,183,236,218,0,25,180,84,171,2,136,34,118,2,48,186,231,21,2,115,135,167,223,177,159,21,180,47,97,93,89,73,17,147,14,168,164,93,141,210,29,169,175,211,24,195,9,177,20,140,116,17,62,23,72,204,146,2,126,232,207,252,235,195,164,168,73,208,203,138,38,214,37,204,89,193,186,56,41,41,191,59,146,58,168,75,10,120,47,214,223,177,15,168,67,146,233,40,118,210,96,97,3,90,127,59,155,110,248,216,223,200,164,91,154,59,67,2,8,51,90,101,22,107,254,54,156,171,39,254,0,13,122,144,5,253,245,108,183,9,237,127,199,116,255,207,87,129,234,175,20,25,146,13,40,192,90,1,46,151,92,103,68,54,151,34,50,60,
99,209,144,68,93,72,10,113,136,115,101,121,54,63,255,225,253,11,115,40,55,128,181,77,242,84,195,180,166,64,45,35,26,96,193,46,1,28,162,217,163,186,36,26,170,113,72,115,30,75,15,23,44,186,6,249,105,168,175,188,133,25,32,128,205,187,29,206,221,32,59,160,158,61,176,18,64,204,194,128,223,62,43,83,4,17,56,211,224,7,125,134,22,195,135,213,218,66,236,216,2,224,5,150,22,139,170,207,59,153,30,56,121,102,72,34,161,94,39,220,130,159,2,116,96,163,98,184,61,94,175,102,251,172,27,73,61,234,223,219,163,25,139,61,2,63,100,63,211,59,60,163,233,164,166,13,62,38,116,28,184,79,58,145,171,254,36,82,51,89,235,164,20,104,141,20,223,138,162,132,71,169,236,38,8,5,56,205,203,106,168,235,225,236,9,140,120,162,200,181,206,104,159,101,82,198,21,201,52,28,125,175,34,212,204,6,128,99,197,108,109,238,116,140,82,118,129,170,42,16,47,154,109,52,12,181,106,146,104,87,178,231,82,41,107,110,131,86,162,52,243,14,1,136,115,84,
77,181,34,194,12,21,250,56,69,171,11,137,224,203,44,146,101,147,178,124,241,43,220,165,211,141,76,151,140,106,155,134,251,252,107,144,125,81,208,140,125,57,188,30,154,38,208,1,99,111,146,236,166,223,153,250,243,217,166,144,219,135,232,48,45,65,59,155,95,56,25,211,226,22,44,250,103,98,181,178,209,120,218,95,186,233,173,235,218,81,31,30,149,147,77,40,172,246,132,165,35,61,63,39,215,225,151,216,43,80,182,83,211,121,1,218,116,163,66,33,111,19,77,27,82,108,15,207,159,33,240,138,25,16,97,162,65,171,35,216,222,173,149,172,92,105,21,88,80,167,233,50,81,201,36,94,211,102,69,37,110,162,109,77,184,111,79,223,3,184,94,87,72,144,97,46,234,84,4,78,1,8,40,170,90,29,231,212,225,145,74,180,121,68,247,204,122,10,15,15,52,61,111,223,64,221,0,108,4,154,78,85,243,146,74,234,118,129,100,55,20,111,43,138,68,168,195,236,94,37,29,232,124,151,247,203,4,102,108,114,117,130,213,82,230,224,244,137,234,41,235,133,126,220,50,55,
237,82,217,4,147,98,98,233,134,238,44,82,109,163,50,192,196,178,50,8,97,98,1,2,149,148,43,73,192,38,163,90,131,75,131,198,53,112,146,146,33,154,38,65,38,40,17,164,81,34,56,251,249,82,86,223,29,115,31,35,82,208,232,153,236,215,250,171,60,63,32,43,120,130,210,188,78,243,133,72,231,191,44,205,123,187,125,223,9,246,123,132,230,150,232,230,138,86,178,236,148,235,21,40,249,170,120,168,135,212,244,255,32,171,129,22,102,203,123,227,49,167,54,89,62,124,6,123,127,195,15,103,170,214,117,75,130,116,194,239,100,159,60,81,141,146,182,41,210,99,136,74,86,103,41,175,171,50,137,155,28,245,229,230,231,79,187,250,166,238,165,57,73,27,169,187,139,197,30,108,125,194,86,231,208,86,84,113,9,247,231,95,9,139,217,86,67,191,16,183,62,1,195,254,166,94,255,98,131,159,139,248,94,116,77,74,238,69,246,160,31,25,173,83,70,150,159,177,146,14,45,165,50,77,241,136,47,49,234,94,24,81,98,100,20,194,120,52,106,253,14,54,221,110,49,146,
249,95,25,232,30,26,216,235,173,163,209,107,44,237,160,72,75,180,241,252,19,140,242,168,203,192,175,5,74,2,20,226,192,66,243,116,72,221,72,230,29,175,191,246,142,41,6,0,41,66,6,60,52,129,237,193,221,159,20,208,254,141,234,125,224,195,196,43,151,196,246,150,34,33,98,145,138,226,26,4,169,110,120,150,194,78,2,229,8,166,16,154,98,205,58,47,171,62,102,151,236,46,175,25,186,163,104,24,37,213,10,57,73,142,137,222,247,52,125,226,166,169,166,38,81,164,229,128,197,188,165,77,218,111,135,44,197,118,222,93,190,233,127,37,133,249,78,50,247,72,18,221,249,237,100,51,65,153,92,46,17,89,58,218,154,177,65,231,93,88,152,23,215,34,3,86,40,63,26,34,180,79,45,123,187,41,30,169,84,18,141,146,168,42,69,164,20,9,232,200,253,62,245,74,52,89,82,174,54,25,38,6,165,202,0,82,152,118,234,11,49,217,16,6,153,149,117,33,181,174,60,83,161,222,42,77,123,23,58,109,253,192,146,253,144,12,205,41,36,81,7,8,197,122,219,251,
133,88,130,15,64,154,88,104,190,222,36,20,246,100,109,54,67,146,100,65,74,116,42,232,174,186,113,66,145,6,186,209,109,53,69,43,25,221,96,182,55,241,190,196,187,104,149,72,138,13,109,125,157,139,212,82,53,65,116,119,45,138,155,3,222,67,135,160,24,135,140,173,226,95,43,185,238,110,175,145,211,230,123,204,89,119,243,160,111,26,36,24,103,51,246,142,92,196,78,90,201,111,250,207,159,18,87,28,14,135,134,36,194,222,103,41,194,159,9,42,9,58,122,232,93,17,200,249,47,111,223,255,244,242,217,243,55,47,81,83,34,42,242,134,174,131,50,198,250,106,8,174,24,202,221,139,80,162,91,65,155,212,230,86,9,211,224,128,2,28,35,179,107,194,75,117,169,44,104,85,227,200,222,190,131,178,138,113,36,45,149,225,167,211,94,61,55,247,79,109,68,239,153,97,221,79,185,78,148,208,57,37,250,185,95,159,230,36,134,255,226,60,147,148,20,17,199,38,37,196,117,91,206,243,12,52,178,168,218,232,94,62,29,156,26,211,168,141,32,106,192,160,199,231,68,151,
60,101,58,142,161,101,83,119,154,10,19,17,109,215,0,117,106,117,108,198,89,148,52,245,14,97,73,105,142,213,4,58,11,28,136,107,243,221,132,254,230,162,181,77,15,204,58,211,231,82,114,74,130,31,170,47,57,8,97,213,69,234,229,76,149,54,226,71,97,234,199,174,84,87,151,250,139,123,211,249,100,171,62,16,200,162,48,247,146,123,88,75,95,95,80,22,154,62,120,69,183,118,233,157,165,251,138,206,93,80,114,4,47,246,143,242,67,118,81,23,5,249,174,159,107,179,203,230,52,168,172,167,173,219,187,1,237,247,250,254,183,253,237,87,69,90,112,121,120,167,0,67,22,178,9,203,144,189,206,20,114,89,44,78,150,134,214,227,125,181,147,56,244,146,16,53,126,187,203,129,42,147,20,53,168,148,160,254,97,129,38,105,250,62,82,201,52,103,149,46,163,234,103,3,232,90,194,92,173,238,242,226,70,227,123,83,192,137,161,253,180,133,78,137,186,69,237,29,218,246,204,81,153,101,51,250,129,2,80,126,149,215,254,249,14,74,104,37,45,226,108,166,4,118,171,4,
125,72,8,165,207,122,100,13,202,31,83,49,111,48,169,95,130,228,140,234,240,190,135,10,178,84,77,97,52,172,20,156,82,55,233,239,51,76,9,226,216,8,183,112,20,49,165,136,61,84,146,45,243,3,16,56,98,210,64,93,209,141,14,157,175,215,226,26,235,212,176,216,160,136,16,54,93,19,10,206,212,105,70,105,214,96,176,119,74,37,101,53,181,52,253,52,6,33,13,197,51,50,133,117,32,222,204,70,180,43,213,253,82,128,146,212,27,154,180,93,190,75,185,198,216,77,162,246,172,102,238,107,148,96,227,14,221,43,13,217,15,192,187,188,88,171,3,37,69,74,81,32,118,141,97,162,29,196,136,141,187,107,175,234,88,237,210,92,170,64,101,22,137,58,143,235,75,179,225,236,63,52,159,23,164,
topic "Moveable";
[2 $$0,0#00000000000000000000000000000000:Default]
[l288;i704;a17;O9;~~~.992;2 $$1,0#10431211400427159095818037425705:param]
[a83;*R6 $$2,5#31310162474203024125188417583966:caption]
[b83;*2 $$3,5#07864147445237544204411237157677:title]
[b167;a42;C2 $$4,6#40027414424643823182269349404212:item]
[b42;a42;2 $$5,5#45413000475342174754091244180557:text]
[l288;a17;2 $$6,6#27521748481378242620020725143825:desc]
[l321;t246;C@5;1 $$7,7#20902679421464641399138805415013:code]
[b2503;2 $$8,0#65142375456100023862071332075487:separator]
[*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base]
[t4167;C2 $$10,0#37138531426314131251341829483380:class]
[l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement]
[i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam]
[b167;C2 $$13,13#92430459443460461911108080531343:item1]
[i288;a42;O9;C2 $$14,14#77422149456609303542238260500223:item2]
[*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate]
[l321;*C$7;2 $$16,16#03451589433145915344929335295360:result]
[l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line]
[l160;t4167;*C+117 $$18,5#88603949442205825958800053222425:package`-title]
[{_}%EN-US
[s2; Moveable&]
[s5; Moveable concept represents basic requirement for types stored
in Vector flavor of containers (namely Vector, BiVector, Index,
VectorMap, InVector, SortedIndex, SortedVectorMap). To explain
what it is and why it is so important let us first create a very
primitive Vector`-like container template&]
[s7; template <class T>&]
[s7; class SimpleVector `{&]
[s7; -|T `*vector;&]
[s7; -|int capacity;&]
[s7; -|int items;&]
[s7; &]
[s7; -|void [* Expand()] `{&]
[s7; -|-|capacity `= max(1, 2 `* capacity);&]
[s7; -|-|T `*newvector `= (T `*) new char`[capacity `* sizeof(T)`];&]
[s7; -|-|for(int i `= 0; i < items; i`+`+) `{&]
[s7; -|-|-|[* new(newvector`[i`]) T(vector`[i`])];&]
[s7; -|-|-|[* vector`[i`].T`::`~T();]&]
[s7; -|-|`}&]
[s7; -|-|delete`[`] (char `*) vector;&]
[s7; -|-|vector `= newvector;&]
[s7; -|`}&]
[s7; public:&]
[s7; -|void Add(const T`& x) `{&]
[s7; -|-|if(items >`= capacity) [* Expand()];&]
[s7; -|-|new(vector`[items`+`+`]) T(x);&]
[s7; -|`}&]
[s7; -|T`& operator`[`](int i) `{ return vector`[i`]; `}&]
[s7; -|SimpleVector() `{&]
[s7; -|-|vector `= NULL;&]
[s7; -|-|capacity `= items `= 0;&]
[s7; -|`}&]
[s7; -|`~SimpleVector() `{&]
[s7; -|-|for(int i `= 0; i < items; i`+`+)&]
[s7; -|-|-|vector`[i`].T`::`~T();&]
[s7; -|-|delete`[`] (char `*)vector;&]
[s7; -|`}&]
[s7; `};&]
[s5; This [* SimpleVector] stores added elements in the [* vector] member
field. If there is no more empty storage space left in [* vector],
[* SimpleVector] simply doubles its capacity using [* Expand] method.
This method is what interests us `- because [* Expand ]requires
means to copy values of elements from the original memory area
to the newly allocated one. The version above uses placement
new and copy constructor for this purpose. This also means that
[* SimpleVector] requires T to have copy constructor (in standard
C`+`+ library terms: it must be [/ copy`-constructible]). Now let
us create a typical element that can be stored in such container&]
[s7; class SimpleString `{&]
[s7; -|char `*text;&]
[s7; public:&]
[s7; -|SimpleString(const char `*txt) `{&]
[s7; -|-|text `= new char`[strlen(txt)`+1`];&]
[s7; -|-|strcpy(text, txt);&]
[s7; -|`}&]
[s7; -|SimpleString(const SimpleString`& s) `{&]
[s7; -|-|text `= new char`[strlen(s.text)`+1`];&]
[s7; -|-|strcpy(text, s.text);&]
[s7; -|`}&]
[s7; -|void operator`=(const SimpleString`& s) `{&]
[s7; -|-|delete`[`] text;&]
[s7; -|-|text `= new char`[strlen(s.text)`+1`];&]
[s7; -|-|strcpy(text, s.text);-|-|&]
[s7; -|`}&]
[s7; -|`~SimpleString() `{&]
[s7; -|-|delete`[`] text;&]
[s7; -|`}&]
[s7; `};&]
[s5; and see what happens when [* SimpleVector] of [* SimpleString]s
is expanded: First, copies of all elements are created, that means
allocating new storage for [* text] member of new element and copying
source [* text] to it using [* strcpy]. A moment later, [* Expand]
invokes destructor for element, thus deleting all [* text]s in
the original elements. Does not it seem we are wasting a lot
of CPU cycles just to make copies of things that we throw away
a moment later anyway? What if instead of making copies we could
find a way to transfer original elements`' [* text] members to
new elements and somehow disallow [* delete`[`] text] in destructor?
See how primitive it can be:&]
[s7; template <class T>&]
[s7; class SimpleVector `{&]
[s7; -|T `*vector;&]
[s7; -|int capacity;&]
[s7; -|int items;&]
[s7; &]
[s7; -|void Expand() `{&]
[s7; -|-|capacity `= max(1, 2 `* capacity);&]
[s7; -|-|T `*newvector `= (T `*) new char`[capacity `* sizeof(T)`];&]
[s7; -|-|[* memcpy(newvector, vector, items `* sizeof(T));]&]
[s7; -|-|delete`[`](char `*)vector;&]
[s7; -|-|vector `= newvector;&]
[s7; -|`}&]
[s7; public:&]
[s7; -|void Add(const T`& x) `{&]
[s7; -|-|if(items >`= capacity) Expand();&]
[s7; -|-|new(vector`[items`+`+`]) T(x);&]
[s7; -|`}&]
[s7; -|SimpleVector() `{&]
[s7; -|-|vector `= NULL;&]
[s7; -|-|capacity `= items `= 0;&]
[s7; -|`}&]
[s7; -|`~SimpleVector() `{&]
[s7; -|-|for(int i `= 0; i < items; i`+`+)&]
[s7; -|-|-|vector`[i`].T`::`~T();&]
[s7; -|-|delete`[`] (char `*)vector;&]
[s7; -|`}&]
[s7; `};&]
[s5; For the moment please ignore fact that by using memcpy to move
non`-POD types we are violating C`+`+ standard (we will discuss
it later). Now, what we get here is exactly what we wanted `-
instead of a series of copy construction and destruction we simply
copy raw binary data to the new location. This way we simply
transfer the old value in the [* text ]member of elements into
the new expanded [* vector]. We need to invoke neither copy constructor
nor destructor when expanding vector. Not a single CPU cycle
is lost.&]
[s5; The types that can be moved in memory using memcpy are called
[*/ moveable.]&]
[s5; Clearly not all types are moveable. Being moveable has a lot
to do with [/ not] storing references to the object itself or to
it`'s parts. E.g.&]
[s7; struct Link `{&]
[s7; -|Link `*prev;&]
[s7; public:&]
[s7; -|Link() `{ prev `= NULL; `}&]
[s7; -|Link(Link `*p) `{ prev `= p; `}&]
[s7; `};&]
[s5; is [* not] moveable, because memcpy`-ing to a new location would
break the existing links. All of the following requirements should
be fullfilled for moveable types:&]
[s5;i150;O0; It does not have any virtual method nor virtual base
class.&]
[s5;i150;O0; Base classes (if any) and any instance member variables
are moveable.&]
[s5;i150;O0; No references or pointers are stored to the object itself
or to subobjects in the methods of the type, into variables that
exist after the method finishes execution. &]
[s5; Fundamental types fulfills these requirements so they are moveable.&]
[s5; Example:&]
[s7; struct Foo;&]
[s7; &]
[s7; Foo `*global`_foo;&]
[s0; &]
[s7; struct Foo `{&]
[s7; -|int a;&]
[s7; -|Foo `*foo;&]
[s7; -|int `*ptr;&]
[s7; public:&]
[s7; -|void Set(Foo `* f) `{&]
[s7; -|-|foo `= f;&]
[s7; -|`}&]
[s7; -|void Ok1() `{&]
[s7; -|-|Foo `*x `= this;&]
[s7; -|// local variable will not exist outside method&]
[s7; -|// `-> does not prevent Foo from being moveable&]
[s7; -|`}&]
[s7; -|void Ok2() `{&]
[s7; -|-|memset(`&a, 0, sizeof(int));&]
[s7; -|// pointer will not exist outside method&]
[s7; -|// `-> does not prevent Foo from being moveable&]
[s7; -|`}&]
[s7; -|void Bad1() `{&]
[s7; -|-|foo `= this;&]
[s7; -|// member variable foo exists outside method&]
[s7; -|// `-> makes Foo non`-moveable&]
[s7; -|`}&]
[s7; -|void Bad2() `{&]
[s7; -|-|ptr `= `&a;&]
[s7; -|// pointer to subobject stored, ptr exists outside method&]
[s7; -|// `-> makes Foo non`-moveable&]
[s7; -|`}&]
[s7; -|void Bad3() `{&]
[s7; -|-|global`_foo `= this;&]
[s7; -|// pointer stored to global variable&]
[s7; -|// `-> makes Foo non`-moveable&]
[s7; -|`}&]
[s7; -|void Bad4(Foo`& another) `{&]
[s7; -|-|another.Set(this);&]
[s7; -|// pointer stored indirectly in object that exist outside method&]
[s7; -|// `-> makes Foo non`-moveable&]
[s7; -|`}&]
[s7; `};&]
[s5; These requirements satisfies fairly large number of types, incidentally
most of the types you ever wanted to store in a container of
elements of a single type are moveable. Most important, all NTL
containers [* are ]moveable.&]
[s5; Now we have an effective method how to organize the storing
of elements in containers. We have to deal with the fact that
being moveable is part of an object`'s interface, and we should
ensure that only movable elements are stored into NTL containers.
For this we need a way to declare at compile time that a certain
type is moveable and also a way to check it.&]
[s5; To achieve this goal, you can mark moveable types by deriving
them from the [* Moveable] template class e.g.:&]
[s7; class SimpleString : Moveable<SimpleString> `{ ... `}&]
[s5; Alternatively the [* NTL`_MOVEABLE ]macro can be used to mark
types as moveable if the class interface can not be changed,
such as in:&]
[s7; NTL`_MOVEABLE(std`::string);&]
[s5; Now that we can mark types as moveable, we need a way to check
a type for being moveable. This is done by adding the line:&]
[s7; AssertMoveable<T>()&]
[s5; to one of the methods of a template that gets compiled for any
template argument `- the destructor is the most obvious place.
The AssertMovable function is defined only if [* T] is marked as
moveable, so it results in compilation error for non`-moveable
T types.&]
[s5; Finally, time has come to deal with the C`+`+ standard. Current
C`+`+ defines memcpy only for POD types. The moveable concept
requires memcpy of non`-POD types to be defined. In fact, difference
between POD and moveable non`-POD types is the existence of constructors
and non`-virtual destructor. To get things work, all we need
is that the result of memcpy`-ing non`-POD type [* T ]is same as
memcpy`-ing the POD [* T1 ]type which you would get by removing
the destructor and the constructors from [* T]. While this operation
is still undefined by C`+`+, it is really hard to imagine an
optimal C`+`+ implementation that would break this rule. Indeed,
all current implementation we have met so far support moveable
semantics in the way we have defined here. Performance and other
gains realized by using the moveable concept are too big to ignore.]]

View file

@ -83,27 +83,26 @@ unknown maximal value&]
[s0; &]
[s3; 3. Transfer issues&]
[s5; Often you need to pass content of one container to another of
the same type. NTL containers follow [^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ def
ault pick semantics], that means that source container is destroyed&]
the same type. NTL containers always support [^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ p
ick semantics], and, depending on type stored, also might support
[^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ clone sematics]. When
transfering the value, you have to explicitly specify which one
to use:&]
[s7; -|Vector<int> v;&]
[s7; -|v.Add(1);&]
[s7; -|v.Add(2);&]
[s7; &]
[s7; -|Vector<int> v1 [* `=] v;&]
[s7; -|Vector<int> v1 [* `=] pick(v);&]
[s5; now source Vector [C v] is destroyed `- picked `- and you can
no longer access its content. This admittedly strange behaviour
has many advantages. First, it is consistently fast and in most
cases, transfer of value instead of full copy is exactly what
you need. Second, NTL containers can store elements that lack
copy operation `- in that case, pick transfer is the only option
anyway.&]
no longer access its content. This behaviour has many advantages.
First, it is consistently fast and in most cases, transfer of
value instead of full copy is exactly what you need. Second,
NTL containers can store elements that lack copy operation `-
in that case, pick transfer is the only option anyway.&]
[s5; If you really need to preserve value of source (and elements
support deep copy operation), you can use [^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ o
ptional deep copy operator or constructor]&]
[s7; -|v [* <<`=] v1;&]
[s5; Now both containers have the same content. Constructor form
of same operation is distinguished by an additional int parameter&]
[s7; -|Vector<int> v2(v[* , 0]);&]
support deep copy operation), you can use [^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ c
lone]&]
[s7; -|v [* `=] clone(v1);&]
[s7; &]
[s3; 4. Client types&]
[s5; So far we were using int as type of elements. In order to store
@ -168,37 +167,41 @@ reasons):&]
[s7; &]
[s3; 6. Polymorphic Array&]
[s5; Array can even be used for storing polymorphic elements &]
[s7; -|struct Number `{&]
[s7; -|-|virtual double Get() const `= 0;&]
[s7; struct Number `{&]
[s7; -|virtual double Get() const `= 0;&]
[s7; &]
[s7; -|-|String ToString() const `{ return AsString(Get()); `}&]
[s7; -|`};&]
[s7; &]
[s7; -|struct Integer : public Number `{&]
[s7; -|-|int n;&]
[s7; -|-|virtual double Get() const `{ return n; `}&]
[s7; -|String ToString() const `{ return AsString(Get()); `}&]
[s7; -|&]
[s7; -|-|Integer(int n) : n(n) `{`}&]
[s7; -|`};&]
[s7; -|virtual `~Number() `{`}&]
[s7; `};&]
[s7; &]
[s7; struct Integer : public Number `{&]
[s7; -|int n;&]
[s7; -|virtual double Get() const `{ return n; `}&]
[s7; &]
[s7; -|Integer() `{`}&]
[s7; `};&]
[s7; &]
[s7; struct Double : public Number `{&]
[s7; -|double n;&]
[s7; -|virtual double Get() const `{ return n; `}&]
[s7; &]
[s7; -|Double() `{`}&]
[s7; `};&]
[s7; &]
[s7; bool operator<(const Number`& a, const Number`& b)&]
[s7; `{&]
[s7; -|return a.Get() < b.Get();&]
[s7; `}&]
[s7; &]
[s7; -|struct Double : public Number `{&]
[s7; -|-|double n;&]
[s7; -|-|virtual double Get() const `{ return n; `}&]
[s7; -|&]
[s7; -|-|Double(double n) : n(n) `{`}&]
[s7; -|`};&]
[s5; In this case, elements are added using Add with pointer to base
element type parameter. Do not be confused by new and pointer,
Array takes ownership of passed object and behaves like container
of base type elements&]
[s7; -|Array<Number> num;&]
[s7; -|num.[* Add]([* new] Integer(3));&]
[s7; -|num.Add(new Double(15.5));&]
[s7; -|num.Add(new Double(2.23));&]
[s7; -|num.Add(new Integer(2));&]
[s7; -|num.Add(new Integer(20));&]
[s7; -|num.Add(new Double(`-2.333));&]
[s17; num `= `{ 3, 15.5, 2.23, 2, 20, `-2.333 `}&]
[s7; -|num.Create<Double>().n `= 15.5;&]
[s7; -|num.Create<Integer>().n `= 3;&]
[s17; num `= `{ 15.5, 3 `}&]
[s5; Thanks to well defined algorithm requirements, you can e.g.
directly apply Sort on such Array&]
[s7; -|bool operator<(const Number`& a, const Number`& b)&]
@ -209,7 +212,7 @@ directly apply Sort on such Array&]
[s7; .......&]
[s7; &]
[s7; -|Sort(num);&]
[s17; num `= `{ `-2.333, 2, 2.23, 3, 15.5, 20 `}&]
[s17; num `= `{ 3, 15.5 `}&]
[s3; 7. Bidirectional containers&]
[s5; Vector and Array containers allow fast adding and removing elements
at the end of sequence. Sometimes, same is needed at begin of
@ -226,13 +229,11 @@ case, BiVector and BiArray should be used&]
[s7; -|n.[* DropTail]();&]
[s17; n `= `{ 1, 2 `}&]
[s7; -|BiArray<Number> num;&]
[s7; -|num.AddHead(new Integer(3));&]
[s7; -|num.AddTail(new Double(15.5));&]
[s7; -|num.AddHead(new Double(2.23));&]
[s7; -|num.AddTail(new Integer(2));&]
[s7; -|num.AddHead(new Integer(20));&]
[s7; -|num.AddTail(new Double(`-2.333));&]
[s17; num `= `{ 20, 2.23, 3, 15.5, 2, `-2.333 `}&]
[s7; -|num.CreateHead<Integer>().n `= 3;&]
[s7; -|num.CreateTail<Double>().n `= 15.5;&]
[s7; -|num.CreateHead<Double>().n `= 2.23;&]
[s7; -|num.CreateTail<Integer>().n `= 2;&]
[s17; num `= `{ 2.23, 3, 15.5, 2 `}&]
[s3; 8. Index&]
[s5; Index is a container very similar to the plain Vector (it is
random access array of elements with fast addition at the end)
@ -325,26 +326,22 @@ source Index)&]
[s5; In order to store elements to Index, they must be moveable (you
can use [* ArrayIndex] for types that are not) and they must have
defined the operator`=`= and a function to compute hash value.
Notice usage of [* CombineHash] to combine hash values of types
Notice usage THE of [* CombineHash] to combine hash values of types
already known to U`+`+ into final result&]
[s7; -|struct Person : Moveable<Person> `{&]
[s7; -|-|String name;&]
[s7; -|-|String surname;&]
[s7; -|&]
[s7; -|-|Person(String name, String surname)&]
[s7; -|-|: name(name), surname(surname) `{`}&]
[s7; -|-|Person() `{`}&]
[s7; -|`};&]
[s7; &]
[s7; -|unsigned [* GetHashValue](const Person`& p)&]
[s7; -|`{&]
[s7; -|-|return [* CombineHash](p.name, p.surname);&]
[s7; -|`}&]
[s7; struct Person : Moveable<Person> `{&]
[s7; -|String name;&]
[s7; -|String surname;&]
[s7; &]
[s7; -|bool operator`=`=(const Person`& a, const Person`& b)&]
[s7; -|`{&]
[s7; -|-|return a.name `=`= b.name `&`& a.surname `=`= b.surname;&]
[s7; -|`}&]
[s7; -|unsigned [* GetHashValue]() const `{ return [* CombineHash](name,
surname); `}&]
[s7; -|bool [* operator`=`=](const Person`& b) const `{ return name
`=`= b.name `&`& surname `=`= b.surname; `}&]
[s7; &]
[s7; -|Person(String name, String surname) : name(name), surname(surname)
`{`}&]
[s7; -|Person() `{`}&]
[s7; `};&]
[s7; &]
[s7; .......&]
[s7; &]
@ -355,29 +352,7 @@ already known to U`+`+ into final result&]
[s7; -| &]
[s7; -|DUMP(p.Find(Person(`"Paul`", `"Carpenter`")));&]
[s17; p.Find(Person(`"Paul`", `"Carpenter`")) `= 1&]
[s5; If type cannot be stored in Index or if references to elements
are required, [* ArrayIndex] can be used&]
[s7; -|unsigned GetHashValue(const Number`& n)&]
[s7; -|`{&]
[s7; -|-|return GetHashValue(n.Get());&]
[s7; -|`}&]
[s7; &]
[s7; -|bool operator`=`=(const Number`& a, const Number`& b)&]
[s7; -|`{&]
[s7; -|-|return a.Get() `=`= b.Get();&]
[s7; -|`}&]
[s7; &]
[s7; .......&]
[s7; &]
[s7; -|[* ArrayIndex]<Number> n;&]
[s7; -|n.Add(new Integer(100));&]
[s7; -|n.Add(new Double(10.5));&]
[s7; -|n.Add(new Integer(200));&]
[s7; -|n.Add(new Double(20.5));&]
[s17; n `= `{ 100, 10.5, 200, 20.5 `}&]
[s7; -|DUMP(n.Find(Double(10.5)));&]
[s17; n.Find(Double(10.5)) `= 1&]
[s3; 10. VectorMap&]
[s3; 10. VectorMap, ArrayMap&]
[s5; VectorMap is nothing more than a simple composition of Index
and Vector. You can use [* Add] methods to put elements into the
VectorMap&]
@ -484,16 +459,231 @@ of source VectorMap&]
or if references to elements are needed, you can use [* ArrayMap]
instead&]
[s7; -|[* ArrayMap]<String, Number> am;&]
[s7; -|am.Add(`"A`", new Integer(1));&]
[s7; -|am.Add(`"B`", new Double(2.0));&]
[s7; -|am.Create<Integer>(`"A`").n `= 11;&]
[s7; -|am.Create<Double>(`"B`").n `= 2.1;&]
[s7; &]
[s16; am.GetKeys() `= `{ A, B `}&]
[s16; am.GetValues() `= `{ 1, 2 `}&]
[s16; am.GetValues() `= `{ 11, 2.1 `}&]
[s7; &]
[s7; -|DUMP(am.Get(`"A`"));&]
[s7; -|DUMP(am.Find(`"B`"));&]
[s7; &]
[s16; am.Get(`"A`") `= 1&]
[s16; am.Get(`"A`") `= 11&]
[s16; am.Find(`"B`") `= 1&]
[s16; &]
[s0; ]]
[s3; 11. One&]
[s5; One is a container that can store none or one element of T or
derived from T. It functionally quite similiar to std`::unique`_ptr,
but has some more convenient features (like Create method).&]
[s7; struct Base `{&]
[s7; -|virtual String Get() `= 0;&]
[s7; -|virtual `~Base() `{`}&]
[s7; `};&]
[s7; &]
[s7; struct Derived1 : Base `{&]
[s7; -|virtual String Get() `{ return `"Derived1`"; `}&]
[s7; `};&]
[s7; &]
[s7; struct Derived2 : Base `{&]
[s7; -|virtual String Get() `{ return `"Derived2`"; `}&]
[s7; `};&]
[s7; &]
[s7; void MakeDerived1(One<Base>`& t)&]
[s7; `{&]
[s7; -|t.Create<Derived1>();&]
[s7; `}&]
[s7; &]
[s7; void MakeDerived2(One<Base>`& t)&]
[s7; `{&]
[s7; -|t.Create<Derived2>();&]
[s7; `}&]
[s7; &]
[s7; .......&]
[s7; -|[* One]<Base> s;&]
[s5; Operator bool of one returns true if it contains an element:&]
[s7; -|DUMP([* (bool)]s);&]
[s7; &]
[s16; (bool)s `= false&]
[s7; &]
[s7; -|&]
[s7; -|s.[* Create]<Derived1>();&]
[s7; -|DUMP((bool)s);&]
[s7; -|DUMP(s`->Get());&]
[s7; &]
[s16; (bool)s `= true&]
[s16; s`->Get() `= Derived1&]
[s7; &]
[s5; Clear method removes the element from One:&]
[s7; -|s.[* Clear]();&]
[s7; -|DUMP((bool)s);&]
[s7; &]
[s16; (bool)s `= false&]
[s7; &]
[s7; &]
[s5; One represents a convenient and recommended method how to deal
with class factories in U`+`+: Define then as function with reference
to One parameter, e.g.:&]
[s7; void MakeDerived1(One<Base>`& t)&]
[s7; `{&]
[s7; -|t.Create<Derived1>();&]
[s7; `}&]
[s7; &]
[s7; void MakeDerived2(One<Base>`& t)&]
[s7; `{&]
[s7; -|t.Create<Derived2>();&]
[s7; `}&]
[s7; &]
[s7; VectorMap<int, void (`*)(One<Base>`&)> factories;&]
[s7; &]
[s7; INITBLOCK `{&]
[s7; -|factories.Add(0, MakeDerived1);&]
[s7; -|factories.Add(1, MakeDerived2);&]
[s7; `};&]
[s7; &]
[s7; void Create(One<Base>`& t, int what)&]
[s7; `{&]
[s7; -|(`*factories.Get(what))(t);&]
[s7; `}&]
[s7; &]
[s3; 12. Any&]
[s5; Any is a container that can contain none or one element of [*/ any]
type, the only requirement is that the type has default constructor.
Impotant thing to remember is that [* Is] method matches [/ exact]
type ignoring class hierarchies (FileIn is derived from Stream,
but if Any contains FileIn, Is<Stream>() returns false).&]
[s7; void Do([* Any]`& x)&]
[s7; `{&]
[s7; -|if(x.[* Is]<String>())&]
[s7; -|-|LOG(`"String: `" << x.[* Get]<String>());&]
[s7; -|if(x.[* Is]<FileIn>()) `{&]
[s7; -|-|LOG(`"`-`-`- File: `");&]
[s7; -|-|LOG(LoadStream(x.[* Get]<FileIn>()));&]
[s7; -|-|LOG(`"`-`-`-`-`-`-`-`-`-`-`");&]
[s7; -|`}&]
[s7; -|if(x.[* IsEmpty]())&]
[s7; -|-|LOG(`"empty`");&]
[s7; `}&]
[s7; &]
[s7; .....&]
[s7; &]
[s7; -|Any x;&]
[s7; -|x.[* Create]<String>() `= `"Hello!`";&]
[s7; -|Do(x);&]
[s7; -|x.[* Create]<FileIn>().Open(GetDataFile(`"Ntl12.cpp`"));&]
[s7; -|Do(x);&]
[s7; -|x.[* Clear]();&]
[s7; -|Do(x);&]
[s7; &]
[s3; 13. InVector, InArray&]
[s5; InVector and InArray are vector types quite similar to Vector/Array,
but they trade the speed of operator`[`] with the ability to
insert or remove elements at any position quickly. You can expect
operator`[`] to be about 10 times slower than in Vector (but
that is still very fast), while Insert at any position scales
well up to hunderds of megabytes of data (e.g. InVector containing
100M of String elements is handled without problems).&]
[s7; -|InVector<int> v;&]
[s7; -|for(int i `= 0; i < 1000000; i`+`+)&]
[s7; -|-|v.Add(i);&]
[s7; -|v.Insert(0, `-1); // This is fast&]
[s7; -|DUMP(v`[0`]);&]
[s7; -|DUMP(v`[1`]);&]
[s7; &]
[s5; While the interface of InVector/InArray is almost identical
to Vector/Array, InVector/InArray in addition implements FindLowerBound/FindUpper
Bound functions `- while normal random access algorithms work,
it is possible to provide InVector specific optimization that
basically matches the performace of Find`*Bound on somple Vector.&]
[s7; &]
[s7; -|DUMP(v.FindLowerBound(55));&]
[s7; &]
[s3; 14. SortedIndex, SortedVectorMap, SortedArrayMap&]
[s5; SortedIndex is similar to regular Index, but keeps its elements
in sorted order (sorting predicate is a template parameter, defaults
to StdLess). Implementation is using InVector, so it works fine
even with very large number of elements (performace is similar
to tree based std`::set). Unlike Index, SortedIndex provides lower/upper
bounds searches, so it allow range search.&]
[s7; -|SortedIndex<int> x;&]
[s7; -|x.Add(5);&]
[s7; -|x.Add(3);&]
[s7; -|x.Add(7);&]
[s7; -|x.Add(1);&]
[s7; -|&]
[s7; -|DUMPC(x);&]
[s7; -|DUMP(x.Find(3));&]
[s7; -|DUMP(x.Find(3));&]
[s7; -|DUMP(x.FindLowerBound(3));&]
[s7; -|DUMP(x.FindUpperBound(6));&]
[s7; &]
[s5; SortedVectorMap and SortedArrayMap are then SortedIndex based
equivalents to VectorMap/ArrayMap `- maps that keep keys sorted:&]
[s7; -|SortedVectorMap<String, int> m;&]
[s7; -|m.Add(`"zulu`", 11);&]
[s7; -|m.Add(`"frank`", 12);&]
[s7; -|m.Add(`"alfa`", 13);&]
[s7; -|&]
[s7; -|DUMPM(m);&]
[s7; -|DUMP(m.Get(`"zulu`"));&]
[s7; &]
[s3; 15. Tuples&]
[s5; U`+`+ has template classes Tuple2, Tuple3 and Tuple4 for combining
2`-4 values with different types. These are quite similiar to
std`::tuple class, with some advantages.&]
[s5; To create a Tuple value, you can use MakeTuple function. If
correct types canot be deduced from parameters, you can specify
them explicitly:&]
[s7; -|Tuple3<int, String, String> x `= [* MakeTuple]<int, String, String>(12,
`"hello`", `"world`");&]
[s7; &]
[s5; Individual values are accessible as members a .. d:&]
[s7; &]
[s7; -|DUMP(x.a);&]
[s7; -|DUMP(x.b);&]
[s7; -|DUMP(x.c);&]
[s7; -|&]
[s5; As long as all individual types have conversion to String (AsString),
the tuple also has such conversion and thus can e.g. be easily
logged:&]
[s7; &]
[s7; -|DUMP(x);&]
[s7; &]
[s5; Also, as long as individual types have defined GetHashValue,
so does Tuple:&]
[s7; &]
[s7; -|DUMP(GetHashValue(x));&]
[s7; &]
[s5; As long as individual types have defined operator`=`=, Tuple
has defined operator`=`= and operator!`=&]
[s7; &]
[s7; -|Tuple3<int, String, String> y `= x;&]
[s7; -|DUMP(x !`= y);&]
[s7; &]
[s5; Finally, as long as all individual types have defined SgnCompare
(most U`+`+ types have), Tuple has SgnCompare, Compare method
and operators <, <`=, >, >`=:&]
[s7; &]
[s7; -|DUMP(x.Compare(y));&]
[s7; -|&]
[s7; -|y.b `= `"a`";&]
[s7; -|&]
[s7; -|DUMP(SgnCompare(y));&]
[s7; -|DUMP(x < y);&]
[s7; -|&]
[s7; &]
[s5; U`+`+ Tuples are strictly designed as POD type, which allows
POD arrays to be intialized with classic C style:&]
[s7; -|static Tuple2<int, const char `*> map`[`] `= `{&]
[s7; -|-|`{ 1, `"one`" `},&]
[s7; -|-|`{ 2, `"one`" `},&]
[s7; -|-|`{ 3, `"one`" `},&]
[s7; -|`};&]
[s7; -|&]
[s5; Simple FindTuple template function is provided to search for
tuple based on the first value:&]
[s7; &]
[s7; -|Tuple2<int, const char `*> `*f `= FindTuple(map, `_`_countof(map),
2);&]
[s7; -|if(f)&]
[s7; -|-|DUMP(f`->b);&]
[s7; ]]

View file

@ -6,10 +6,10 @@ topic "NTL and standard library";
[b167;a42;C2 $$4,6#40027414424643823182269349404212:item]
[b42;a42;2 $$5,5#45413000475342174754091244180557:text]
[l288;a17;2 $$6,6#27521748481378242620020725143825:desc]
[l321;tC@5;1 $$7,7#20902679421464641399138805415013:code]
[l321;C@5;1 $$7,7#20902679421464641399138805415013:code]
[b2503;2 $$8,0#65142375456100023862071332075487:separator]
[*@(0.0.255)2 $$9,0#83433469410354161042741608181528:base]
[tC7 $$10,0#37138531426314131251341829483380:class]
[C7 $$10,0#37138531426314131251341829483380:class]
[l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement]
[i417;b42;a42;O9;~~~.416;2 $$12,12#10566046415157235020018451313112:tparam]
[b167;C2 $$13,13#92430459443460461911108080531343:item1]
@ -17,7 +17,7 @@ topic "NTL and standard library";
[*@2$(0.128.128)2 $$15,15#34511555403152284025741354420178:NewsDate]
[l321;*C$7;2 $$16,16#03451589433145915344929335295360:result]
[l321;b83;a83;*C$7;2 $$17,17#07531550463529505371228428965313:result`-line]
[l160;*tC+117 $$18,5#88603949442205825958800053222425:package`-title]
[l160;*C+117 $$18,5#88603949442205825958800053222425:package`-title]
[{_}%EN-US
[s2; NTL and standard library&]
[s5; While NTL is kind of `"alien technology`" with respect to C`+`+
@ -35,4 +35,4 @@ any known (and imaginable) implementation of auto`_ptr is moveable
need to do is to mark an instantiation with the Moveable template.&]
[s5; Even better is that you do not need Vector of auto`_ptr `- because
Array flavor will do the same job more comfortably.&]
[s0; ]
[s0; ]]

View file

@ -152,6 +152,8 @@ public:
struct SrcFile {
SrcFile();
rval_default(SrcFile);
String text;
Vector<int> linepos;
int preprocessorLinesRemoved;
@ -284,6 +286,9 @@ class Parser {
void operator<<=(const Context& t);
String Dump() const;
Context() {}
rval_default(Context);
};
struct Decla {
@ -314,6 +319,9 @@ class Parser {
struct Decl : Decla {
Array<Decl> param;
rval_default(Decl);
Decl() {}
};
struct RecursionCounter

View file

@ -498,7 +498,7 @@ void Parser::ParamList(Decl& d) {
break;
}
else
d.param.Add() = Declaration().Top();
d.param.Add() = pick(Declaration().Top());
if(Key(t_elipsis)) {
Elipsis(d);
break;
@ -640,7 +640,7 @@ Parser::Decl Parser::Type() {
Qualifier();
SimpleType(d);
Declarator(d, p);
return Finish(d, p);
return pick(Finish(d, p));
}
bool Parser::IsParamList(int q)
@ -1180,7 +1180,7 @@ bool Parser::Scope(const String& tp, const String& tn) {
im.pname.Clear();
im.param.Clear();
if(Key(';')) {
context = cc;
context = pick(cc);
im.natural = Gpurify(nn);
SetScopeCurrent();
return true;
@ -1219,7 +1219,7 @@ bool Parser::Scope(const String& tp, const String& tn) {
else
if(IsNull(im.natural))
im.natural = Gpurify(nn);
context = cc;
context = pick(cc);
CheckKey(';');
SetScopeCurrent();
return true;

View file

@ -189,7 +189,7 @@ SrcFile PreProcess(Stream& in)
res.commentLinesRemoved++;
}
}
return res;
return pick(res);
}
END_UPP_NAMESPACE

View file

@ -89,7 +89,7 @@ const Vector<String>& Scopefo::GetBases()
Bases(b[i], bb);
}
}
b = bb;
b = pick(bb);
}
for(int i = 0; i < bi.GetCount(); i++)
baselist.Add(base.GetKey(bi[i]) + "::");

View file

@ -168,6 +168,11 @@ void Lex::Next()
while(iscid(*ptr))
x.Cat(*ptr++);
int q = id.FindAdd(x);
if(q == tk_rval_ - 256) { // simple hack for transitionary macro
AddCode('&');
AddCode('&');
}
else
if(q >= ignore_low && q < ignore_high)
while(*ptr && (byte)*ptr <= ' ') {
ptr++;

View file

@ -85,3 +85,5 @@ CPPID(SKYLARK)
CPPID(RPC_METHOD)
CPPID(RPC_GMETHOD)
CPPID(force_inline)
CPPID(rval_)

View file

@ -110,7 +110,7 @@ void PostCallback(Callback cb, void *id = NULL) { SetTimeCallbac
class TimeCallback
{
public:
~TimeCallback() { Kill(); }
~TimeCallback() { Kill(); (void)dummy; }
void Set(int delay, Callback cb) { UPP::SetTimeCallback(delay, cb, this); }
void Post(Callback cb) { UPP::PostCallback(cb, this); }

View file

@ -212,7 +212,7 @@ void Ctrl::SyncScroll()
GuiLock __;
if(!top)
return;
Vector<Scroll> scroll = top->scroll;
Vector<Scroll> scroll = pick(top->scroll);
top->scroll.Clear();
if(IsFullRefresh())
return;

View file

@ -322,7 +322,7 @@ void Ctrl::DefferedFocusSync()
GuiLock __;
while(defferedChildLostFocus.GetCount() || defferedSetFocus) {
LLOG("Ctrl::DeferredFocusSync, defferedSetFocus = " << UPP::Name(defferedSetFocus));
Vector< Ptr<Ctrl> > b = defferedChildLostFocus;
Vector< Ptr<Ctrl> > b = pick(defferedChildLostFocus);
defferedChildLostFocus.Clear();
for(int i = 0; i < b.GetCount(); i++)
if(b[i]) {

View file

@ -376,7 +376,7 @@ void Ctrl::RemoveFrame(int i) {
m.Add().frame = frame[q].frame;
else
frame[q].frame->FrameRemove();
frame = m;
frame = pick(m);
if(frame.GetCount() == 0)
frame.Add().frame = &NullFrame();
RefreshFrame();
@ -413,7 +413,7 @@ void Ctrl::InsertFrame(int i, CtrlFrame& fr)
}
if(i == n)
m.Add().frame = &fr;
frame = m;
frame = pick(m);
fr.FrameAdd(*this);
SyncLayout();
RefreshFrame();

View file

@ -79,7 +79,6 @@ private:
byte charset;
Size dot_page_size;
Rect dot_margins;
void *context;
RichPara::CharFormat charfmt;
RichPara::Format parafmt;
@ -130,7 +129,6 @@ RTFEncoder::RTFEncoder(Stream& stream_, const RichText& richtext_, byte charset_
, charset(charset_)
, dot_page_size(dot_page_size_)
, dot_margins(dot_margins_)
, context(context_)
{
for(int i = 0; i < richtext.GetStyleCount(); i++)
styleid.Add(richtext.GetStyleId(i));
@ -254,9 +252,9 @@ bool RTFEncoder::PutCharFormat(const RichPara::CharFormat& cf, const RichPara::C
bool f;
int t;
if(cf.GetFace() != difcf.GetFace())
Command("pnf" + pn2, used_faces.Find(cf.GetFace()));
Command(("pnf") + pn2, used_faces.Find(cf.GetFace()));
if((t = DotPoints(2 * tabs(cf.GetHeight()))) != DotPoints(2 * tabs(difcf.GetHeight())))
Command("pnfs" + pn2, t);
Command(("pnfs") + pn2, t);
if(!pn && dword(t = cf.sscript) != difcf.sscript)
Command(t == 0 ? "nosupersub" : t == 1 ? "super" : "sub");
if((f = cf.IsBold()) != difcf.IsBold()) Command((f ? "pnb" : "pnb0") + pn2);
@ -264,9 +262,9 @@ bool RTFEncoder::PutCharFormat(const RichPara::CharFormat& cf, const RichPara::C
if((f = cf.IsUnderline()) != difcf.IsUnderline()) Command((f ? "pnul" : "pnul0") + pn2);
if((f = cf.IsStrikeout()) != difcf.IsStrikeout()) Command((f ? "pnstrike" : "pnstrike0") + pn2);
if((f = cf.capitals) != difcf.capitals) Command((f ? "pncaps" : "pncaps0") + pn2);
if((t = used_ink.Get(cf.ink)) != used_ink.Get(difcf.ink)) Command("pncf" + pn2, t);
if((t = used_paper.Get(cf.paper)) != used_paper.Get(difcf.paper)) Command("pncb" + pn2, t);
#ifdef PLATFORM_WIN32 //zapoznamkoval Fidler kdyz chtel zkompilovat pod Linuxem...
if((t = used_ink.Get(cf.ink)) != used_ink.Get(difcf.ink)) Command(("pncf") + pn2, t);
if((t = used_paper.Get(cf.paper)) != used_paper.Get(difcf.paper)) Command(("pncb") + pn2, t);
#ifdef PLATFORM_WIN32
if(!pn && cf.language != difcf.language) Command("lang", GetLanguageLCID(cf.language));
#endif
// todo: link

View file

@ -71,7 +71,7 @@ public:
bool CanSetSurface() { return true; }
static void Flush() {} // TODO?
SystemDraw(cairo_t *cr, GdkDrawable *dw/* = NULL*/) : cr(cr), drawable(dw) {}
SystemDraw(cairo_t *cr, GdkDrawable *dw/* = NULL*/) : cr(cr), drawable(dw) { (void)drawable; }
};
class ImageDraw : public SystemDraw {

View file

@ -86,7 +86,6 @@ private:
String ReadBinHex(char& odd) const;
private:
const char *rtf_begin;
const char *rtf;
TOKEN token;
@ -200,8 +199,7 @@ RTFParser::Cell::Cell()
}
RTFParser::RTFParser(const char *rtf)
: rtf_begin(rtf)
, rtf(rtf)
: rtf(rtf)
{
#ifdef _DEBUG
SaveFile(ConfigFile("rtfparser.rtf"), rtf);
@ -227,12 +225,12 @@ RTFParser::RTFParser(const char *rtf)
RichText RTFParser::Run()
{
if(!PassGroup() || !PassCmd("rtf") || command_arg != 1 && !IsNull(command_arg))
return output;
return pick(output);
while(Token() != T_EOF)
ReadItem();
Flush(false, 1);
FlushTable(0);
return output;
return pick(output);
}
void RTFParser::FlushTable(int level)
@ -263,7 +261,7 @@ void RTFParser::FlushTable(int level)
table.SetFormat(child.tableformat);
for(int c = 1; c < dot_order.GetCount(); c++)
table.AddColumn(dot_order[c] - dot_order[c - 1]);
dot_index = dot_order;
dot_index = pick(dot_order);
int tbl_border = Null, tbl_grid = Null;
Color clr_border = Null, clr_grid = Null;
for(int r = 0; r < child.cells.GetCount(); r++) {
@ -360,16 +358,16 @@ void RTFParser::FlushTable(int level)
}
table.SetFormat(r, cell.nbegin, cell.info.format);
cell.text.Normalize();
table.SetPick(r, cell.nbegin, cell.text);
table.SetPick(r, cell.nbegin, pick(cell.text));
}
}
table.Normalize();
table_stack.Drop();
if(table_stack.IsEmpty())
output.CatPick(table);
output.CatPick(pick(table));
else {
TableState& par = table_stack.Top();
CellAt(par, par.textcol).text.CatPick(table);
CellAt(par, par.textcol).text.CatPick(pick(table));
}
}
}

View file

@ -3,7 +3,7 @@
#include "Draw/init"
#include "plugin\bmp/init"
#include "RichText/init"
#define BLITZ_INDEX__ F656a4ea94e4f808b1ec63034b0e6c5ac
#define BLITZ_INDEX__ Fe2ff541f9bb9f4ad3f5bcc23a34e1b73
#include "CtrlCore.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -201,7 +201,7 @@ void ArrayCtrl::CellInfo::Set(Ctrl *ctrl, bool owned, bool value)
ptr.Set1(cc);
}
ArrayCtrl::CellInfo::CellInfo(pick_ CellInfo& s)
ArrayCtrl::CellInfo::CellInfo(CellInfo rval_ s)
{
ptr = s.ptr;
const_cast<CellInfo&>(s).ptr.SetPtr(NULL);
@ -2298,15 +2298,15 @@ void ArrayCtrl::SortB(const Vector<int>& o)
Vector< Vector<CellInfo> > ncellinfo;
for(int i = 0; i < o.GetCount(); i++) {
int oi = o[i];
narray[i] = array[oi];
narray[i] = pick(array[oi]);
if(oi < cellinfo.GetCount())
ncellinfo.At(i) = cellinfo[oi];
ncellinfo.At(i) = pick(cellinfo[oi]);
if(oi < ln.GetCount())
nln.At(i) = ln[oi];
}
array = narray;
cellinfo = ncellinfo;
ln = nln;
array = pick(narray);
cellinfo = pick(ncellinfo);
ln = pick(nln);
Reline(0, 0);
if(hasctrls) {
for(int i = 0; i < array.GetCount(); i++)

View file

@ -155,7 +155,7 @@ private:
bool IsDisplay() const { return !ptr.GetBit() && ptr.GetPtr(); }
const Display& GetDisplay() const { ASSERT(IsDisplay()); return *(const Display *)ptr.GetPtr(); }
CellInfo(pick_ CellInfo& s);
CellInfo(CellInfo rval_ s);
CellInfo() {}
~CellInfo();
};

View file

@ -36,7 +36,6 @@ private:
Color normalized_color;
int h16, s16, v16;
int round_step;
int wheel_style;
enum STYLE { S_WHEEL, S_RECT, S_HEXAGON };
STYLE style;
Image cache;

View file

@ -288,7 +288,7 @@ void HeaderCtrl::Distribute(const Vector<int>& sci, double delta)
if(fabs(delta) < eps)
break;
ci = nci;
ci = pick(nci);
if(ci.GetCount() == 0) {
double psm = 0;
for(int i = 0; i < sci.GetCount(); i++)

View file

@ -25,7 +25,7 @@ bool HelpWindow::GoTo0(const String& link)
Title(FromUtf8(t.title));
RichText txt = ParseQTF(t.text);
FinishText(txt);
view.Pick(txt, zoom);
view.Pick(pick(txt), zoom);
view.GotoLabel(label, true);
current_link = link;
tree.FindSetCursor(topic);

View file

@ -51,8 +51,8 @@ public:
Callback1<int> WhenMouseMove;
void Clear();
void Pick(pick_ RichText& t);
void Pick(pick_ RichText& txt, Zoom z);
void Pick(RichText rval_ t);
void Pick(RichText rval_ txt, Zoom z);
void SetQTF(const char *qtf, Zoom z = Zoom(1, 1));
const RichText& Get() const { return text; }
String GetQTF(byte cs = CHARSET_UTF8) const { return AsQTF(text, cs); }

View file

@ -301,20 +301,20 @@ void RichTextView::Clear()
anchor = cursor = sell = selh = 0;
}
void RichTextView::Pick(pick_ RichText& rt)
void RichTextView::Pick(RichText rval_ rt)
{
sb = 0;
anchor = cursor = sell = selh = 0;
text = rt;
text = pick(rt);
SetSb();
UpdateRefresh();
highlight = -1;
}
void RichTextView::Pick(pick_ RichText& txt, Zoom z) {
void RichTextView::Pick(RichText rval_ txt, Zoom z) {
if(z.m != z.d)
const_cast<RichText&>(txt).ApplyZoom(z);
Pick(txt);
Pick(pick(txt));
sb.SetLine(z * 100);
}

View file

@ -198,16 +198,16 @@ void TextCtrl::ClearDirty()
TextCtrl::UndoData TextCtrl::PickUndoData()
{
UndoData data;
data.undo = undo;
data.redo = redo;
data.undo = pick(undo);
data.redo = pick(redo);
data.undoserial = undoserial;
return data;
}
void TextCtrl::SetPickUndoData(pick_ TextCtrl::UndoData& data)
void TextCtrl::SetPickUndoData(TextCtrl::UndoData rval_ data)
{
undo = data.undo;
redo = data.redo;
undo = pick(data.undo);
redo = pick(data.redo);
undoserial = data.undoserial;
incundoserial = true;
}

View file

@ -163,7 +163,7 @@ public:
void ClearUndo() { undo.Clear(); redo.Clear(); }
bool IsUndoOp() const { return undo_op; }
UndoData PickUndoData();
void SetPickUndoData(pick_ UndoData& data);
void SetPickUndoData(UndoData rval_ data);
void Cut();
void Copy();

View file

@ -380,7 +380,6 @@ private:
int showwidth;
bool up;
bool open;
int droplines;
void DoClose();
void OpenClose(int i);

View file

@ -113,10 +113,10 @@ void AddRefreshRect(Vector<Rect>& invalid, const Rect& _r)
for(int i = 0; i < inv.GetCount(); i++) {
bool ch = false;
Vector<Rect> rs1 = Subtract(rs, inv[i], ch);
if(ch) rs = rs1;
if(ch) rs = pick(rs1);
}
inv.AppendPick(rs);
invalid = inv;
inv.AppendPick(pick(rs));
invalid = pick(inv);
}
void DrawFatFrame(Draw& w, int x, int y, int cx, int cy, Color color, int n) {

View file

@ -70,7 +70,7 @@ void ImageBuffer::Set(Image& img)
hotspot = img.GetHotSpot();
spot2 = img.Get2ndSpot();
dots = img.GetDots();
pixels = img.data->buffer.pixels;
pixels = pick(img.data->buffer.pixels);
img.Clear();
}
else {
@ -106,7 +106,7 @@ ImageBuffer::ImageBuffer(ImageBuffer& b)
kind = b.kind;
size = b.size;
dots = b.dots;
pixels = b.pixels;
pixels = pick(b.pixels);
hotspot = b.hotspot;
spot2 = b.spot2;
}

View file

@ -460,14 +460,14 @@ void Filter(RasterEncoder& target, Raster& src, ImageFilter9& filter)
sLine(target, sz.cx, l, filter);
target.WriteLine();
for(int y = 1; y < sz.cy - 1; y++) {
l[0] = l[1];
l[1] = l[2];
l[0] = pick(l[1]);
l[1] = pick(l[2]);
l[2] = src[y + 1];
sLine(target, sz.cx, l, filter);
target.WriteLine();
}
l[0] = l[1];
l[1] = l[2];
l[0] = pick(l[1]);
l[1] = pick(l[2]);
l[2] = src[sz.cy - 1];
sLine(target, sz.cx, l, filter);
target.WriteLine();

View file

@ -52,7 +52,7 @@ int Raster::GetPageDisposal(int n)
return 0;
}
void Raster::Line::Pick(pick_ Line& b)
void Raster::Line::Pick(Line rval_ b)
{
data = b.data;
fmtdata = b.fmtdata;

View file

@ -85,7 +85,7 @@ public:
void MakeRGBA() const;
void Free() { if(free) delete[] data; if(fmtfree) delete[] fmtdata; }
void Pick(pick_ Line& b);
void Pick(Line rval_ b);
public:
const RGBA *GetRGBA() const { if(!data) MakeRGBA(); return data; }
@ -97,11 +97,11 @@ public:
: data(data), fmtdata((byte *)data), raster(NULL), free(free), fmtfree(false) {}
Line(const byte *fmtdata, Raster *raster, bool fmtfree)
: data(NULL), fmtdata(fmtdata), raster(raster), free(false), fmtfree(fmtfree) {}
Line(pick_ Line& b) { Pick(b); }
Line(Line rval_ b) { Pick(pick(b)); }
Line() { data = NULL; fmtdata = NULL; raster = NULL; free = fmtfree = false; }
~Line() { Free(); }
void operator=(pick_ Line& b) { Free(); Pick(b); }
void operator=(Line rval_ b) { Free(); Pick(pick(b)); }
};
struct Info {

View file

@ -152,15 +152,15 @@ public:
{
Node() {}
Node(int branch) : branch(branch) {}
Node(One<Split> split) : branch(-1), split(split) {}
Node(One<Split> rval_ split) : branch(-1), split(pick(split)) {}
int branch;
One<Split> split;
};
struct Split
{
Split(Pointf n, double c, pick_ Node& minus, pick_ Node& plus)
: n(n), c(c), minus(minus), plus(plus) {}
Split(Pointf n, double c, Node rval_ minus, Node rval_ plus)
: n(n), c(c), minus(pick(minus)), plus(pick(plus)) {}
Pointf n;
double c; // np = c
@ -170,7 +170,7 @@ public:
struct Tree : GeomRefBase
{
Tree(pick_ Node& root) : root(root) {}
Tree(Node pick_ root) : root(pick(root)) {}
Node root;
};
@ -178,7 +178,7 @@ public:
public:
GisBSPTree() {}
GisBSPTree(int branch) : tree(new Tree(Node(branch))) {}
GisBSPTree(pick_ Node& root) : tree(new Tree(root)) {}
GisBSPTree(Node pick_ root) : tree(new Tree(pick(root))) {}
bool IsEmpty() const { return !tree->root.split; }
int GetBranch() const { return tree->root.branch; }

View file

@ -268,7 +268,7 @@ GisBSPTree GisCoordsConical::GetBranchTree(const Rectf& lonlat_extent) const
: GisBSPTree::Node(new GisBSPTree::Split(Pointf(1, 0), pm + 180,
GisBSPTree::Node(1),
GisBSPTree::Node(2))));
return GisBSPTree::Node(new GisBSPTree::Split(Pointf(1, 0), pm, minus, plus));
return GisBSPTree::Node(new GisBSPTree::Split(Pointf(1, 0), pm, pick(minus), pick(plus)));
}
Pointf GisCoordsConical::Project(Pointf lonlat, int branch) const

View file

@ -408,8 +408,8 @@ void SplitPolygon(const Point *vertices, int vertex_count, const int *counts, in
PolygonIterator<int> pi(clip, max_trace_points);
pi.Add(vertices, vertex_count, counts, count_count);
pi.Run();
out_vertices = pi.out_vertices;
out_counts = pi.out_counts;
out_vertices = pick(pi.out_vertices);
out_counts = pick(pi.out_counts);
}
void SplitPolygon(const Vector<Point>& vertices, const Vector<int>& counts,
@ -426,8 +426,8 @@ void SplitPolygon(Array<Pointf>::ConstIterator vertices, int vertex_count, const
PolygonIterator<double> pi(clip, max_trace_points);
pi.Add(vertices, vertex_count, counts, count_count);
pi.Run();
out_vertices = pi.out_vertices;
out_counts = pi.out_counts;
out_vertices = pick(pi.out_vertices);
out_counts = pick(pi.out_counts);
}
void SplitPolygon(const Array<Pointf>& vertices, const Vector<int>& counts,
@ -682,7 +682,7 @@ void PolygonIterator<T>::Run()
Flush(flush, y);
Trace& n = traces.Insert(i1);
i2++;
n.avail = segments[s];
n.avail = pick(segments[s]);
n.next = n.avail.Begin();
n.stop = n.avail.End() - 1;
n.end = *++n.next;
@ -690,7 +690,7 @@ void PolygonIterator<T>::Run()
if(i1 & 1)
{ // hole opening
Trace& r = traces[i1 + 1];
n.done = r.done;
n.done = pick(r.done);
#if POLY_LOGGING
RLOG("insert: r.ypos = " << r.ypos);
if(r.ypos.y < n.done.Top().y)
@ -714,7 +714,7 @@ void PolygonIterator<T>::Run()
else // simply insert segment
n.Add(n.next[-1]);
Trace& o = traces.Insert(i2);
o.avail = segments[s + 1];
o.avail = pick(segments[s + 1]);
o.next = o.avail.Begin();
o.stop = o.avail.End() - 1;
o.Add(*o.next);

View file

@ -22,7 +22,7 @@ void BufferPainter::EndOp()
FinishMask();
if(attr.onpath) {
attr.onpath = false;
onpath = onpathstack.Top();
onpath = pick(onpathstack.Top());
onpathstack.Drop();
pathlen = pathlenstack.Pop();
}

View file

@ -24,7 +24,7 @@ void BufferPainter::BeginOnPathOp(double q, bool abs)
}
}
attrstack.Top().onpath = true;
onpathstack.Add() = onpath;
onpathstack.Add() = pick(onpath);
pathlenstack.Add(pathlen);
onpath.Clear();
pathlen = 0;

View file

@ -209,7 +209,7 @@ Buffer<ClippingLine> BufferPainter::RenderPath(double width, SpanSource *ss, con
}
current = Null;
if(width == ONPATH) {
onpath = onpathtarget.path;
onpath = pick(onpathtarget.path);
pathlen = onpathtarget.len;
}
return newclip;
@ -229,9 +229,9 @@ void BufferPainter::ClipOp()
{
Buffer<ClippingLine> newclip = RenderPath(CLIP, NULL, RGBAZero());
if(attr.hasclip)
clip.Top() = newclip;
clip.Top() = pick(newclip);
else {
clip.Add() = newclip;
clip.Add() = pick(newclip);
attr.hasclip = true;
attr.cliplevel = clip.GetCount();
}

View file

@ -82,7 +82,7 @@ struct sMakeGlyph : LRUCache<Value, GlyphKey>::Maker {
gp.tolerance = gk.tolerance;
PaintCharacter(gp, Pointf(0, 0), gk.chr, gk.fnt);
int sz = gp.glyph.GetCount() * 4;
v = RawPickToValue(gp.glyph);
v = RawPickToValue(pick(gp.glyph));
return sz;
}
};

View file

@ -202,7 +202,7 @@ void RichEdit::Copy()
ZoomClip(txt);
ClearClipboard();
AppendClipboardUnicodeText(txt.GetPlainText());
Value clip = RawPickToValue(txt);
Value clip = RawPickToValue(pick(txt));
AppendClipboard("text/QTF", clip, sQTF);
AppendClipboard(RTFS, clip, sRTF);
if(objectpos >= 0) {

View file

@ -400,7 +400,7 @@ void RichEdit::Clear()
zsc = 0;
}
void RichEdit::SetupLanguage(pick_ Vector<int>& _lng)
void RichEdit::SetupLanguage(Vector<int> rval_ _lng)
{
Vector<int>& lng = const_cast<Vector<int>&>(_lng);
Sort(lng);
@ -409,16 +409,15 @@ void RichEdit::SetupLanguage(pick_ Vector<int>& _lng)
language.Add(lng[i], lng[i] ? LNGAsText(lng[i]) : String(t_("None")));
}
void RichEdit::Pick(pick_ RichText& t)
void RichEdit::Pick(RichText pick_ t)
{
Clear();
text = t;
text = pick(t);
if(text.GetPartCount() == 0)
text.Cat(RichPara());
ReadStyles();
EndSizeTracking();
Vector<int> all_lang = text.GetAllLanguages();
SetupLanguage(all_lang);
SetupLanguage(text.GetAllLanguages());
Move(0);
Update();
}
@ -519,18 +518,18 @@ RichEdit::UndoInfo RichEdit::PickUndoInfo()
{
UndoInfo f;
f.undoserial = undoserial;
f.undo = undo;
f.redo = redo;
f.undo = pick(undo);
f.redo = pick(redo);
Clear();
return f;
}
void RichEdit::SetPickUndoInfo(pick_ UndoInfo& f)
void RichEdit::SetPickUndoInfo(UndoInfo pick_ f)
{
undoserial = f.undoserial;
incundoserial = true;
undo = f.undo;
redo = f.redo;
undo = pick(f.undo);
redo = pick(f.redo);
Finish();
}

View file

@ -151,7 +151,7 @@ void RichEdit::Language()
for(int i = 0; i < language.GetCount(); i++)
h.Add(language.GetKey(i));
h.Add(~d.lang);
SetupLanguage(h);
SetupLanguage(pick(h));
}
}

View file

@ -256,7 +256,7 @@ RichText RichEdit::GetSelection(int maxcount) const
if(tablesel) {
RichTable tab = text.CopyTable(tablesel, cells);
clip.SetStyles(text.GetStyles());
clip.CatPick(tab);
clip.CatPick(pick(tab));
}
else {
if(begtabsel) {
@ -264,7 +264,7 @@ RichText RichEdit::GetSelection(int maxcount) const
if(p.table) {
RichTable tab = text.CopyTable(p.table);
clip.SetStyles(text.GetStyles());
clip.CatPick(tab);
clip.CatPick(pick(tab));
clip.CatPick(text.Copy(p.tablen + 1, minmax(abs(cursor - p.tablen - 1), 0, maxcount)));
}
}

View file

@ -509,7 +509,7 @@ private:
void SetPaper();
void SetLanguage();
void Language();
void SetupLanguage(pick_ Vector<int>& lng);
void SetupLanguage(Vector<int> rval_ lng);
void SetBullet(int bullet);
@ -776,7 +776,7 @@ public:
void PrevPara();
void Clear();
void Pick(pick_ RichText& t);
void Pick(RichText pick_ t);
void SetQTF(const char *qtf) { Pick(ParseQTF(qtf, 0, context)); }
const RichText& Get() const { return text; }
String GetQTF(byte cs = CHARSET_UTF8) const { return AsQTF(text, cs); }
@ -822,7 +822,7 @@ public:
};
UndoInfo PickUndoInfo();
void SetPickUndoInfo(pick_ UndoInfo& f);
void SetPickUndoInfo(UndoInfo pick_ f);
PosInfo GetPosInfo() const;
void SetPosInfo(const PosInfo& pos);

View file

@ -41,7 +41,7 @@ void RichEdit::InsertTable()
p.format.newpage = false;
p.format.label.Clear();
h.Cat(p);
table.SetPick(i, j, h);
table.SetPick(i, j, pick(h));
}
NextUndo();
if(cursorp.posinpara)

View file

@ -1,7 +1,7 @@
#ifndef _RichEdit_icpp_init_stub
#define _RichEdit_icpp_init_stub
#include "CtrlLib/init"
#define BLITZ_INDEX__ F8db56c659ae621fee9530fc849c1b0ec
#define BLITZ_INDEX__ F517b719d199b5babccb3788b668ebd68
#include "RichEdit.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -62,18 +62,18 @@ void RichText::PaintHeaderFooter(PageDraw& pw, const Rect& page, const PaintInfo
}
}
void RichText::PickHeader(pick_ RichText& txt)
void RichText::PickHeader(RichText rval_ txt)
{
RichText b = txt;
RichText b = pick(txt);
b.ClearHeader();
header.Create() = b;
header.Create() = pick(b);
}
void RichText::PickFooter(pick_ RichText& txt)
void RichText::PickFooter(RichText rval_ txt)
{
RichText b = txt;
RichText b = pick(txt);
b.ClearFooter();
footer.Create() = b;
footer.Create() = pick(b);
}
void RichText::SetHeaderQtf(const char *qtf)

View file

@ -213,6 +213,8 @@ struct RichPara {
void Justify(const Format& format);
int BodyHeight() const;
rval_default(Lines);
Lines();
~Lines();
@ -289,6 +291,8 @@ struct RichPara {
void CacheId(int64 id);
rval_default(RichPara);
RichPara();
~RichPara();
@ -317,13 +321,6 @@ inline bool operator==(const RichPara::Tab& a, const RichPara::Tab& b) {
return a.pos == b.pos && a.align == b.align && a.fillchar == b.fillchar;
}
bool operator==(const Vector<RichPara::Tab>& a, const Vector<RichPara::Tab>& b);
inline
bool operator!=(const Vector<RichPara::Tab>& a, const Vector<RichPara::Tab>& b) {
return !(a == b);
}
bool NumberingDiffers(const RichPara::Format& fmt1, const RichPara::Format& fmt2);
void Sort(Vector<RichPara::Tab>& tab);

View file

@ -29,7 +29,7 @@ RichPara::~RichPara()
Mutex::Lock __(cache_lock);
Array<RichPara>& cache = Cache();
incache = true;
cache.InsertPick(0, *this);
cache.InsertPick(0, pick(*this));
int total = 0;
for(int i = 1; i < cache.GetCount(); i++) {
total += cache[i].GetLength();
@ -154,15 +154,6 @@ bool NumberingDiffers(const RichPara::Format& fmt1, const RichPara::Format& fmt2
memcmp(fmt1.number, fmt2.number, sizeof(fmt1.number));
}
bool operator==(const Vector<RichPara::Tab>& a, const Vector<RichPara::Tab>& b)
{
if(a.GetCount() != b.GetCount()) return false;
for(int i = 0; i < a.GetCount(); i++)
if(a[i].pos != b[i].pos || a[i].align != b[i].align || a[i].fillchar != b[i].fillchar)
return false;
return true;
}
RichPara::CharFormat::CharFormat()
{
(Font &)*this = Arial(100);
@ -573,7 +564,7 @@ void RichPara::Unpack(const String& data, const Array<RichObject>& obj,
Array<RichPara>& cache = Cache();
for(int i = 0; i < cache.GetCount(); i++)
if(cache[i].cacheid == cacheid) {
*this = cache[i];
*this = pick(cache[i]);
incache = false;
cache.Remove(i);
return;

View file

@ -218,8 +218,8 @@ RichPara::Lines::~Lines()
Mutex::Lock __(cache_lock);
Array<Lines>& cache = Cache();
incache = true;
cache.Insert(0) = *this;
cache.SetCount(1);
cache.Insert(0) = pick(*this);
// cache.SetCount(1);
int total = 0;
for(int i = 1; i < cache.GetCount(); i++) {
total += cache[i].clen;
@ -240,7 +240,7 @@ RichPara::Lines RichPara::FormatLines(int acx) const
Array<Lines>& cache = Lines::Cache();
for(int i = 0; i < cache.GetCount(); i++)
if(cache[i].cacheid == cacheid && cache[i].cx == acx) {
lines = cache[i];
lines = pick(cache[i]);
lines.incache = false;
cache.Remove(i);
return lines;

View file

@ -242,9 +242,9 @@ void RichQtfParser::EndPart()
if(istable) {
if(paragraph.GetCount() == 0 && text.GetCount() == 0)
if(table.GetCount())
table.Top().text.CatPick(tablepart);
table.Top().text.CatPick(pick(tablepart));
else
target.CatPick(tablepart);
target.CatPick(pick(tablepart));
else {
paragraph.part.Clear();
text.Clear();
@ -458,7 +458,7 @@ void RichQtfParser::FinishCell()
i = b.cell / t.GetColumns();
j = b.cell % t.GetColumns();
}
t.SetPick(i, j, b.text);
t.SetPick(i, j, pick(b.text));
b.text.Clear();
t.SetFormat(i, j, b.format);
t.SetSpan(i, j, b.vspan, b.hspan);
@ -475,7 +475,7 @@ void RichQtfParser::FinishCell()
void RichQtfParser::FinishTable()
{
FinishCell();
tablepart = Table();
tablepart = pick(Table());
istable = true;
table.Drop();
}
@ -503,7 +503,7 @@ void RichQtfParser::FinishOldTable()
if(h.GetCount() == 0)
Error("table");
Sort(h);
pos = h;
pos = pick(h);
pos.Add(10000);
RichTable tab;
tab.SetFormat(t.GetFormat());
@ -527,9 +527,9 @@ void RichQtfParser::FinishOldTable()
}
table.Drop();
if(table.GetCount())
table.Top().text.CatPick(tab);
table.Top().text.CatPick(pick(tab));
else
target.CatPick(tab);
target.CatPick(pick(tab));
oldtab = false;
}
@ -1011,7 +1011,7 @@ bool ParseQTF(RichText& txt, const char *qtf, int accesskey, void *context)
catch(RichQtfParser::Exc) {
return false;
}
txt = p.target;
txt = pick(p.target);
return true;
}
@ -1022,7 +1022,7 @@ RichText ParseQTF(const char *qtf, int accesskey, void *context)
p.Parse(qtf, accesskey);
}
catch(RichQtfParser::Exc) {}
return p.target;
return pick(p.target);
}
String QtfRichObject::ToString() const

View file

@ -110,6 +110,9 @@ private:
Rect page;
int page0;
Size sz;
rval_default(TabLayout);
TabLayout() {}
};
mutable TabLayout clayout;
@ -198,7 +201,7 @@ private:
public:
void AddColumn(int cx);
void SetPick(int i, int j, pick_ RichTxt& text);
void SetPick(int i, int j, RichTxt rval_ text);
RichTxt GetPick(int i, int j);
const RichTxt& Get(int i, int j) const { return cell[i][j].text; }
void SetQTF(int i, int j, const char *qtf);
@ -216,6 +219,8 @@ public:
void Normalize();
rval_default(RichTable);
RichTable(const RichTable& src, int);
RichTable();
};

View file

@ -265,14 +265,14 @@ void RichTable::AddColumn(int cx)
format.column.Add(cx);
}
void RichTable::SetPick(int i, int j, pick_ RichTxt& text)
void RichTable::SetPick(int i, int j, RichTxt rval_ text)
{
cell.At(i).At(j).text = text;
cell.At(i).At(j).text = pick(text);
}
RichTxt RichTable::GetPick(int i, int j)
{
return cell[i][j].text;
return pick(cell[i][j].text);
}
void RichTable::SetQTF(int i, int j, const char *qtf)

View file

@ -39,7 +39,7 @@ public:
RichPara Get(int i) const { return RichTxt::Get(i, style); }
void Cat(const RichPara& p) { RichTxt::Cat(p, style); }
void CatPick(pick_ RichText& p);
void CatPick(RichText rval_ p);
using RichTxt::CatPick;
RichContext Context(const Rect& page) const;
@ -131,8 +131,8 @@ public:
static void Register(ClipboardType& type);
void PickHeader(pick_ RichText& txt);
void PickFooter(pick_ RichText& txt);
void PickHeader(RichText rval_ txt);
void PickFooter(RichText rval_ txt);
void SetHeaderQtf(const char *qtf);
void SetFooterQtf(const char *qtf);
void ClearHeader() { header.Clear(); }
@ -150,5 +150,7 @@ public:
RichText() { Init(); }
RichText(const RichText& x, int);
RichText(pick_ RichTxt& x, pick_ RichStyles& st);
RichText(RichTxt rval_ x, RichStyles rval_ st);
rval_default(RichText);
};

View file

@ -2,11 +2,11 @@
NAMESPACE_UPP
void RichText::CatPick(pick_ RichText& p)
void RichText::CatPick(RichText rval_ p)
{
MergeStyles(p);
int c = part.GetCount();
part.AppendPick(p.part);
part.AppendPick(pick(p.part));
for(int i = c; i < part.GetCount(); i++)
if(IsPara(i))
part[i].Get<Para>().Invalidate();
@ -166,7 +166,7 @@ RichText RichText::Copy(int pos, int count) const
r.Cat(txt.Get(pi, style));
else {
RichTable tab(txt.GetTable(pi), 1);
r.CatPick(tab);
r.CatPick(pick(tab));
}
pi++;
}
@ -332,8 +332,8 @@ RichText::RichText(const RichText& x, int)
nolinks = x.nolinks;
}
RichText::RichText(pick_ RichTxt& x, pick_ RichStyles& st)
: RichTxt(x), style(st)
RichText::RichText(RichTxt rval_ x, RichStyles rval_ st)
: RichTxt(pick(x)), style(pick(st))
{
nolinks = false;
}

View file

@ -129,7 +129,7 @@ struct RichText::OverrideStylesOp : RichTxt::ParaOp {
void RichText::OverrideStyles(const RichStyles& ms, bool matchname, bool addmissing)
{
Invalidate();
RichStyles orig = style;
RichStyles orig = pick(style);
style <<= ms;
OverrideStylesOp op;
for(int i = 0; i < orig.GetCount(); i++) {

View file

@ -23,7 +23,7 @@ int RichText::SetTable(int pos, const RichTable& table)
int pi = txt.FindPart(pos);
ASSERT(pos == 0 && txt.GetPartLength(pi) == 0 && txt.IsPara(pi));
RichTable pt(table, 1);
txt.SetPick(pi, pt);
txt.SetPick(pi, pick(pt));
return GetRichPos(bpos).table;
}
@ -156,7 +156,7 @@ void RichText::JoinCell(int table, const Rect& sel)
RichTxt& t = tab[i][j].text;
for(int pi = 0; pi < t.GetPartCount(); pi++)
if(t.IsTable(pi))
cell.text.CatPick(t.part[pi].Get<RichTable>());
cell.text.CatPick(pick(t.part[pi].Get<RichTable>()));
else
if(pi < t.GetPartCount() - 1 || t.GetPartLength(pi))
cell.text.Cat(t.Get(pi, style), style);

View file

@ -216,8 +216,8 @@ public:
void ClearSpelling();
void SetPick(int parti, pick_ RichTable& table);
void CatPick(pick_ RichTable& table) { SetPick(GetPartCount(), table); }
void SetPick(int parti, RichTable rval_ table);
void CatPick(RichTable rval_ table) { SetPick(GetPartCount(), pick(table)); }
void Set(int parai, const RichPara& p, const RichStyles& s);
void Insert(int parai, const RichPara& p, const RichStyles& s);
void Cat(const RichPara& p, const RichStyles& s) { Set(GetPartCount(), p, s); }
@ -245,6 +245,8 @@ public:
RichTxt(const RichTxt& src, int);
RichTxt();
rval_default(RichTxt);
#ifdef _DEBUG
void Dump();
#endif

View file

@ -159,10 +159,10 @@ void RichTxt::RemovePart(int parti)
Invalidate();
}
void RichTxt::SetPick(int i, pick_ RichTable& p)
void RichTxt::SetPick(int i, RichTable rval_ p)
{
const_cast<RichTable&>(p).Normalize();
part.At(i).Create<RichTable>() = p;
part.At(i).Create<RichTable>() = pick(p);
Invalidate();
SetRefresh(i);
}

View file

@ -176,7 +176,7 @@ Array<Drawing> RenderPages(const RichText& txt, Size pagesize)
paintinfo.hyperlink = Null;
txt.Paint(pd, pagesize, paintinfo);
pd.Flush();
return pd.page;
return pick(pd.page);
}
String Pdf(const RichText& txt, Size pagesize, int margin, bool pdfa)

View file

@ -2,7 +2,7 @@
#define _RichText_icpp_init_stub
#include "plugin\png/init"
#include "Draw/init"
#define BLITZ_INDEX__ F879f8417b17173ef5a1decd1d548c525
#define BLITZ_INDEX__ Fe9a5c3f383dfd330a482e67c81d55694
#include "RichImage.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -190,7 +190,6 @@ void MacroSet::Serialize(Stream& s) {
macro.Clear();
for(int i = 0; i < n; i++) {
String key;
Macro value;
s % key;
s % macro.Add(key);
}
@ -198,10 +197,8 @@ void MacroSet::Serialize(Stream& s) {
else
for(int i = 0; i < n; i++) {
String key;
Macro value;
key = macro.GetKey(i);
value = macro[i];
s % key % value;
s % key % macro[i];
}
}

View file

@ -171,7 +171,6 @@ FileTabs& FileTabs::operator<<(const FileTabs &src)
}
FileTabs::FileTabs() :
normalicons(true),
stackedicons(false),
greyedicons(true),
filecolor(SColorLabel),

View file

@ -1,7 +1,6 @@
class FileTabs : public TabBar
{
private:
bool normalicons:1;
bool stackedicons:1;
bool greyedicons:1;
Color filecolor;

Some files were not shown because too many files have changed in this diff Show more