List:MySQL++« Previous MessageNext Message »
From:Rick Gutleber Date:December 4 2008 4:42pm
Subject:Re: Using macros to compose SSQLS structures.
View as plain text  
Ryan:

Actually, the commas used in FIRSTARGS and SECONDARGS aren't interpreted 
as argument separators, but as the comma operator which is a binary 
operator that evaluates both operands and returns the second one, which 
explains why
MACROREQUIRINGFOURARGS( FIRSTARGS, SECONDARGS ) only sees 2 arguments 
instead of 4.  It's a weird little feature of C++ that very occasionally 
can be useful.

The macros mentioned in this thread might be the basis for a solution to 
what you're trying to do, but it's probably more trouble than it's worth:

http://www.gamedev.net/community/forums/topic.asp?topic_id=345017

Rick


Ryan W. Frenz wrote:
> On Wed, Dec 3, 2008 at 2:03 PM, Warren Young <mysqlpp@stripped> wrote:
>   
>> I question how well this is going to work with MySQL to begin with, since it
>> isn't an OODB.
>>
>> You could have a separate table per subtype, but then it's impossible to
>> keep the keys synchronized among the subtype tables, so joins are
>> impossible.
>>     
>
> I apologize, as I probably over-explained my problem.  I already have
> my tables laid out and working in MySQL.  Say I have a base with an
> int and two different derived types that inherit from it:
>
> // base.h
> class base { int id; }
>
> // derived1.h
> class derived1 : public base { std::string name; }
>
> // derived2.h
> class derived2 : public base { double d; }
>
> table derived1 looks like:
> | INT id | TEXT name |
>
> table derived2 looks like:
> | INT id | DOUBLE d |
>
> I understand the limitations of MySQL as an OODB and have designed my
> tables accordingly.
>
> I create my SSQLS for derived1 with:
> sql_create_2(derived1Struct, 1, 2, mysqlpp::sql_int, id,
> mysqlpp::sql_text, name)
>
> I create my SSQLS for derived2 with:
> sql_create_2(derived2Struct, 1, 2, mysqlpp::sql_int, id, mysqlpp::sql_double, d)
>
> This all works fine.  I'm just trying to get around the fact that (in
> the above) I have 'mysqlpp::sql_int, id' hard-coded into every
> sql_create_ call.
>
> My problem is simply one of the macro-expansion I'm trying to do not
> working the way I expect.  In a way more general, non mysql++ related
> example:
>
> #define FIRSTARGS a0, a1
> #define SECONDARGS a2, a3
> #define MACROREQUIRINGFOURARGS(a,b,c,d) ...
>
> MACROREQUIRINGFOURARGS(FIRSTARGS, SECONDARGS)  // does not work
>
> The way I understand cpp's macro expansion, this should first expand to:
> MACROREQUIRINGFOURARGS(a0, a1, a2, a3)
>
> and as a result work fine.  But I'm wrong.
>
> Thanks again,
> Ryan
>
>   

Thread
Using macros to compose SSQLS structures.Ryan W. Frenz3 Dec
  • Re: Using macros to compose SSQLS structures.Warren Young3 Dec
    • Re: Using macros to compose SSQLS structures.Ryan W. Frenz3 Dec
      • Re: Using macros to compose SSQLS structures.Warren Young3 Dec
        • Re: Using macros to compose SSQLS structures.Ryan W. Frenz3 Dec
          • Re: Using macros to compose SSQLS structures.Warren Young4 Dec
      • Re: Using macros to compose SSQLS structures.Rick Gutleber4 Dec
      • Re: Using macros to compose SSQLS structures.Jonathan Wakely8 Dec