cgicc and Qt

View: New views
9 Messages — Rating Filter:   Alert me  

cgicc and Qt

by Frank Büttner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hallo,
I try to use cgicc with the Qt Framework.
But my problem is, to connect it with the QTextStream class of qt.
Have anybody try it`on an idea how to do it?



_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

smime.p7s (6K) Download Attachment

Parent Message unknown Re: cgicc and Qt

by Steven King-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Frank,

You could try creating a sub-class of the cgicc::CgiInput class and
aggregate a QTextStream instance within that object. Im only guessing
:)

Good luck,

Steve

> Date: Sun, 22 Mar 2009 19:44:41 +0100
> From: Frank B?ttner <tuxmaster5000@...>
> Subject: [help-cgicc] cgicc and Qt
> To: help-cgicc@...
> Message-ID: <49C68719.9050909@...>
> Content-Type: text/plain; charset="utf-8"
>
> Hallo,
> I try to use cgicc with the Qt Framework.
> But my problem is, to connect it with the QTextStream class of qt.
> Have anybody try it`on an idea how to do it?
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 5024 bytes
> Desc: S/MIME Cryptographic Signature
> Url : http://lists.gnu.org/pipermail/help-cgicc/attachments/20090322/3737e6ef/smime.bin
>
>
> *****************************************
>


_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

Re: cgicc and Qt

by Frank Büttner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Steve,
I have look at the docu for the class.
But the doc say, that this is for input only,
but my problem is the output that must be go
into the QTextStream.


Frank


Steven King schrieb:

> Hi Frank,
>
> You could try creating a sub-class of the cgicc::CgiInput class and
> aggregate a QTextStream instance within that object. Im only guessing
> :)
>
> Good luck,
>
> Steve
>
>> Date: Sun, 22 Mar 2009 19:44:41 +0100
>> From: Frank B?ttner <tuxmaster5000@...>
>> Subject: [help-cgicc] cgicc and Qt
>> To: help-cgicc@...
>> Message-ID: <49C68719.9050909@...>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hallo,
>> I try to use cgicc with the Qt Framework.
>> But my problem is, to connect it with the QTextStream class of qt.
>> Have anybody try it`on an idea how to do it?
>>


_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

smime.p7s (6K) Download Attachment

Re[2]: cgicc and Qt

by Igor-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Frank,

Wednesday, March 25, 2009, 11:01:26 AM, you wrote:

FB> Hello Steve,
FB> I have look at the docu for the class.
FB> But the doc say, that this is for input only,
FB> but my problem is the output that must be go
FB> into the QTextStream.

    cgicc knows nothing about the output, it is your application
    that is responsible for what to do with the output cgicc produces.
    You may want to put it to cout or QTextStream or whatever.

    QString str;
    QTextStream ts( &str, IO_WriteOnly );
    ts << cgicc::a("Send Mail").set("href", "mailto:sbooth@...");

    or you may try to redirect cout to QTextStream



FB> Frank


FB> Steven King schrieb:

>> Hi Frank,
>>
>> You could try creating a sub-class of the cgicc::CgiInput class and
>> aggregate a QTextStream instance within that object. Im only guessing
>> :)
>>
>> Good luck,
>>
>> Steve
>>
>>> Date: Sun, 22 Mar 2009 19:44:41 +0100
>>> From: Frank B?ttner <tuxmaster5000@...>
>>> Subject: [help-cgicc] cgicc and Qt
>>> To: help-cgicc@...
>>> Message-ID: <49C68719.9050909@...>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Hallo,
>>> I try to use cgicc with the Qt Framework.
>>> But my problem is, to connect it with the QTextStream class of qt.
>>> Have anybody try it`on an idea how to do it?
>>>




--
www.rol.ru
Best regards,
 Igor                            mailto:sprog@...



_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

Re: cgicc and Qt

by Frank Büttner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Igor,

yes , I search something like in the example,
but this will not work.
I get this error when I try to compile it:

error: no match for 'operator<<' in 'ts <<
cgicc::HTMLBooleanElement<cgicc::aTag>(((const std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&)(&
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>(((const char*)"Send Mail"), ((const std::allocator<char>&)((const
std::allocator<char>*)(&
std::allocator<char>()))))))).cgicc::HTMLBooleanElement<cgicc::aTag>::<anonymous>.cgicc::HTMLElement::set(((const
std::string&)(& std::basic_string<char, std::char_traits<char>,
std::allocator<char> >(((const char*)"href"), ((const
std::allocator<char>&)((const std::allocator<char>*)(&
std::allocator<char>())))))), ((const std::string&)(&
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>(((const char*)"mailto:qqq@..."), ((const
std::allocator<char>&)((const std::allocator<char>*)(&
std::allocator<char>())))))))'

This was my test code

QString Test;
QTextStream ts(&Test,QIODevice::WriteOnly);
ts << cgicc::a("Send Mail").set("href","mailto:qqq@...");

Thanks for your help.

Igor schrieb:

> Hello Frank,
>
> Wednesday, March 25, 2009, 11:01:26 AM, you wrote:
>
> FB> Hello Steve,
> FB> I have look at the docu for the class.
> FB> But the doc say, that this is for input only,
> FB> but my problem is the output that must be go
> FB> into the QTextStream.
>
>     cgicc knows nothing about the output, it is your application
>     that is responsible for what to do with the output cgicc produces.
>     You may want to put it to cout or QTextStream or whatever.
>
>     QString str;
>     QTextStream ts( &str, IO_WriteOnly );
>     ts << cgicc::a("Send Mail").set("href", "mailto:sbooth@...");
>
>     or you may try to redirect cout to QTextStream
>
>



_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

smime.p7s (6K) Download Attachment

Re[2]: cgicc and Qt

by Igor-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Frank,

Wednesday, March 25, 2009, 3:20:38 PM, you wrote:


That was a correct remark. Each cgicc Element is derived from MStreamable class
which has << operator defined only for std::ostream. That means there
is no << operator that knows how to put HTMLBooleanElement into
QTextStream. But you can write your own operator which would know how
to do it.

example:

 class QTextStream{
   public:
   //just to compile, junk section, if QTextStream knows how to handle
   // std::string, it wouldn't be necessary
           QTextStream& operator << (const string& s){
                   return *this;
           }
   };

   QTextStream& operator << (QTextStream& qs, const cgicc::MStreamable& obj){
           std::stringstream c;
           obj.render(c);
           qs << c.str();
           return qs;
   }
QTextStream qs;
qs << cgicc::a("Send Mail").set("href", "mailto:sbooth@...");


I didn't use QTextStream so there might be a better way to write

std::stringstream c;
obj.render(c);
qs << c.str();

I assumed QTextStream knows how to handle std::string if it is not,
you got to rewrite QTextStream& operator << (QTextStream& qs, const cgicc::MStreamable& obj)

 

FB> Hello Igor,

FB> yes , I search something like in the example,
FB> but this will not work.
FB> I get this error when I try to compile it:

FB> error: no match for 'operator<<' in 'ts <<
FB> cgicc::HTMLBooleanElement<cgicc::aTag>(((const std::basic_string<char,
FB> std::char_traits<char>, std::allocator<char> >&)(&
FB> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>>(((const char*)"Send Mail"), ((const std::allocator<char>&)((const
FB> std::allocator<char>*)(&
FB> std::allocator<char>()))))))).cgicc::HTMLBooleanElement<cgicc::aTag>::<anonymous>.cgicc::HTMLElement::set(((const
FB> std::string&)(& std::basic_string<char, std::char_traits<char>,
FB> std::allocator<char> >(((const char*)"href"), ((const
FB> std::allocator<char>&)((const std::allocator<char>*)(&
FB> std::allocator<char>())))))), ((const std::string&)(&
FB> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>>(((const char*)"mailto:qqq@..."), ((const
FB> std::allocator<char>&)((const std::allocator<char>*)(&
FB> std::allocator<char>())))))))'

FB> This was my test code

FB> QString Test;
FB> QTextStream ts(&Test,QIODevice::WriteOnly);
FB> ts << cgicc::a("Send Mail").set("href","mailto:qqq@...");

FB> Thanks for your help.

FB> Igor schrieb:

>> Hello Frank,
>>
>> Wednesday, March 25, 2009, 11:01:26 AM, you wrote:
>>
>> FB> Hello Steve,
>> FB> I have look at the docu for the class.
>> FB> But the doc say, that this is for input only,
>> FB> but my problem is the output that must be go
>> FB> into the QTextStream.
>>
>>     cgicc knows nothing about the output, it is your application
>>     that is responsible for what to do with the output cgicc produces.
>>     You may want to put it to cout or QTextStream or whatever.
>>
>>     QString str;
>>     QTextStream ts( &str, IO_WriteOnly );
>>     ts << cgicc::a("Send Mail").set("href", "mailto:sbooth@...");
>>
>>     or you may try to redirect cout to QTextStream
>>
>>





