cpp11 branch - committing the merge (rest of it)

git-svn-id: svn://ultimatepp.org/upp/trunk@7048 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-03-16 16:35:29 +00:00
parent ba7ab3ed50
commit 0e04c59abc
58 changed files with 1176 additions and 2335 deletions

4
tutorial/Core01/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Core01_icpp_init_stub
#define _Core01_icpp_init_stub
#include "Core/init"
#endif

View file

@ -9,15 +9,15 @@ CONSOLE_APP_MAIN
v.Add(2);
DUMPC(v);
Vector<int> v1 = v;
Vector<int> v1 = pick(v);
DUMPC(v1);
// DUMPC(v); -> v is picked, this would crash with runtime error
v <<= v1;
v = clone(v1);
DUMPC(v1);
DUMPC(v);
Vector<int> v2(v, 0);
Vector<int> v2 = clone(v);
DUMPC(v2);
DUMPC(v);
}

4
tutorial/Ntl03/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl03_icpp_init_stub
#define _Ntl03_icpp_init_stub
#include "Core/init"
#endif

View file

@ -13,7 +13,7 @@ Distribution CreateDist(int n)
d.text << "Test (create) " << n;
for(int i = 0; i < 10000; i++)
d.data.At(rand() % n, 0)++;
return d;
return pick(d);
}
void Dump(const Vector<Distribution>& dist)

4
tutorial/Ntl04/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl04_icpp_init_stub
#define _Ntl04_icpp_init_stub
#include "Core/init"
#endif

4
tutorial/Ntl05/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl05_icpp_init_stub
#define _Ntl05_icpp_init_stub
#include "Core/init"
#endif

View file

@ -6,20 +6,22 @@ struct Number {
virtual double Get() const = 0;
String ToString() const { return AsString(Get()); }
virtual ~Number() {}
};
struct Integer : public Number {
int n;
virtual double Get() const { return n; }
Integer(int n) : n(n) {}
Integer() {}
};
struct Double : public Number {
double n;
virtual double Get() const { return n; }
Double(double n) : n(n) {}
Double() {}
};
bool operator<(const Number& a, const Number& b)
@ -30,12 +32,8 @@ bool operator<(const Number& a, const Number& b)
CONSOLE_APP_MAIN
{
Array<Number> num;
num.Add(new Integer(3));
num.Add(new Double(15.5));
num.Add(new Double(2.23));
num.Add(new Integer(2));
num.Add(new Integer(20));
num.Add(new Double(-2.333));
num.Create<Double>().n = 15.5;
num.Create<Integer>().n = 3;
DUMPC(num);
Sort(num);
DUMPC(num);

4
tutorial/Ntl06/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl06_icpp_init_stub
#define _Ntl06_icpp_init_stub
#include "Core/init"
#endif

View file

@ -6,22 +6,29 @@ struct Number {
virtual double Get() const = 0;
String ToString() const { return AsString(Get()); }
virtual ~Number() {}
};
struct Integer : public Number {
int n;
virtual double Get() const { return n; }
Integer(int n) : n(n) {}
Integer() {}
};
struct Double : public Number {
double n;
virtual double Get() const { return n; }
Double(double n) : n(n) {}
Double() {}
};
bool operator<(const Number& a, const Number& b)
{
return a.Get() < b.Get();
}
CONSOLE_APP_MAIN
{
BiVector<int> n;
@ -38,11 +45,9 @@ CONSOLE_APP_MAIN
DUMPC(n);
BiArray<Number> num;
num.AddHead(new Integer(3));
num.AddTail(new Double(15.5));
num.AddHead(new Double(2.23));
num.AddTail(new Integer(2));
num.AddHead(new Integer(20));
num.AddTail(new Double(-2.333));
num.CreateHead<Integer>().n = 3;
num.CreateTail<Double>().n = 15.5;
num.CreateHead<Double>().n = 2.23;
num.CreateTail<Integer>().n = 2;
DUMPC(num);
}

4
tutorial/Ntl07/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl07_icpp_init_stub
#define _Ntl07_icpp_init_stub
#include "Core/init"
#endif

4
tutorial/Ntl08/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl08_icpp_init_stub
#define _Ntl08_icpp_init_stub
#include "Core/init"
#endif

View file

@ -6,50 +6,13 @@ struct Person : Moveable<Person> {
String name;
String surname;
unsigned GetHashValue() const { return CombineHash(name, surname); }
bool operator==(const Person& b) const { return name == b.name && surname == b.surname; }
Person(String name, String surname) : name(name), surname(surname) {}
Person() {}
};
unsigned GetHashValue(const Person& p)
{
return CombineHash(p.name, p.surname);
}
bool operator==(const Person& a, const Person& b)
{
return a.name == b.name && a.surname == b.surname;
}
struct Number {
virtual double Get() const = 0;
String ToString() const { return AsString(Get()); }
};
struct Integer : public Number {
int n;
virtual double Get() const { return n; }
Integer(int n) : n(n) {}
};
struct Double : public Number {
double n;
virtual double Get() const { return n; }
Double(double n) : n(n) {}
};
unsigned GetHashValue(const Number& n)
{
return GetHashValue(n.Get());
}
bool operator==(const Number& a, const Number& b)
{
return a.Get() == b.Get();
}
CONSOLE_APP_MAIN
{
Index<Person> p;
@ -58,12 +21,4 @@ CONSOLE_APP_MAIN
p.Add(Person("Carl", "Engles"));
DUMP(p.Find(Person("Paul", "Carpenter")));
ArrayIndex<Number> n;
n.Add(new Integer(100));
n.Add(new Double(10.5));
n.Add(new Integer(200));
n.Add(new Double(20.5));
DUMP(n.Find(Double(10.5)));
}

4
tutorial/Ntl09/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl09_icpp_init_stub
#define _Ntl09_icpp_init_stub
#include "Core/init"
#endif

View file

@ -21,22 +21,29 @@ struct Number {
virtual double Get() const = 0;
String ToString() const { return AsString(Get()); }
virtual ~Number() {}
};
struct Integer : public Number {
int n;
virtual double Get() const { return n; }
Integer(int n) : n(n) {}
Integer() {}
};
struct Double : public Number {
double n;
virtual double Get() const { return n; }
Double(double n) : n(n) {}
Double() {}
};
bool operator<(const Number& a, const Number& b)
{
return a.Get() < b.Get();
}
CONSOLE_APP_MAIN
{
VectorMap<String, Person> m;
@ -89,8 +96,8 @@ CONSOLE_APP_MAIN
DUMPC(ps);
ArrayMap<String, Number> am;
am.Add("A", new Integer(1));
am.Add("B", new Double(2.0));
am.Create<Integer>("A").n = 1;
am.Create<Double>("B").n = 2.1;
DUMPC(am.GetKeys());
DUMPC(am.GetValues());

4
tutorial/Ntl10/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl10_icpp_init_stub
#define _Ntl10_icpp_init_stub
#include "Core/init"
#endif

60
tutorial/Ntl11/Ntl11.cpp Normal file
View file

@ -0,0 +1,60 @@
#include <Core/Core.h>
using namespace Upp;
struct Base {
virtual String Get() = 0;
virtual ~Base() {}
};
struct Derived1 : Base {
virtual String Get() { return "Derived1"; }
};
struct Derived2 : Base {
virtual String Get() { return "Derived2"; }
};
void MakeDerived1(One<Base>& t)
{
t.Create<Derived1>();
}
void MakeDerived2(One<Base>& t)
{
t.Create<Derived2>();
}
VectorMap<int, void (*)(One<Base>&)> factories;
INITBLOCK {
factories.Add(0, MakeDerived1);
factories.Add(1, MakeDerived2);
};
void Create(One<Base>& t, int what)
{
(*factories.Get(what))(t);
}
CONSOLE_APP_MAIN
{
One<Base> s;
DUMP((bool)s);
s.Create<Derived1>();
DUMP((bool)s);
DUMP(s->Get());
s.Create<Derived2>();
DUMP((bool)s);
DUMP(s->Get());
s.Clear();
DUMP((bool)s);
Create(s, 0);
DUMP(s->Get());
}

11
tutorial/Ntl11/Ntl11.upp Normal file
View file

@ -0,0 +1,11 @@
description "One\377";
uses
Core;
file
Ntl11.cpp;
mainconfig
"" = "SSE2";

4
tutorial/Ntl11/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl11_icpp_init_stub
#define _Ntl11_icpp_init_stub
#include "Core/init"
#endif

27
tutorial/Ntl12/Ntl12.cpp Normal file
View file

@ -0,0 +1,27 @@
#include <Core/Core.h>
using namespace Upp;
void Do(Any& x)
{
if(x.Is<String>())
LOG("String: " << x.Get<String>());
if(x.Is<FileIn>()) {
LOG("--- File: ");
LOG(LoadStream(x.Get<FileIn>()));
LOG("----------");
}
if(x.IsEmpty())
LOG("empty");
}
CONSOLE_APP_MAIN
{
Any x;
x.Create<String>() = "Hello!";
Do(x);
x.Create<FileIn>().Open(GetDataFile("Ntl12.cpp"));
Do(x);
x.Clear();
Do(x);
}

11
tutorial/Ntl12/Ntl12.upp Normal file
View file

@ -0,0 +1,11 @@
description "Any\377";
uses
Core;
file
Ntl12.cpp;
mainconfig
"" = "SSE2";

4
tutorial/Ntl12/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl12_icpp_init_stub
#define _Ntl12_icpp_init_stub
#include "Core/init"
#endif

14
tutorial/Ntl13/Ntl13.cpp Normal file
View file

@ -0,0 +1,14 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
InVector<int> v;
for(int i = 0; i < 1000000; i++)
v.Add(i);
v.Insert(0, -1); // This is fast
DUMP(v[0]);
DUMP(v[1]);
DUMP(v.FindLowerBound(55));
}

11
tutorial/Ntl13/Ntl13.upp Normal file
View file

@ -0,0 +1,11 @@
description "InVector, InArray\377";
uses
Core;
file
Ntl13.cpp;
mainconfig
"" = "SSE2";

4
tutorial/Ntl13/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl13_icpp_init_stub
#define _Ntl13_icpp_init_stub
#include "Core/init"
#endif

25
tutorial/Ntl14/Ntl14.cpp Normal file
View file

@ -0,0 +1,25 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
SortedIndex<int> x;
x.Add(5);
x.Add(3);
x.Add(7);
x.Add(1);
DUMPC(x);
DUMP(x.Find(3));
DUMP(x.FindLowerBound(3));
DUMP(x.FindUpperBound(6));
SortedVectorMap<String, int> m;
m.Add("zulu", 11);
m.Add("frank", 12);
m.Add("alfa", 13);
DUMPM(m);
DUMP(m.Get("zulu"));
}

