Jump to content

  • Log In with Google      Sign In   
  • Create Account


[C++] bask in my awesomeness.

  • You cannot reply to this topic
42 replies to this topic

#1 e‍dd   Members   -  Reputation: 2105

Like
5Likes
Like

Posted 24 June 2009 - 10:23 AM

http://bitbucket.org/edd/xsmell/src/ From the readme:
XSMELL README
-------------

Congratulations! You have in your hands the MOST BRILLIANTEST C++ XML CREATION 
LIBRARY EVER CREATED.

Have you ever needed to embed a quick snippet of HTML or XML in your C++ source 
code? Didn't you just hate having to use that obscure string concatenation
syntax?

Well no more! With the advent of XSMELL you can now use regular XML syntax
directly in your source code, thanks to the reckless use of operator 
overloading, template meta-programming and preprocessor macros:
using namespace xsmell;

document doc = 
    _
    <html>_
        <head>_
            <title>"XSMELL demo"<!title>_
        <!head>_
        <body>_
            <p>"Yesssssssssssssssss!"<!p>_
            <img .src("chucknorris.png") .alt("sneezing eyes open")>_ <!img>_
        <!body>_
    <!html>
    _;

std::cout << doc << '\n';

That's right! Thanks to XSMELL you'll no longer suffer from S-Expression
envy. You've got one up on those Lisp guys now -- smug bastards!

And you no longer have to worry about generating malformed XML! After spending
hours fighting obscure C++ compiler errors, you'll be 100% certain that your 
XML is correct.
I couldn't wait for April 1st to come around.

Sponsor:

#2 Josh Petrie   Moderators   -  Reputation: 3098

Like
1Likes
Like

Posted 24 June 2009 - 10:28 AM

Win. This is like the <dot> and <cross> "operator" hacks on steroids. I dare you to submit this to Boost.

Josh Petrie | Core Tools Engineer, 343i | Microsoft C++ MVP


#3 rip-off   Moderators   -  Reputation: 7958

Like
0Likes
Like

Posted 24 June 2009 - 10:31 AM

There are no words.

#4 Sneftel   Senior Moderators   -  Reputation: 1776

Like
0Likes
Like

Posted 24 June 2009 - 10:40 AM

Quote:
Original post by jpetrie
I dare you to submit this to Boost.

They already have boost::spirit. :P

#5 MaulingMonkey   Members   -  Reputation: 1556

Like
0Likes
Like

Posted 24 June 2009 - 10:57 AM

It's a little disturbing that one of the first thoughts I had on viewing this code was thinking "Gee, that looks like something I would write..."

#6 Zipster   Crossbones+   -  Reputation: 578

Like
0Likes
Like

Posted 24 June 2009 - 11:11 AM

I can't tell if these are tears of joy or sadness.

#7 colinhect   Members   -  Reputation: 193

Like
0Likes
Like

Posted 24 June 2009 - 01:27 PM

It is like dipping into the part of the yogurt without the fruit in it...

#8 Rraawwrr   Members   -  Reputation: 322

Like
0Likes
Like

Posted 24 June 2009 - 01:55 PM

This is amazing.

#9 Hodgman   Moderators   -  Reputation: 28405

Like
0Likes
Like

Posted 24 June 2009 - 02:00 PM

OMG that is so bad and right.

#10 Cornstalks   Crossbones+   -  Reputation: 6974

Like
0Likes
Like

Posted 24 June 2009 - 02:02 PM

You, sir, have just won the Holy Sh** You're F***ing Awesome Award. Now would be a good time to request a staff member to change your name to "the_awesome_edd."
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#11 loufoque   Banned   -  Reputation: 92

Like
0Likes
Like

Posted 24 June 2009 - 02:02 PM

Does it even check the document is valid HTML?

Otherwise I think a general-purpose XML or SGML document creation would be more useful.

#12 Cornstalks   Crossbones+   -  Reputation: 6974

Like
0Likes
Like

Posted 24 June 2009 - 02:15 PM

Quote:
Original post by loufoque
Does it even check the document is valid HTML?

Otherwise I think a general-purpose XML or SGML document creation would be more useful.

Technically, it sounds like it's just an XML library. I believe the reason you can use it to write HTML is because of the syntactical similarities between XML and HTML. And if you look at the source (which is impressive 116 LOC, including white space) it doesn't do any syntax validation.

