[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: [help-cgicc] cgicc and Qt
From: |
Igor |
Subject: |
Re[2]: [help-cgicc] cgicc and Qt |
Date: |
Wed, 25 Mar 2009 17:58:04 +0300 |
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:address@hidden");
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:address@hidden"), ((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:address@hidden");
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:address@hidden");
>>
>> or you may try to redirect cout to QTextStream
>>
>>
--
www.rol.ru
Best regards,
Igor mailto:address@hidden
- [help-cgicc] cgicc and Qt, Frank Büttner, 2009/03/22
- Re: [help-cgicc] cgicc and Qt, Steven King, 2009/03/23
- Re: [help-cgicc] cgicc and Qt, Frank Büttner, 2009/03/25
- Re[2]: [help-cgicc] cgicc and Qt, Igor, 2009/03/25
- Re: [help-cgicc] cgicc and Qt, Frank Büttner, 2009/03/25
- Re[2]: [help-cgicc] cgicc and Qt,
Igor <=
- Re: [help-cgicc] cgicc and Qt, Frank Büttner, 2009/03/27
- Re[2]: [help-cgicc] cgicc and Qt, Igor, 2009/03/27
- Re: [help-cgicc] cgicc and Qt, Frank Büttner, 2009/03/28