11
tutorial/Ntl14/Ntl14.upp Normal file
View file

@ -0,0 +1,11 @@
description "SortedIndex, SortedVectorMap, SortedArrayMap\377";
uses
Core;
file
Ntl14.cpp;
mainconfig
"" = "SSE2";

4
tutorial/Ntl14/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl14_icpp_init_stub
#define _Ntl14_icpp_init_stub
#include "Core/init"
#endif

36
tutorial/Ntl15/Ntl15.cpp Normal file
View file

@ -0,0 +1,36 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
Tuple3<int, String, String> x = MakeTuple<int, String, String>(12, "hello", "world");
DUMP(x.a);
DUMP(x.b);
DUMP(x.c);
DUMP(x);
DUMP(GetHashValue(x));
Tuple3<int, String, String> y = x;
DUMP(x != y);
DUMP(x.Compare(y));
y.b = "a";
DUMP(SgnCompare(y));
DUMP(x < y);
static Tuple2<int, const char *> map[] = {
{ 1, "one" },
{ 2, "one" },
{ 3, "one" },
};
Tuple2<int, const char *> *f = FindTuple(map, __countof(map), 2);
if(f)
DUMP(f->b);
}

11
tutorial/Ntl15/Ntl15.upp Normal file
View file

@ -0,0 +1,11 @@
description "Tuples\377";
uses
Core;
file
Ntl15.cpp;
mainconfig
"" = "SSE2";

4
tutorial/Ntl15/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Ntl15_icpp_init_stub
#define _Ntl15_icpp_init_stub
#include "Core/init"
#endif

View file

@ -54,5 +54,5 @@ file
www.t;
mainconfig
"" = "MT SKELETON RAINBOW";
"" = "MT SKELETON RAINBOW NOGTK";

View file

@ -669,8 +669,11 @@ void ExportPage(int i)
.BgColor(bg)
.Alink(Red).Link(Black).Vlink(Blue)
/ html;
SaveFile(AppendFileName(targetdir, links[i]), content);
RLOG("Exported page " << links[i]);
if(!SaveFile(AppendFileName(targetdir, links[i]), content)) {
RLOG("SaveFile failed!");
abort();
}
RLOG("Exported page " << AppendFileName(targetdir, links[i]));
}
String Downloads()

