opensubscriber
   Find in this group all groups
 
Unknown more information…

h : help-cgicc@gnu.org 25 March 2009 • 11:58PM -0400

Re[2]: [help-cgicc] cgicc and Qt
by Igor

REPLY TO AUTHOR
 
REPLY TO GROUP




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@gnu....");


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@qq.q..."), ((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@qq.q...");

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@gnu....");
>>
>>     or you may try to redirect cout to QTextStream
>>
>>





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



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

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.