|
Say Something... |
William Labbett
Member #4,486
March 2004
|
Pissed. Not like you mean over in US though. No, not angry. You know what I mean. BTW, save me having to write a new thread. Where's Trent and the Supreme Loser?
|
Sirocco
Member #88
April 2000
|
Yup. --> |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Jeez, where has everyone gone? I guess it's nice weather now and no one wants to sit inside and computer. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
jmasterx
Member #11,410
October 2009
|
I'm giving up on you Armando Agui GUI API -> https://github.com/jmasterx/Agui |
MiquelFire
Member #3,110
January 2003
|
I'm in a position where I don't have the time to sit in front of the computer as much as I want. --- |
AMCerasoli
Member #11,955
May 2010
|
jmasterx said: I'm giving up on you Armando I'll be the one if you want me to
|
Gideon Weems
Member #3,925
October 2003
|
Dennis
Member #1,090
July 2003
|
Got bored with WoW a few days ago. Will probably not continue playing it. I only started playing to escape from RL problems anyway but it turns out problems do not always go away when they are ignored (you would be surprised how often it works, despite people saying it does not ). So... blah. --- 0xDB | @dennisbusch_de --- |
AMCerasoli
Member #11,955
May 2010
|
I'm trying to make a class to handle sqlite3 databases like Codeignter does. Something like this: db->select("users.email, users.password"); db->from("users"); db->join("games", "games.id = users.id", "LEFT"); db->join("webs", "webs.id = users.id", "LEFT"); db->where("user.email", "amcerasoli@hotmail.com"); db->where("webs.cast", 1); db->groupBy("users.id"); db->get()->row_array(); And I want row_array() to return a std::map like this: typedef std::map<std::string, boost::variant<int, double, std::string> > aArray_t; but when I do this: int a = myMap["userId"] I get an error telling me that cannot convert and bla bla bla... If I could get the direct value from a map would be incredible, and that's what I'm trying to do now, but I think it's kind of impossible.
|
pkrcel
Member #14,001
February 2012
|
AMCerasoli said: but when I do this: int a = myMap["userId"] I get an error telling me that cannot convert and bla bla bla... Shouldn't that access grant a return of a boost::variant as per your definition? It is unlikely that Google shares your distaste for capitalism. - Derezo |
AMCerasoli
Member #11,955
May 2010
|
Yes, that's what gives me. But I'm looking for something that could give me the type directly in this case an integer. Now I'm trying to use templates in order to do something like: Database db; db.init(); db.select("users.email, users.password"); db.from("peopleProfile"); Dbres dbr = db.get(); int a = dbr.get(0, "name"); Where 0 is the result row number and "name" the column name. If name is int returns int if it's string, string... and so on and so forth. But I haven't be able to do it so far. I think it should be possible?
|
pkrcel
Member #14,001
February 2012
|
Not with that signature, as far as I know...your asking for a variant return type....I'm unsure there is a technique granting what you want, but I am too a n00b to know for sure. It is unlikely that Google shares your distaste for capitalism. - Derezo |
AMCerasoli
Member #11,955
May 2010
|
Where will I stop being a n00b? It's not like I have all my life!
|
jmasterx
Member #11,410
October 2009
|
AMCerasoli said: I'll be the one if you want me to Anywhere I, would've followed you (even on Twitter) Agui GUI API -> https://github.com/jmasterx/Agui |
AMCerasoli
Member #11,955
May 2010
|
jmasterx said: Anywhere I, would've followed you (even on Twitter) Ok man I'll say something so you don't give up on me. When programming C++ I feel so small, I have all these dreams over my head, but when I'm programming I know nothing at all. I know I will stumble and fall I'm even still learning PHP Just starting to crawl. jmasterx (btw what is your real name?) say something, don't give up on me...
|
jmasterx
Member #11,410
October 2009
|
Armando, I'm sorry that I couldn't get to you before you started feeling this way about your C++ skills. I'll swallow my pride, you're the one that I teach, please don't say goodbye Josh Agui GUI API -> https://github.com/jmasterx/Agui |
Gideon Weems
Member #3,925
October 2003
|
Is there something wrong with using a void pointer and a typecast? Is that not plus-plussy enough or something? Donald Knuth convinced me to finally take the hyphen out of "email." I'm currently setting up mutt and offlineimap to work with Gmail. It's a pain in the ass, but that's part of doing things right. Command-line email is the way to go. I've decided to keep this topic going for as long as socially acceptable. |
pkrcel
Member #14,001
February 2012
|
Gideon Weems said: Is there something wrong with using a void pointer and a typecast? Is that not plus-plussy enough or something? Well, that would get close (as I initially tought) to what Armando's asking but no cigar, he is askinf to implement a method that automatically detects the type and returns the corresponding item. I sense come C++11ness in there, as well as something far beyond my reach By the way I could use some teaching as well, are you holding classes? It is unlikely that Google shares your distaste for capitalism. - Derezo |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Java uses specific methods and type checking to get information out of a result set. my_int_column = results.getInt(index); My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
bamccaig
Member #7,536
July 2006
|
You might be able to use a template to get the dynamic return value. My C++ is a little bit rusty. auto x = row.get<int>("column"); // x is implicitly an int. That's probably the closest you'll get. That said, I really think that SQL is the best tool for the job, and you should keep your C++ API scoped to just be capable of handing off SQL requests and getting at the results as efficiently as possible (so don't bother trying to create a query language in C++). Let SQL do what SQL was designed to do. Use C++ to make the request and consume the data in as few keystrokes as possible. Gideon Weems said: I'm currently setting up mutt and offlineimap to work with Gmail. I'd appreciate it if you publish the result. fetchmail + mutt is becoming unmanageable given my current situation behind a Microsoft proxy. It worked fine when a server-side mutt became my primary MUA, but since I most often don't have access to my server during work hours I am stuck managing multiple copies of my mailbox and trying to manually keep them in sync. I haven't had the time to try to set up my own UNIX-friendly proxy, but I suspect that I'd get in trouble if I got caught anyway. At least if I could access G-mail via IMAP then I'd be able to get the best of both worlds. In theory. I think that the way that G-mail does IMAP is actually not very good... I digress. The alternative would be setting up my own E-mail service, which would be a lot of work and would result in less reliable service. Gideon Weems said: Command-line email is the way to go. Hear, hear! -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
AMCerasoli
Member #11,955
May 2010
|
jmasterx said: Josh Oh cool! like Yoshi? {"name":"Yoshi_MP8_Artwork.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/9\/996b3f57af61aed7ee6df0b2798eccac.jpg","w":1244,"h":2480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/9\/996b3f57af61aed7ee6df0b2798eccac"} Gideon Weems said: Is there something wrong with using a void pointer and a typecast? Is that not plus-plussy enough or something? That's so C-- Edgar Reynaldo said: Java uses specific methods and type checking to get information out of a result set. my_int_column = results.getInt(index); Weeeeelll... But it is not so cool. bamccaig said: That's probably the closest you'll get. NO! THERE SHOULD BE SOMETHING BETTER!! MUCH BETTER!! Quote: That said, I really think that SQL is the best tool for the job, and you should keep your C++ API scoped to just be capable of handing off SQL requests and getting at the results as efficiently as possible (so don't bother trying to create a query language in C++). Let SQL do what SQL was designed to do. Use C++ to make the request and consume the data in as few keystrokes as possible. He... What do you mean? making queries manually like: std::string query = "SELECT apple.syrup" "FROM Canada" "WHERE apple.isAtPoint = 1 AND apple.isGreen = 1" ; db.query(query); Because that will be also possible. But I'm trying to simplify that process.
|
Gideon Weems
Member #3,925
October 2003
|
bamccaig said: ... I am stuck managing multiple copies of my mailbox and trying to manually keep them in sync. I think that's the very problem OfflineIMAP was designed to fix. Admittedly, I've mostly been configuring the Mutt side of things, but an ideal set-up would have a one-for-one offline backup on the main machine, with smaller, filtered versions on portable devices. OfflineIMAP synchronizes everything to Gmail and even includes a dedicated Gmail protocol, as apparently Google's IMAP isn't 100% pure . Mutt can handle IMAP out of the box, though, and Mutt configuration alone has kept me tied up for a bit. Here are a few observations for anyone interested in emailing like a boss:
|
bamccaig
Member #7,536
July 2006
|
AMCerasoli said: NO! THERE SHOULD BE SOMETHING BETTER!! MUCH BETTER!! You should be able to define user-defined conversions for a particular invariant class so that it will automatically convert to e.g., int or std::string or whatever. I'm not familiar with boost::variant so I don't know if it does this or not. It looks like not based on a skim of the documentation. I'm not sure why that is (e.g., technical or logical). In any case, you might be able to implement your own variant class that does. AMCerasoli said: He... What do you mean? making queries manually like: std::string query = "SELECT apple.syrup" "FROM Canada" "WHERE apple.isAtPoint = 1 AND apple.isGreen = 1" ; db.query(query); Because that will be also possible. But I'm trying to simplify that process. Sure, but the API that you've defined above is more verbose and more difficult to read than the raw SQL is. It's also less functional. At least be careful not to introduce SQL injection vulnerabilities in your API. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
I use template structs/classes to get "Variant" return values: template<> struct stack<int> { static int get(LuaGlueBase *, lua_State *s, int idx) { return luaL_checkint(s, idx); } static void put(LuaGlueBase *, lua_State *s, int v) { lua_pushinteger(s, v); } }; And to use such a thing: int foo = stack<int>::get(glue, glue->state(), 0);
-- |
|
|