View file

@ -2,17 +2,18 @@
using namespace Upp;
struct ArrayOneHelper {
Array<T> array;
One<T> one;
public:
operator One<T>&();
~ArrayOneHelper() { array.Add(one.Detach()); }
};
CONSOLE_APP_MAIN
{
Test(array.AddOne());
Array< Vector<int> > a;
a.Add() << 1 << 2 << 3;
auto b = clone(a);
DUMPCC(a);
DUMPCC(b);
Vector<int> h;
h.Insert(0, {1, 2, 3});
h.Insert(1, {5, 4, 3});
DDUMPC(h);
}

4
uppdev/ArrayOne/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _ArrayOne_icpp_init_stub
#define _ArrayOne_icpp_init_stub
#include "Core/init"
#endif

View file

@ -16,6 +16,7 @@ struct MyApp : TopWindow {
GUI_APP_MAIN
{
StdLogSetup(LOG_FILE|LOG_COUT);
// ChClassicSkin();
// ChStdSkin();
// SetLanguage(LNG_('P','L','P','L'));

File diff suppressed because it is too large Load diff

View file

@ -1,304 +0,0 @@
$uvs: PENDING CONFLICT
#ifndef _TabBar_TabBar_h_
#define _TabBar_TabBar_h_
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define IMAGECLASS TabBarImg
#define IMAGEFILE <TabBar/TabBar.iml>
#include <Draw/iml_header.h>
struct AlignedFrame : FrameCtrl<Ctrl>
{
int layout;
int framesize;
int border;
public:
enum
{
LEFT = 0,
TOP = 1,
RIGHT = 2,
BOTTOM = 3
};
AlignedFrame() : border(0), framesize(0), layout(TOP) {}
virtual void FrameLayout(Rect &r);
virtual void FrameAddSize(Size& sz);
virtual void FramePaint(Draw& w, const Rect& r);
bool IsVert() const { return (layout & 1) == 0; }
bool IsHorz() const { return layout & 1; }
bool IsTL() const { return layout < 2; }
bool IsBR() const { return layout >= 2; }
AlignedFrame& SetAlign(int align) { layout = align; FrameSet(); RefreshParentLayout(); return *this; }
AlignedFrame& SetLeft() { return SetAlign(LEFT); }
AlignedFrame& SetTop() { return SetAlign(TOP); }
AlignedFrame& SetRight() { return SetAlign(RIGHT); }
AlignedFrame& SetBottom() { return SetAlign(BOTTOM); }
AlignedFrame& SetFrameSize(int sz, bool refresh = true);
int GetAlign() const { return layout; }
int GetFrameSize() const { return framesize; }
int GetBorder() const { return border; }
protected:
void Fix(Size& sz);
void Fix(Point& p);
bool HasBorder() { return border >= 0; }
AlignedFrame& SetBorder(int _border) { border = _border; }
virtual void FrameSet() { }
};
class TabScrollBar : public AlignedFrame
{
private:
int total;
double pos, ps;
int new_pos;
int old_pos;
double start_pos;
double size;
double cs, ics;
virtual void UpdatePos(bool update = true);
void RefreshScroll();
bool ready;
Size sz;
public:
TabScrollBar();
virtual void Paint(Draw &w);
virtual void LeftDown(Point p, dword keyflags);
virtual void LeftUp(Point p, dword keyflags);
virtual void MouseMove(Point p, dword keyflags);
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
virtual void Layout();
int GetPos() const;
void SetPos(int p, bool dontscale = false);
void AddPos(int p, bool dontscale = false);
int GetTotal() const;
void AddTotal(int t);
void SetTotal(int t);
void GoEnd();
void GoBegin();
void Clear();
void Set(const TabScrollBar& t);
bool IsScrollable() const;
Callback WhenScroll;
};
class TabBar : public AlignedFrame
{
public:
struct Style : public TabCtrl::Style { };
protected:
enum
{
QT_MARGIN = 6,
QT_SPACE = 10,
QT_SBHEIGHT = 4,
QT_SBSEPARATOR = 1,
QT_FILEICON = 16,
QT_SPACEICON = 5
};
struct Tab : Moveable<Tab>
{
Value data;
String group;
bool visible;
int x, cx;
int y, cy;
int id;
Size tsz;
Tab() : visible(true), id(-1)
{}
int Right() const { return x + cx; }
bool HasMouse(const Point& p) const;
bool HasMouseCross(const Point& p, int h, int type) const;
};
struct Group : Moveable<Group>
{
Group() {}
String name;
Value data;
int active;
int count;
int first;
int last;
};
private:
int id;
TabScrollBar sc;
$uvs: REPOSITORY DELETE
Scroller scroller;
void Scroll();
$uvs: END REPOSITORY DELETE
Vector<Group> groups;
Vector<Tab> tabs;
int highlight;
int active;
int target;
int cross;
bool crosses:1;
bool isctrl:1;
bool isdrag:1;
bool grouping:1;
bool autoscrollhide:1;
bool nosel:1;
bool nohl:1;
bool inactiveshadow:1;
int neverempty;
Point mouse, oldp;
int group;
const Display *display;
Image dragimg;
static Style leftstyle, rightstyle, bottomstyle;
const Style *style[4];
void DrawTab(Draw &w, const Style &s, const Size &sz, int i, bool enable);
int TabPos(const String &g, bool &first, int i, int j, bool inactive);
void SyncScrollBar(int total);
$uvs: REPOSITORY INSERT
void Scroll();
$uvs: END REPOSITORY INSERT
int FindId(int id) const;
int GetNext(int n) const;
int GetPrev(int n) const;
int GetWidth(int n);
int GetWidth() const;
int GetHeight() const { return TabBar::GetStyleHeight(*style[TOP]); }
static int GetStyleHeight(const Style& s);
int GetNextId();
int GetScrollPos() { return sc.GetPos(); }
static Value AlignValue(int align, const Value &v, const Size &isz);
protected:
virtual void Paint(Draw &w);
virtual void LeftDown(Point p, dword keysflags);
virtual void LeftUp(Point p, dword keysflags);
virtual void RightDown(Point p, dword keyflags);
virtual void MiddleDown(Point p, dword keyflags);
virtual void MiddleUp(Point p, dword keyflags);
virtual void MouseMove(Point p, dword keysflags);
virtual void MouseLeave();
virtual void DragAndDrop(Point p, PasteClip& d);
virtual void LeftDrag(Point p, dword keyflags);
virtual void DragEnter();
virtual void DragLeave();
virtual void DragRepeat(Point p);
virtual void CancelMode();
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
virtual void FrameSet();
virtual void FrameLayout(Rect& r);
void Repos();
void MakeGroups();
int FindGroup(const String& g) const;
void CloseAll();
void DoGrouping(int n);
void DoCloseGroup(int n);
void NewGroup(const String &name, const Value &data = Value());
// Sub-class display overide & helpers
virtual void DrawTabData(Draw& w, Point p, const Size &sz, const Value& q, const Font &font,
Color ink, dword style);
virtual Size GetStdSize(Value &q);
int TextAngle() { return AlignedFrame::IsVert() ? (GetAlign() == LEFT ? 900 : 2700) : 0; }
void TabCenterText(Point &p, const Size &sz, const Font &f) { TabCenter(p, sz, f.GetHeight()); }
void TabCenter(Point &p, const Size &sz, const Size &hsz) { TabCenter(p, sz, IsVert() ? sz.cx : sz.cy); }
void TabCenter(Point &p, const Size &sz, int h);
int GetTargetTab(Point p);
const Style &GetStyle() { return *style[GetAlign()]; }
// Sub-class menu overrides
virtual void ContextMenu(Bar& bar);
virtual void GroupMenu(Bar &bar, int n);
public:
typedef TabBar CLASSNAME;
Callback WhenHighlight;
Callback WhenCursor;
Callback1<Value> WhenClose;
$uvs: REPOSITORY INSERT
Callback WhenCloseAll;
$uvs: END REPOSITORY INSERT
TabBar();
TabBar& Add(const Value &data, bool make_active = false) { return Add(data, Null, make_active); }
TabBar& Add(const Value &data, String group = Null, bool make_active = false);
TabBar& Insert(int ix, const Value &data, bool make_active = false) { return Insert(ix, data, Null, make_active); }
TabBar& Insert(int ix, const Value &data, String group = Null, bool make_active = false);
void Close(int n);
void Clear();
TabBar& Crosses(bool b = true);
TabBar& Grouping(bool b = true);
TabBar& AutoScrollHide(bool b = true);
TabBar& InactiveShadow(bool b = true);
TabBar& SetDisplay(const Display &d) { display = &d; Refresh(); }
int Find(const Value &v) const;
Value Get(int n) const { ASSERT(n >= 0 && n < tabs.GetCount()); return tabs[n].data;}
void Set(int n, const Value &data, const String &group = Null);
virtual Value GetData() const { return HasCursor() ? Get(active) : Value(); }
virtual void SetData(const Value &data) { int n = Find(data); if (n >= 0) SetCursor(n); }
Value GetGroupData(const String &s) const { return GetGroupData(FindGroup(s)); }
void SetGroupData(const String &s, const Value &data) { SetGroupData(FindGroup(s), data); }
Value GetGroupData(int n) const { ASSERT(n >= 0 && n < groups.GetCount()); return groups[n].data; }
void SetGroupData(int n, const Value &data) { ASSERT(n >= 0 && n < groups.GetCount()); groups[n].data = data;}
String GetGroupName() const { return group == 0 ? Null : groups[group].name; }
int SetGroup(const String &s) { group = max(0, FindGroup(s)); return group; }
int SetGroup(int c) { group = c; return group; }
int GetGroup() const { return group; }
void SetGroupActive(int id) { groups[group].active = id; }
int GetGroupActive() const { return groups[group].active; }
int GetFirst() const { return groups[group].first; }
int GetLast() const { return groups[group].last; }
bool IsGroupAll() const { return group == 0; }
int GetCount() const { return tabs.GetCount(); }
int GetCursor() const { return active; }
int GetHighlight() const { return highlight; }
void SetCursor(int n);
void SetTabGroup(int n, const String &group);
bool HasCursor() const { return active >= 0; }
bool HasHighlight() const { return highlight >= 0; }
TabBar& NeverEmpty(int limit = 1) { neverempty = max(limit, 1); Refresh(); return *this; }
TabBar& CanEmpty() { neverempty = 0; Refresh(); return *this; }
TabBar& SetStyle(int align, const Style& s) { ASSERT(align >= 0 && align < 4); style[align] = &s; Refresh(); return *this; }
static const Style& StyleDefault();
static const Style& StyleLeft();
static const Style& StyleRight();
static const Style& StyleBottom();
static const Style& AlignStyle(int align, Style &s);
static void ResetStyles();
virtual void Serialize(Stream& s);
};
#endif

View file

@ -1,55 +0,0 @@
PREMULTIPLIED
IMAGE_ID(CR0)
IMAGE_ID(CR1)
IMAGE_ID(CR2)
IMAGE_ID(CHK)
IMAGE_BEGIN_DATA
IMAGE_DATA(120,156,133,149,121,76,84,87,20,198,95,210,52,53,68,77,91,180,166,105,82,109,83,211,63,154,52,237,63,141,166,168)
IMAGE_DATA(129,56,196,193,48,136,138,45,24,132,68,17,65,193,22,44,21,171,6,37,197,165,165,173,184,212,186,33,251,38,235,176)
IMAGE_DATA(200,206,12,251,32,195,34,219,12,195,148,89,217,247,34,139,166,95,207,189,48,8,41,226,157,252,114,206,123,231,251,238)
IMAGE_DATA(254,50,194,90,97,173,176,70,120,79,96,205,223,239,120,200,205,235,17,210,178,210,98,20,21,230,175,72,105,113,33,152)
IMAGE_DATA(214,226,145,203,74,161,234,104,131,182,171,19,93,26,245,178,176,90,167,186,3,76,59,55,78,17,26,27,158,160,185,73)
IMAGE_DATA(137,166,198,250,21,177,104,138,139,242,57,204,215,160,172,227,212,63,169,229,53,101,189,98,225,221,98,152,86,46,43,89)
IMAGE_DATA(226,99,218,238,191,53,232,49,27,22,188,38,163,142,195,52,22,100,101,197,200,205,149,162,158,234,79,104,28,37,121,141)
IMAGE_DATA(164,49,147,143,69,157,78,203,115,134,66,81,13,25,141,83,87,87,131,34,26,43,61,53,5,117,181,213,168,173,174,68)
IMAGE_DATA(77,85,5,143,250,110,45,140,250,238,5,216,62,102,103,101,32,47,71,202,201,202,72,67,74,114,2,106,107,42,81,93)
IMAGE_DATA(85,206,169,170,148,211,254,169,160,167,177,24,108,222,133,5,121,200,127,156,195,99,81,225,99,164,167,165,32,62,46,154)
IMAGE_DATA(235,43,43,100,220,211,169,110,167,61,87,115,44,57,235,199,178,23,165,37,133,72,125,148,132,152,232,72,174,175,40,47)
IMAGE_DATA(227,181,167,205,13,92,207,250,205,150,102,208,185,182,114,216,121,49,15,139,108,142,49,81,145,168,144,151,161,156,206,179)
IMAGE_DATA(48,63,143,175,151,69,182,14,22,115,179,179,32,205,76,71,81,193,99,148,149,20,65,70,247,234,81,114,34,18,19,98)
IMAGE_DATA(249,248,37,197,5,200,163,189,205,201,206,68,110,78,22,95,15,27,147,189,103,117,203,120,236,12,226,98,163,248,157,73)
IMAGE_DATA(74,140,227,207,139,231,194,158,217,188,203,229,165,75,200,204,72,93,114,71,19,227,99,249,122,151,35,45,53,153,147,16)
IMAGE_DATA(31,179,224,17,216,199,177,184,5,29,57,28,162,58,236,141,86,71,231,21,105,63,232,1,166,181,120,212,190,126,24,174)
IMAGE_DATA(168,197,120,107,39,198,91,84,203,67,181,81,69,3,212,62,39,184,183,195,235,24,204,49,169,232,73,206,134,57,49,107)
IMAGE_DATA(142,248,204,151,121,194,60,148,247,36,73,41,74,209,230,226,134,150,61,46,48,197,100,192,120,63,137,163,255,51,150,116)
IMAGE_DATA(153,48,220,77,128,225,94,34,140,15,146,57,60,103,154,168,84,116,28,243,67,235,158,253,228,75,167,26,121,110,199,226)
IMAGE_DATA(31,173,14,207,167,167,168,223,76,122,142,193,244,232,24,199,248,144,252,15,83,96,140,78,131,202,235,56,170,36,78,252)
IMAGE_DATA(217,112,55,14,198,184,52,204,76,61,195,243,231,179,152,165,56,53,56,200,115,134,246,175,104,104,252,206,195,120,43,10)
IMAGE_DATA(202,163,62,200,18,59,192,116,39,14,250,155,145,232,142,184,143,214,168,88,76,79,78,98,118,102,102,1,121,216,175,80)
IMAGE_DATA(218,56,66,189,237,0,52,54,251,81,236,224,140,104,145,61,204,215,110,67,31,126,157,136,128,238,82,56,134,77,38,76)
IMAGE_DATA(61,155,226,140,143,140,160,205,205,11,134,237,180,30,145,43,250,8,169,88,130,8,59,59,244,144,86,31,122,25,250,159)
IMAGE_DATA(175,160,95,167,71,255,192,16,6,135,70,208,99,50,99,128,242,129,158,62,12,122,5,98,84,228,130,113,177,43,146,119)
IMAGE_DATA(57,32,116,187,13,122,130,207,65,31,20,12,109,224,105,180,42,155,160,39,125,193,217,80,228,126,115,8,218,110,29,52)
IMAGE_DATA(132,214,235,36,198,68,7,48,65,190,7,59,69,8,217,97,131,190,227,254,48,208,121,182,57,123,34,89,36,65,118,240)
IMAGE_DATA(121,52,219,56,241,185,229,122,120,35,197,253,40,140,118,206,24,19,127,59,231,19,137,112,197,201,17,90,103,119,232,157)
IMAGE_DATA(61,208,184,205,21,138,173,174,80,126,237,66,123,224,10,147,173,43,134,236,14,160,143,24,163,117,141,18,19,98,55,132)
IMAGE_DATA(217,218,242,59,115,195,222,22,3,251,157,209,235,43,129,201,95,130,190,239,36,24,10,144,96,44,80,130,201,31,28,241)
IMAGE_DATA(204,194,41,39,164,237,19,45,185,163,23,197,34,220,219,45,194,157,221,59,113,199,113,39,238,82,188,47,177,195,3,199)
IMAGE_DATA(57,30,82,30,182,195,118,193,243,191,143,227,86,96,64,124,237,71,155,32,19,132,21,169,92,191,30,76,107,241,40,86)
IMAGE_DATA(175,67,111,124,6,134,229,117,24,46,85,44,15,213,6,50,242,161,176,178,230,222,154,77,155,160,9,12,69,215,185,223)
IMAGE_DATA(208,117,230,151,57,78,95,125,153,7,207,195,242,179,225,20,195,81,110,101,5,57,141,175,9,188,4,149,207,89,78,187)
IMAGE_DATA(199,41,210,93,69,135,87,48,125,4,63,65,229,123,142,195,115,170,171,191,15,69,205,170,117,40,183,248,168,214,238,249)
IMAGE_DATA(35,38,154,218,241,239,204,44,239,191,221,51,8,179,195,35,28,181,127,8,212,39,47,64,29,16,6,197,27,214,72,37)
IMAGE_DATA(95,23,245,161,242,14,134,230,244,37,188,160,75,205,26,243,206,244,246,195,210,154,143,4,161,113,195,22,116,121,4,34)
IMAGE_DATA(255,205,183,241,59,249,180,62,103,160,242,12,64,187,187,31,42,233,242,89,188,150,150,184,107,15,10,72,215,64,52,17)
IMAGE_DATA(145,68,16,209,125,208,11,170,125,135,160,218,235,142,14,241,62,12,233,186,233,3,124,193,153,24,25,67,181,176,10,93)
IMAGE_DATA(172,127,194,68,252,65,184,17,122,241,94,168,236,28,160,178,119,132,89,77,255,140,253,67,232,167,53,233,117,6,244,82)
IMAGE_DATA(222,107,52,163,111,213,102,140,144,118,130,184,64,216,18,134,47,183,64,253,217,151,120,186,249,115,84,22,203,160,38,253)
IMAGE_DATA(189,175,236,112,131,106,45,29,106,52,17,173,86,27,49,78,207,147,196,73,194,134,141,189,225,67,104,172,223,71,13,229)
IMAGE_DATA(23,137,107,95,108,229,247,131,205,237,166,176,6,161,194,106,158,47,246,237,94,103,141,22,138,106,162,132,200,37,44,123)
IMAGE_DATA(192,214,51,48,191,38,230,25,153,247,217,19,236,206,28,162,216,75,24,223,37,237,7,164,219,72,250,143,73,251,137,128)
IMAGE_DATA(233,79,5,204,88,216,44,224,242,188,199,114,71,183,211,221,241,165,119,222,196,49,194,135,56,65,248,207,207,43,128,16)
IMAGE_DATA(45,242,8,111,209,111,173,240,142,240,154,134,21,222,99,153,58,150,97,57,253,171,116,175,235,255,149,243,250,15,56,206)
IMAGE_DATA(131,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
IMAGE_END_DATA(1504, 4)

View file

@ -1,5 +0,0 @@
file
TabBar.h,
TabBar.cpp,
TabBar.iml;

View file

@ -1,3 +0,0 @@
#ifndef _TabBar_icpp_init_stub
#define _TabBar_icpp_init_stub
#endif

View file

@ -4,9 +4,7 @@ using namespace Upp;
GUI_APP_MAIN
{
TopWindow win;
TextDiffCtrl ctrl;
win.Add(ctrl.SizePos());
ctrl.Set(LoadFile("C:/u/upp.src/uppdev/AssistTest/main.cpp"), LoadFile("C:/u/upp.src/uppdev/ArrayCtrl/main.cpp"));
win.Run();
DirDiffDlg dlg;
dlg.Run();
}

View file

@ -1,5 +1,14 @@
#include <Core/Core.h>
using namespace Upp;
Vector<int> Test()
{
Vector<int> x;
x << 1 << 2 << 3;
return pick(x);
}
CONSOLE_APP_MAIN
{
Vector<String> test;
@ -9,4 +18,15 @@ CONSOLE_APP_MAIN
test.Add("5");
test.Add("4");
DUMPC(test);
Vector<String> b = pick(test);
for(auto x: b)
DLOG(x);
DDUMP(__cplusplus);
#ifdef CPP_11
LOG("C++ 11 active");
#endif
}

View file

@ -1,7 +1,9 @@
uses Core;
file
"Vector.cpp";
mainconfig
"" = "CONSOLE ST";
uses
Core;
file
Vector.cpp;
mainconfig
"" = "CONSOLE ST";

4
uppdev/Vector/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Vector_icpp_init_stub
#define _Vector_icpp_init_stub
#include "Core/init"
#endif

262
uppsrc/Core/InMap.hpp Normal file
View file

@ -0,0 +1,262 @@
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, class Less>
String SortedIndex<T, Less>::ToString() const
{
return AsStringArray(*this);
}
template <class T>
void Slaved_InVector__<T>::Insert(int blki, int pos)
{
data.data[blki].Insert(pos);
res = &data.data[blki][pos];
}
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()
{
data.data.Add().Add();
res = &data.data[0][0];
}
template <class K, class T, class Less, class Data>
String SortedAMap<K, T, Less, Data>::ToString() const
{
String r;
r = "{";
for(int i = 0; i < GetCount(); i++) {
if(i)
r << ", ";
r << GetKey(i) << ": " << (*this)[i];
}
r << '}';
return r;
}
template <class K, class T, class Less>
SortedVectorMap<K, T, Less>::SortedVectorMap(SortedVectorMap rval_ s)
{
B::key = pick(s.key);
B::value.data = pick(s.value.data);
B::SetSlave();
}
template <class K, class T, class Less>
SortedVectorMap<K, T, Less>& SortedVectorMap<K, T, Less>::operator=(SortedVectorMap rval_ s)
{
B::key = pick(s.key);
B::value.data = pick(s.value.data);
B::SetSlave();
return *this;
}
template <class K, class T, class Less>
SortedVectorMap<K, T, Less>::SortedVectorMap(const SortedVectorMap& s, int)
{
B::key = clone(s.key);
B::value.data = clone(s.value.data);
B::SetSlave();
}
template <class K, class T, class Less>
int SortedVectorMap<K, T, Less>::FindAdd(const K& k, const T& init)
{
B::value.res = NULL;
int q = B::key.FindAdd(k);
if(B::value.res)
*B::value.res = init;
return q;
}
template <class K, class T, class Less>
void SortedVectorMap<K, T, Less>::Swap(SortedVectorMap& x)
{
B::value.data.Swap(x.value.data);
B::key.Swap(x.B::key);
B::SetSlave();
x.SetSlave();
}
template <class T>
void Slaved_InArray__<T>::Insert(int blki, int pos)
{
if(!res)
res = new T;
data.iv.data[blki].Insert(pos, res);
}
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()
{
if(res)
data.iv.data.Add().Add(res);
else
data.iv.data.Add().Add();
}
template <class K, class T, class Less>
int SortedArrayMap<K, T, Less>::FindAdd(const K& k, const T& init)
{
B::value.res = NULL;
int q = B::key.FindAdd(k);
if(B::value.res)
*B::value.res = init;
return q;
}
template <class K, class T, class Less>
SortedArrayMap<K, T, Less>::SortedArrayMap(SortedArrayMap rval_ s)
{
B::key = pick(s.key);
B::value.data = pick(s.value.data);
B::SetSlave();
}
template <class K, class T, class Less>
SortedArrayMap<K, T, Less>& SortedArrayMap<K, T, Less>::operator=(SortedArrayMap rval_ s)
{
B::key = pick(s.key);
B::value.data = pick(s.value.data);
B::SetSlave();
return *this;
}
template <class K, class T, class Less>
SortedArrayMap<K, T, Less>::SortedArrayMap(const SortedArrayMap& s, int)
{
B::key = clone(s.key);
B::value.data = clone(s.value.data);
B::SetSlave();
}
template <class K, class T, class Less>
void SortedArrayMap<K, T, Less>::Swap(SortedArrayMap& x)
{
B::value.data.Swap(x.value.data);
B::key.Swap(x.B::key);
B::SetSlave();
x.SetSlave();
}
#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

View file

@ -0,0 +1,107 @@
#include <Core/Core.h>
using namespace Upp;
template <class T>
void CompareArray()
{
T a;
a.Add(1);
a.Add(2);
T b = clone(a);
ASSERT(a == b);
b.At(1) = 3;
ASSERT(a != b);
ASSERT(b > a);
b = clone(a);
b.Add(10);
ASSERT(a != b);
ASSERT(b > a);
}
template <class T>
void CompareBiArray()
{
T a;
a.AddTail(1);
a.AddTail(2);
T b = clone(a);
ASSERT(a == b);
b[1] = 3;
ASSERT(a != b);
ASSERT(b > a);
b = clone(a);
b.AddTail(10);
ASSERT(a != b);
ASSERT(b > a);
}
template <class T>
void CompareIndex()
{
T a;
a.Add(1);
a.Add(2);
T b = clone(a);
ASSERT(a == b);
b.Add(3);
ASSERT(a != b);
ASSERT(b > a);
b.Clear();
b.Add(1);
b.Add(3);
ASSERT(a != b);
ASSERT(b > a);
}
template <class T>
void CompareMap()
{
T a;
a.Add(1, 2);
a.Add(3, 4);
T b = clone(a);
ASSERT(a == b);
b.Add(4, 4);
ASSERT(a != b);
ASSERT(b > a);
b.Clear();
b.Add(2, 2);
b.Add(3, 4);
ASSERT(b > a);
b.Clear();
b.Add(1, 2);
b.Add(3, 5);
ASSERT(b > a);
}
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
CompareArray< Vector<int> >();
CompareArray< Array<int> >();
CompareArray< InVector<int> >();
CompareArray< InArray<int> >();
CompareBiArray< BiVector<int> >();
CompareBiArray< BiArray<int> >();
CompareIndex< Index<int> >();
CompareIndex< ArrayIndex<int> >();
CompareIndex< SortedIndex<int> >();
CompareMap<VectorMap<int, int> >();
CompareMap<ArrayMap<int, int> >();
CompareMap<SortedVectorMap<int, int> >();
CompareMap<SortedArrayMap<int, int> >();
LOG("===== OK");
}

View file

@ -0,0 +1,11 @@
description "Comparison for containers\377";
uses
Core;
file
CompareContainer.cpp;
mainconfig
"" = "SSE2";

View file

@ -0,0 +1,4 @@
#ifndef _CompareContainer_icpp_init_stub
#define _CompareContainer_icpp_init_stub
#include "Core/init"
#endif

183
upptst/Core11/Core11.cpp Normal file
View file

@ -0,0 +1,183 @@
#include <Core/Core.h>
using namespace Upp;
template <class T>
void TestTransfer()
{
T a, b;
a = pick(b);
ASSERT(b.IsPicked());
ASSERT(!a.IsPicked());
b = clone(a);
ASSERT(!b.IsPicked());
ASSERT(!a.IsPicked());
T c = pick(b);
T d = clone(c);
Swap(c, d);
}
template <class T>
void TestTransfers()
{
TestTransfer< Vector<T> >();
TestTransfer< Array<T> >();
TestTransfer< Index<T> >();
TestTransfer< ArrayIndex<T> >();
TestTransfer< VectorMap<int, T> >();
TestTransfer< ArrayMap<int, T> >();
TestTransfer< FixedVectorMap<int, T> >();
TestTransfer< FixedArrayMap<int, T> >();
TestTransfer< InVector<T> >();
TestTransfer< InArray<T> >();
TestTransfer< SortedIndex<int> >();
TestTransfer< SortedVectorMap<int, T> >();
TestTransfer< SortedArrayMap<int, T> >();
}
template <class InMap, class Val>
void TestInMap()
{
InMap m;
m.Add(1, "hello");
ASSERT(m.GetCount() == 1);
ASSERT(m[0] == "hello");
ASSERT(m.Get(1) == "hello");
m.Add(2, "world");
ASSERT(m.GetCount() == 2);
ASSERT(m[0] == "hello");
ASSERT(m[1] == "world");
ASSERT(m.Get(1) == "hello");
ASSERT(m.Get(2) == "world");
ASSERT(m.FindAdd(1) == 0);
ASSERT(m.FindAdd(2) == 1);
ASSERT(m.FindAdd(3) == 2);
ASSERT(m.FindAdd(0) == 0);
ASSERT(m.FindAdd(4, "four") == 4);
ASSERT(m.GetCount() == 5);
ASSERT(m[4] == "four");
ASSERT(m.GetAdd(3) == "");
ASSERT(m.GetAdd(2) == "world");
ASSERT(m.GetAdd(5) == "");
ASSERT(m.GetCount() == 6);
m.GetAdd(6) = "six";
ASSERT(m.GetCount() == 7);
ASSERT(m.Get(6) == "six");
m.GetAdd(7, "seven");
ASSERT(m[7] == "seven");
ASSERT(m.Get(7) == "seven");
ASSERT(m.Get(8, "no") == "no");
ASSERT(m.FindPtr(99) == NULL);
ASSERT(*m.FindPtr(7) == "seven");
m.Shrink();
InMap h;
h.Add(1, "1");
ASSERT(h.GetCount() == 1);
h.Clear();
ASSERT(h.GetCount() == 0);
const Val& vv = m.GetValues();
ASSERT(vv.GetCount() == vv.GetCount());
ASSERT(vv[7] == "seven");
InMap mm = pick(m);
ASSERT(m.IsPicked());
ASSERT(!mm.IsPicked());
m = clone(mm);
ASSERT(!m.IsPicked());
ASSERT(!mm.IsPicked());
mm = pick(m);
m = pick(mm);
mm.Clear();
mm.Swap(m);
m.Swap(mm);
ASSERT(mm.IsEmpty());
ASSERT(mm.GetCount() == 0);
ASSERT(!m.IsPicked());
ASSERT(!mm.IsPicked());
ASSERT(m.FindLowerBound(6) == 6);
ASSERT(m.FindUpperBound(6) == 7);
ASSERT(m.Find(6) == 6);
m.Add(6, "another six");
ASSERT(m.GetCount() == 9);
ASSERT(m.FindNext(6) == 7);
ASSERT(m.FindLast(6) == 7);
ASSERT(m.FindPrev(7) == 6);
ASSERT(m.GetKey(7) == 6);
m.Remove(0);
ASSERT(m.GetCount() == 8);
m.RemoveKey(6);
ASSERT(m.GetCount() == 6);
m.Remove(1, 2);
ASSERT(m.GetCount() == 4);
}
struct HasClone : MoveableAndDeepCopyOption<HasClone> {
Vector<int> a;
#ifdef CPP_11
HasClone(HasClone rval_ x) = default;
HasClone& operator=(HasClone rval_ x) = default;
#endif
HasClone(const HasClone& x, int) : a(x.a, 0) {}
HasClone() {}
};
struct NoClone : Moveable<NoClone> {
Vector<int> a;
};
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
TestTransfers<int>();
TestTransfers<String>();
TestTransfers<HasClone>();
TestInMap< SortedVectorMap<int, String>, InVector<String> >();
TestInMap< SortedArrayMap<int, String>, InArray<String> >();
SortedArrayMap<int, NoClone> x;
x.Create<NoClone>(1).a.Add(1);
{
SortedVectorMap<int, NoClone> mm;
mm.GetAdd(1).a.Add(12);
mm.GetAdd(1).a.Add(13);
}
{
SortedVectorMap<int, HasClone> mm;
mm.GetAdd(1).a.Add(12);
mm.GetAdd(1).a.Add(13);
}
LOG("=========== OK");
}

11
upptst/Core11/Core11.upp Normal file
View file

@ -0,0 +1,11 @@
description "Core tests for C+11\377";
uses
Core;
file
Core11.cpp;
mainconfig
"" = "SSE2";

4
upptst/Core11/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _Core11_icpp_init_stub
#define _Core11_icpp_init_stub
#include "Core/init"
#endif

View file

@ -0,0 +1,88 @@
#include <Core/Core.h>
using namespace Upp;
template <class T>
void ArrayTest()
{
T array;
array.Add(1);
array.Add(2);
array.Add(3);
DUMP(array);
}
template <class T>
void BiArrayTest()
{
T array;
array.AddTail(1);
array.AddTail(2);
array.AddTail(3);
DUMP(array);
}
template <class T>
void MapTest()
{
T map;
map.Add(1, "one");
map.Add(2, "two");
map.Add(3, "three");
DUMP(map);
map.Unlink(1);
DUMP(map);
}
template <class T>
void SortedMapTest()
{
T map;
map.Add(1, "one");
map.Add(2, "two");
map.Add(3, "three");
DUMP(map);
}
template <class T>
void FixedMapTest()
{
T map;
map.Add(1, "one");
map.Add(2, "two");
map.Add(3, "three");
map.Finish();
DUMP(map);
}
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_FILE|LOG_COUT);
ArrayTest< Vector<int> > ();
ArrayTest< Array<int> > ();
ArrayTest< InVector<int> > ();
ArrayTest< InArray<int> > ();
ArrayTest< Index<int> > ();
ArrayTest< ArrayIndex<int> > ();
ArrayTest< SortedIndex<int> > ();
BiArrayTest< BiVector<int> > ();
BiArrayTest< BiArray<int> > ();
MapTest< VectorMap<int, String> >();
MapTest< ArrayMap<int, String> >();
SortedMapTest< SortedVectorMap<int, String> >();
SortedMapTest< SortedArrayMap<int, String> >();
FixedMapTest< FixedVectorMap<int, String> >();
FixedMapTest< FixedArrayMap<int, String> >();
One<int> x;
DUMP(x);
x.Create() = 1;
DUMP(x);
LOG("======== OK");
}

