Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
Untitled diff
Created
9 years ago
Diff never expires
Clear
Export
Share
Explain
16 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
70 lines
Copy
53 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
99 lines
Copy
#include <iostream>
#include <iostream>
#include <memory>
#include <memory>
#include <Wt/Dbo/Dbo.h>
#include <Wt/Dbo/Dbo.h>
#include <Wt/Dbo/backend/Sqlite3.h>
#include <Wt/Dbo/backend/Sqlite3.h>
using namespace std;
using namespace std;
namespace dbo = Wt::Dbo;
namespace dbo = Wt::Dbo;
class EntityA
class EntityA
{
{
public:
public:
string name {"Jef"};
string name {"Jef"};
template<class Action>
template<class Action>
void persist(Action& a)
void persist(Action& a)
{
{
dbo::field(a, name, "name");
dbo::field(a, name, "name");
}
}
};
};
class EntityB
class EntityB
{
{
public:
public:
string name {"Jef Jr."};
string name {"Jef Jr."};
Copy
Copied
Copy
Copied
dbo::
ptr<EntityA> parent;
static shared_ptr<
dbo::
Session> session;
static void setSession(shared_ptr<dbo::Session> s)
{
session = s;
}
template<class Action>
template<class Action>
void persist(Action& a)
void persist(Action& a)
{
{
dbo::field(a, name, "name");
dbo::field(a, name, "name");
dbo::belongsTo(a, parent, "parent");
dbo::belongsTo(a, parent, "parent");
}
}
Copy
Copied
Copy
Copied
unique_ptr<EntityA> getParent() const
{
dbo::Transaction t{*session};
return make_unique<EntityA>(*parent);
}
void setParent(dbo::ptr<EntityA> p)
{
parent = p;
}
void setParent(unique_ptr<EntityA> p)
{
parent.reset(move(p));
}
private:
dbo::ptr<EntityA> parent {nullptr};
};
};
Copy
Copied
Copy
Copied
dbo::ptr<EntityB> getAnyB(
dbo::Session
&
session)
shared_ptr<dbo::Session> EntityB::session = nullptr;
dbo::ptr<EntityB> getAnyB(
shared_ptr<
dbo::Session
>
session)
{
{
Copy
Copied
Copy
Copied
dbo::Transaction t{
session};
dbo::Transaction t{
*
session};
Copy
Copied
Copy
Copied
return session
.
find<EntityB>().limit(1);
return session
->
find<EntityB>().limit(1);
}
}
int main()
int main()
{
{
Copy
Copied
Copy
Copied
dbo::Session
session
;
auto session = make_shared<
dbo::Session
>()
;
Copy
Copied
Copy
Copied
session
.
setConnection([](){
session
->
setConnection([](){
auto sqlite3 = make_unique<dbo::backend::Sqlite3>(":memory:");
auto sqlite3 = make_unique<dbo::backend::Sqlite3>(":memory:");
sqlite3->setProperty("show-queries", "true");
sqlite3->setProperty("show-queries", "true");
return move(sqlite3);
return move(sqlite3);
}());
}());
Copy
Copied
Copy
Copied
session
.
mapClass<EntityA>("entity_a");
session
->
mapClass<EntityA>("entity_a");
session
.
mapClass<EntityB>("entity_b");
session
->
mapClass<EntityB>("entity_b");
Copy
Copied
Copy
Copied
session
.
createTables();
session
->
createTables();
EntityB::setSession(session);
{
{
Copy
Copied
Copy
Copied
dbo::Transaction t{
session};
dbo::Transaction t{
*
session};
auto b = make_unique<EntityB>();
auto b = make_unique<EntityB>();
Copy
Copied
Copy
Copied
b->
p
arent
=
session
.
add(make_unique<EntityA>())
;
b->
setP
arent
(
session
.
add(move(b));
session
->
add(make_unique<EntityA>())
)
;
session
->
add(move(b));
}
}
Copy
Copied
Copy
Copied
//dbo::Transaction t{session}; // This "fixes" the problem, but it's VERY inconvenient
cout << getAnyB(session)->
getP
arent
()
->name;
cout << getAnyB(session)->
p
arent
->name;
// Exception: Dbo load(): no active transaction
return 0;
return 0;
}
}
Saved diffs
Original text
Open file
#include <iostream> #include <memory> #include <Wt/Dbo/Dbo.h> #include <Wt/Dbo/backend/Sqlite3.h> using namespace std; namespace dbo = Wt::Dbo; class EntityA { public: string name {"Jef"}; template<class Action> void persist(Action& a) { dbo::field(a, name, "name"); } }; class EntityB { public: string name {"Jef Jr."}; dbo::ptr<EntityA> parent; template<class Action> void persist(Action& a) { dbo::field(a, name, "name"); dbo::belongsTo(a, parent, "parent"); } }; dbo::ptr<EntityB> getAnyB(dbo::Session& session) { dbo::Transaction t{session}; return session.find<EntityB>().limit(1); } int main() { dbo::Session session; session.setConnection([](){ auto sqlite3 = make_unique<dbo::backend::Sqlite3>(":memory:"); sqlite3->setProperty("show-queries", "true"); return move(sqlite3); }()); session.mapClass<EntityA>("entity_a"); session.mapClass<EntityB>("entity_b"); session.createTables(); { dbo::Transaction t{session}; auto b = make_unique<EntityB>(); b->parent = session.add(make_unique<EntityA>()); session.add(move(b)); } //dbo::Transaction t{session}; // This "fixes" the problem, but it's VERY inconvenient cout << getAnyB(session)->parent->name; // Exception: Dbo load(): no active transaction return 0; }
Changed text
Open file
#include <iostream> #include <memory> #include <Wt/Dbo/Dbo.h> #include <Wt/Dbo/backend/Sqlite3.h> using namespace std; namespace dbo = Wt::Dbo; class EntityA { public: string name {"Jef"}; template<class Action> void persist(Action& a) { dbo::field(a, name, "name"); } }; class EntityB { public: string name {"Jef Jr."}; static shared_ptr<dbo::Session> session; static void setSession(shared_ptr<dbo::Session> s) { session = s; } template<class Action> void persist(Action& a) { dbo::field(a, name, "name"); dbo::belongsTo(a, parent, "parent"); } unique_ptr<EntityA> getParent() const { dbo::Transaction t{*session}; return make_unique<EntityA>(*parent); } void setParent(dbo::ptr<EntityA> p) { parent = p; } void setParent(unique_ptr<EntityA> p) { parent.reset(move(p)); } private: dbo::ptr<EntityA> parent {nullptr}; }; shared_ptr<dbo::Session> EntityB::session = nullptr; dbo::ptr<EntityB> getAnyB(shared_ptr<dbo::Session> session) { dbo::Transaction t{*session}; return session->find<EntityB>().limit(1); } int main() { auto session = make_shared<dbo::Session>(); session->setConnection([](){ auto sqlite3 = make_unique<dbo::backend::Sqlite3>(":memory:"); sqlite3->setProperty("show-queries", "true"); return move(sqlite3); }()); session->mapClass<EntityA>("entity_a"); session->mapClass<EntityB>("entity_b"); session->createTables(); EntityB::setSession(session); { dbo::Transaction t{*session}; auto b = make_unique<EntityB>(); b->setParent( session->add(make_unique<EntityA>()) ); session->add(move(b)); } cout << getAnyB(session)->getParent()->name; return 0; }
Find difference