#13 Hodgman   Moderators   -  Reputation: 28405

Like
0Likes
Like

Posted 24 June 2009 - 02:18 PM

Quote:
Original post by loufoque
Does it even check the document is valid HTML?
looking at the demo application, it doesn't know about HTML, just how XML should be structured. The application tells it about what tags you can use:
TAG(html,  NO_ATTRIBS);
TAG(head, NO_ATTRIBS);
TAG(title, NO_ATTRIBS);
TAG(body, NO_ATTRIBS);
TAG(p, NO_ATTRIBS);
TAG(a, ATTRIB(href));
TAG(img, ATTRIB(src), ATTRIB(alt));



#14 owl   Banned   -  Reputation: 364

Like
0Likes
Like

Posted 24 June 2009 - 02:30 PM

I love the License

Quote:
You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want


@the_edd: You Sir, are my new hero.

#15 Sik_the_hedgehog   Crossbones+   -  Reputation: 1536

Like
0Likes
Like

Posted 24 June 2009 - 03:01 PM

Now this made my day XD
Quote:
Original post by owl
I love the License

Quote:
You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want


@the_edd: You Sir, are my new hero.

And the best of all is that it's a real license!

Clicky =P

#16 swiftcoder   Senior Moderators   -  Reputation: 9723

Like
0Likes
Like

Posted 24 June 2009 - 03:06 PM

Just. Awesome.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#17 iblis   Members   -  Reputation: 101

Like
0Likes
Like

Posted 24 June 2009 - 04:32 PM

Quote:
Original post by the_edd
http://bitbucket.org/edd/xsmell/src/

From the readme:


XSMELL README
-------------

Congratulations! You have in your hands the MOST BRILLIANTEST C++ XML CREATION
LIBRARY EVER CREATED.

Have you ever needed to embed a quick snippet of HTML or XML in your C++ source
code? Didn't you just hate having to use that obscure string concatenation
syntax?

Well no more! With the advent of XSMELL you can now use regular XML syntax
directly in your source code, thanks to the reckless use of operator
overloading, template meta-programming and preprocessor macros:


*** Source Snippet Removed ***


That's right! Thanks to XSMELL you'll no longer suffer from S-Expression
envy. You've got one up on those Lisp guys now -- smug bastards!

And you no longer have to worry about generating malformed XML! After spending
hours fighting obscure C++ compiler errors, you'll be 100% certain that your
XML is correct.


I couldn't wait for April 1st to come around.


--- xsmell.hpp	2009-06-24 23:46:07.000000000 -0400
+++ ../xsmell_fixed.hpp 2009-06-24 23:46:01.000000000 -0400
@@ -17,6 +17,7 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/static_assert.hpp>

namespace xsmell
{


I tried to make a patch queue, but bitbucket wasn't letting me authenticate. :D

#18 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 24 June 2009 - 09:38 PM

Quote:
Original post by loufoque
Does it even check the document is valid HTML?


You can define the tags yourself, but it can't check particular "nesting patterns". However, you cannot assign a set of uneven tags to a xsmell::document as you'll get a compile-time assertion. In that sense, the XML is validated.

I know! I can hardly contain myself either!

Quote:
Original post by Hodgman
looking at the demo application, it doesn't know about HTML, just how XML should be structured. The application tells it about what tags you can use:


Yes, I am particularly proud of the macro hackery needed to get that ATTRIB/NO_ATTRIBS stuff working. Have a look if you want to see awesome distilled in to it's purest form.

#19 e‍dd   Members   -  Reputation: 2105

Like
0Likes
Like

Posted 24 June 2009 - 09:43 PM

Quote:
Original post by iblis
--- xsmell.hpp	2009-06-24 23:46:07.000000000 -0400
+++ ../xsmell_fixed.hpp 2009-06-24 23:46:01.000000000 -0400
@@ -17,6 +17,7 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/static_assert.hpp>

namespace xsmell
{


I tried to make a patch queue, but bitbucket wasn't letting me authenticate. :D


Thank you for your invaluable contribution! I have applied and uploaded your patch.

#20 loufoque   Banned   -  Reputation: 92

Like
0Likes
Like

Posted 25 June 2009 - 01:07 AM

Quote:
You can define the tags yourself, but it can't check particular "nesting patterns".

With such a syntax, it could perfectly do so at compile-time.





PARTNERS