View file

@ -0,0 +1,9 @@
uses
Core;
file
NTLAsString.cpp;
mainconfig
"" = "SSE2";

4
upptst/NTLAsString/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _NTLAsString_icpp_init_stub
#define _NTLAsString_icpp_init_stub
#include "Core/init"
#endif

View file

@ -149,6 +149,10 @@ void Test(T& map)
}
}
struct Foo : Moveable<Foo> {
Vector<int> a;
};
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
@ -208,4 +212,10 @@ CONSOLE_APP_MAIN
RDUMP(sizeof(InArray<int>));
RDUMP(sizeof(SortedIndex<int>));
RDUMP(sizeof(SortedVectorMap<int, int>));
{ // Test that this compiles
SortedVectorMap<int, Foo> mm;
Foo& x = mm.Add(1);
x.a.Add(12);
}
}

View file

@ -0,0 +1,99 @@
#include <Core/Core.h>
using namespace Upp;
template <class T>
void TestCompareT(T a, T b)
{
LOG("==== TestCompare(" << a << " " << b << "): " << a.Compare(b));
ASSERT(sgn(a.Compare(b)) == -1);
ASSERT(sgn(b.Compare(a)) == 1);
ASSERT(a.Compare(a) == 0);
ASSERT(b.Compare(b) == 0);
ASSERT(a > Null);
ASSERT(b > Null);
ASSERT(a < b);
ASSERT(a <= a);
ASSERT(b <= b);
ASSERT(a <= b);
ASSERT(b > a);
ASSERT(b >= a);
ASSERT(a >= a);
ASSERT(b >= b);
ASSERT(a != b);
ASSERT(a == a);
ASSERT(b == b);
}
void TestCompare(Value a, Value b)
{
TestCompareT<Value>(a, b);
}
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_FILE|LOG_COUT);
TestCompare("ahoj", "ahoj1");
TestCompare(WString("ahoj"), WString("ahoj1"));
TestCompare(1, 2);
TestCompare(1.1, 1.2);
TestCompare(false, true);
TestCompare((int64)1, (int64)2);
TestCompare(GetSysTime(), GetSysTime() + 1);
TestCompare(GetSysDate(), GetSysDate() + 1);
ValueArray va1; va1 << 1 << 2 << 3;
ValueArray va2; va2 << 1 << 2 << 4;
TestCompareT(va1, va2);
TestCompare(va1, va2);
va2 = va1;
va2 << 0;
TestCompareT(va1, va2);
TestCompare(va1, va2);
ValueMap m1; m1("a", 1)("b", 2);
ValueMap m2; m2("a", 1)("c", 2);
TestCompareT(m1, m2);
Value a = m1;
Value b = m2;
a.Compare(b);
TestCompare(m1, m2);
m2 = m1;
m2("b", 2);
TestCompareT(m1, m2);
TestCompare(m1, m2);
TestCompare((bool)false, 123);
TestCompare((bool)false, (int64)123);
TestCompare((bool)false, (double)123);
TestCompare((bool)false, (bool)true);
TestCompare(12, 123);
TestCompare(12, (int64)123);
TestCompare(12, (double)123);
TestCompare(0, (bool)true);
TestCompare((int64)12, 123);
TestCompare((int64)12, (int64)123);
TestCompare((int64)12, (double)123);
TestCompare((int64)0, (bool)true);
TestCompare((double)12, 123);
TestCompare((double)12, (int64)123);
TestCompare((double)12, (double)123);
TestCompare((double)0, (bool)true);
LOG("===== Everything is OK");
}

View file

@ -0,0 +1,11 @@
description "Test of Value::Compare\377";
uses
Core;
file
ValueCompare.cpp;
mainconfig
"" = "SSE2";

4
upptst/ValueCompare/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _ValueCompare_icpp_init_stub
#define _ValueCompare_icpp_init_stub
#include "Core/init"
#endif