Wt::Dbo classname 'CSystemError' not allowed?
Added by Beat Brand almost 11 years ago
Hello
I've tried the dbo examples from http://www.webtoolkit.eu/wt/doc/tutorial/dbo/tutorial.html. All works fine.
Now when I change the classname of the class 'User' to 'CSystemError', something mystery will happen:
The const_iterator of the Wt::Dbo::collection can't resolve the class members...
Here are my classes:
class CSystemError {
public:
enum Role {
Visitor = 0,
Admin = 1,
Alien = 42
};
int test;
std::string name;
std::string password;
Role role;
int karma;
template<class Action>
void persist(Action& a)
{
Wt::Dbo::field(a, test, "test");
Wt::Dbo::field(a, name, "name");
Wt::Dbo::field(a, password, "password");
Wt::Dbo::field(a, role, "role");
Wt::Dbo::field(a, karma, "karma");
}
};
class User {
public:
enum Role {
Visitor = 0,
Admin = 1,
Alien = 42
};
int test;
std::string name;
std::string password;
Role role;
int karma;
template<class Action>
void persist(Action& a)
{
Wt::Dbo::field(a, test, "test");
Wt::Dbo::field(a, name, "name");
Wt::Dbo::field(a, password, "password");
Wt::Dbo::field(a, role, "role");
Wt::Dbo::field(a, karma, "karma");
}
};
In the 'find' part with the iteration:
{
Wt::Dbo::Transaction transaction(session);
typedef Wt::Dbo::collection< Wt::Dbo::ptr<CSystemError> > Users;
Users users = session.find<CSystemError>();
std::cerr << "We have " << (int)users.size() << " users:" << std::endl;
for (Users::const_iterator i = users.begin(); i != users.end(); ++i)
std::cerr << " user " << (*i)->name // 'name' will not be proposed...
<< " with karma of " << (*i)->karma << std::endl; // 'karma' will not be proposed...
}
{
Wt::Dbo::Transaction transaction(session);
typedef Wt::Dbo::collection< Wt::Dbo::ptr<User> > Users;
Users users = session.find<User>();
std::cerr << "We have " << (int)users.size() << " users:" << std::endl;
for (Users::const_iterator i = users.begin(); i != users.end(); ++i)
std::cerr << " user " << (*i)->name // 'name' will be proposed...
<< " with karma of " << (*i)->karma << std::endl; // 'karma' will be proposed...
}
Are there other classnames that I shouldn't use?
Replies (1)
RE: Wt::Dbo classname 'CSystemError' not allowed? - Added by Wim Dumon almost 11 years ago
What do you mean by 'will not be proposed'?
Does the code compile, or are you referring to a bug in the auto-completion functionality of the editor you're using?
Apart from the confusing name of the typedef, your code looks fine at first sight.
BR,
Wim.