Mercurial > malikania
comparison server/main.cpp @ 29:99792c6c8b06
Server: add initial postgresql account management, #475
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 26 May 2016 07:32:05 +0200 |
parents | 8991989c4708 |
children | a1e80d991968 |
comparison
equal
deleted
inserted
replaced
28:80736513d699 | 29:99792c6c8b06 |
---|---|
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 */ | 17 */ |
18 | 18 |
19 #include <iostream> | 19 #include <iostream> |
20 | 20 |
21 #include <malikania/Game.h> | 21 #include "malikania/account.h" |
22 #include <malikania/ResourcesLocator.h> | 22 #include "malikania/dao-account.h" |
23 #include <malikania/ResourcesLoader.h> | 23 #include "malikania/database.h" |
24 | 24 |
25 using namespace malikania; | 25 using namespace malikania; |
26 | 26 |
27 int main(int, char **) | 27 int main(int, char **) |
28 { | 28 { |
29 ResourcesLocatorDirectory locator("/home/markand/mygame"); | 29 try { |
30 ResourcesLoader loader(locator); | 30 Database database("./pgsql", { |
31 Game game = loader.loadGame(); | 31 { "user", "kingdom" }, |
32 { "host", "localhost" }, | |
33 { "database", "kingdomdb" } | |
34 }); | |
35 | |
36 AccountDao act(database); | |
37 Account account; | |
38 | |
39 account.setId(2); | |
40 | |
41 act.remove(account); | |
42 | |
43 for (const Account &ac : act.list()) { | |
44 std::cout << "id : " << ac.id() << std::endl; | |
45 std::cout << "name : " << ac.name() << std::endl; | |
46 std::cout << "email : " << ac.email() << std::endl; | |
47 std::cout << "firstname : " << ac.firstName() << std::endl; | |
48 std::cout << "lastname : " << ac.lastName() << std::endl; | |
49 } | |
50 } catch (const std::exception &ex) { | |
51 std::cerr << ex.what() << std::endl; | |
52 } | |
32 | 53 |
33 return 0; | 54 return 0; |
34 } | 55 } |