--
www.rol.ru
Best regards,
 Igor                            mailto:sprog@...



_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

Re: cgicc and Qt

by Frank Büttner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks,
now it will work.
I have written an QTextStream helper class.
For all, see the class at the attachment.

Now I can use QTextStreamCGI << cgicc:XXXX :)

Frank

Igor schrieb:

> Hello Frank,
>
> Wednesday, March 25, 2009, 3:20:38 PM, you wrote:
>
>
> That was a correct remark. Each cgicc Element is derived from MStreamable class
> which has << operator defined only for std::ostream. That means there
> is no << operator that knows how to put HTMLBooleanElement into
> QTextStream. But you can write your own operator which would know how
> to do it.
>
> example:
>
>  class QTextStream{
>    public:
>    //just to compile, junk section, if QTextStream knows how to handle
>    // std::string, it wouldn't be necessary
>            QTextStream& operator << (const string& s){
>                    return *this;
>            }
>    };
>
>    QTextStream& operator << (QTextStream& qs, const cgicc::MStreamable& obj){
>            std::stringstream c;
>            obj.render(c);
>            qs << c.str();
>            return qs;
>    }
> QTextStream qs;
> qs << cgicc::a("Send Mail").set("href", "mailto:sbooth@...");
>
>
> I didn't use QTextStream so there might be a better way to write
>
> std::stringstream c;
> obj.render(c);
> qs << c.str();
>
> I assumed QTextStream knows how to handle std::string if it is not,
> you got to rewrite QTextStream& operator << (QTextStream& qs, const cgicc::MStreamable& obj)
>
>  
>
> FB> Hello Igor,
>
> FB> yes , I search something like in the example,
> FB> but this will not work.
> FB> I get this error when I try to compile it:
>
> FB> error: no match for 'operator<<' in 'ts <<
> FB> cgicc::HTMLBooleanElement<cgicc::aTag>(((const std::basic_string<char,
> FB> std::char_traits<char>, std::allocator<char> >&)(&
> FB> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>>> (((const char*)"Send Mail"), ((const std::allocator<char>&)((const
> FB> std::allocator<char>*)(&
> FB> std::allocator<char>()))))))).cgicc::HTMLBooleanElement<cgicc::aTag>::<anonymous>.cgicc::HTMLElement::set(((const
> FB> std::string&)(& std::basic_string<char, std::char_traits<char>,
> FB> std::allocator<char> >(((const char*)"href"), ((const
> FB> std::allocator<char>&)((const std::allocator<char>*)(&
> FB> std::allocator<char>())))))), ((const std::string&)(&
> FB> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>>> (((const char*)"mailto:qqq@..."), ((const
> FB> std::allocator<char>&)((const std::allocator<char>*)(&
> FB> std::allocator<char>())))))))'
>
> FB> This was my test code
>
> FB> QString Test;
> FB> QTextStream ts(&Test,QIODevice::WriteOnly);
> FB> ts << cgicc::a("Send Mail").set("href","mailto:qqq@...");
>
> FB> Thanks for your help.
>
> FB> Igor schrieb:
>>> Hello Frank,
>>>
>>> Wednesday, March 25, 2009, 11:01:26 AM, you wrote:
>>>
>>> FB> Hello Steve,
>>> FB> I have look at the docu for the class.
>>> FB> But the doc say, that this is for input only,
>>> FB> but my problem is the output that must be go
>>> FB> into the QTextStream.
>>>
>>>     cgicc knows nothing about the output, it is your application
>>>     that is responsible for what to do with the output cgicc produces.
>>>     You may want to put it to cout or QTextStream or whatever.
>>>
>>>     QString str;
>>>     QTextStream ts( &str, IO_WriteOnly );
>>>     ts << cgicc::a("Send Mail").set("href", "mailto:sbooth@...");
>>>
>>>     or you may try to redirect cout to QTextStream
>>>
>>>
>
>
>
>
>

#include "qtextstreamcgi.h"

#include <sstream>
namespace QFrank
{
QTextStreamCGI::QTextStreamCGI(FILE *datei,QIODevice::OpenMode zugriff):QTextStream(datei,zugriff)
{  
}
QTextStreamCGI &QTextStreamCGI:: operator <<(const cgicc::MStreamable &was)
{
    std::stringstream ss;
    was.render(ss);
    QString tmp =QString::fromStdString(ss.str());
    QTextStream::operator <<(tmp);
    return *this;
}
}

#ifndef QTEXTSTREAMCGI_H
#define QTEXTSTREAMCGI_H

#include <QtCore>
#include "cgicc/MStreamable.h"

namespace QFrank
{
    class QTextStreamCGI : public QTextStream
    {
        public:
         QTextStreamCGI(FILE *datei,QIODevice::OpenMode zugriff);
         QTextStreamCGI& operator <<(const cgicc::MStreamable &was);
    };
}
#endif // QTEXTSTREAMCGI_H


_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

smime.p7s (6K) Download Attachment

Re[2]: cgicc and Qt

by Igor-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Frank,

Friday, March 27, 2009, 9:23:55 PM, you wrote:

That's right. Now it is time to work on some improvements.

If you're not working on a multithreaded program use static, there is no
need to re-create stringstream each time you want to use it. And we
don't need tmp, it will slow you down a bit if the compiler
isn't smart enough.

    static std::stringstream ss;
    static QString tmp;
    was.render(ss.str(""));
    QTextStream::operator <<(QString::fromStdString(ss.str()));
    return *this;


I'm all so not sure if you require QTextStream at all. If you just want to
redirect cout into a file you can do it by redefining cout's rdbuf.

Or you may use stringstream as the output buffer and then write it to a file
or to a screen.

FB> #include "qtextstreamcgi.h"

FB> #include <sstream>
FB> namespace QFrank
FB> {
FB> QTextStreamCGI::QTextStreamCGI(FILE *datei,QIODevice::OpenMode zugriff):QTextStream(datei,zugriff)
FB> {  
FB> }
FB> QTextStreamCGI &QTextStreamCGI:: operator <<(const cgicc::MStreamable &was)
FB> {
FB>     std::stringstream ss;
FB>     was.render(ss);
FB>     QString tmp =QString::fromStdString(ss.str());
FB>     QTextStream::operator <<(tmp);
FB>     return *this;
FB> }
FB> }



--
www.rol.ru
Best regards,
 Igor                            mailto:sprog@...



_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

Re: cgicc and Qt

by Frank Büttner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good morning Igor,

yes it is an good hind.:)
For multi threading, an QMutex will also be an option.
But for now this is not needed.

Thanks.

Igor schrieb:

> Hello Frank,
>
> Friday, March 27, 2009, 9:23:55 PM, you wrote:
>
> That's right. Now it is time to work on some improvements.
>
> If you're not working on a multithreaded program use static, there is no
> need to re-create stringstream each time you want to use it. And we
> don't need tmp, it will slow you down a bit if the compiler
> isn't smart enough.
>
>     static std::stringstream ss;
>     static QString tmp;
>     was.render(ss.str(""));
>     QTextStream::operator <<(QString::fromStdString(ss.str()));
>     return *this;
>
>
> I'm all so not sure if you require QTextStream at all. If you just want to
> redirect cout into a file you can do it by redefining cout's rdbuf.
>
> Or you may use stringstream as the output buffer and then write it to a file
> or to a screen.
>
> FB> #include "qtextstreamcgi.h"
>
> FB> #include <sstream>
> FB> namespace QFrank
> FB> {
> FB> QTextStreamCGI::QTextStreamCGI(FILE *datei,QIODevice::OpenMode zugriff):QTextStream(datei,zugriff)
> FB> {  
> FB> }
> FB> QTextStreamCGI &QTextStreamCGI:: operator <<(const cgicc::MStreamable &was)
> FB> {
> FB>     std::stringstream ss;
> FB>     was.render(ss);
> FB>     QString tmp =QString::fromStdString(ss.str());
> FB>     QTextStream::operator <<(tmp);
> FB>     return *this;
> FB> }
> FB> }
>
>
>


_______________________________________________
help-cgicc mailing list
help-cgicc@...
http://lists.gnu.org/mailman/listinfo/help-cgicc

smime.p7s (6K) Download Attachment