thready
asked on
How do I use base64_from_binary from boost?
Hi Experts,
I tried adding a filter to some code, but I'm getting a compile error in Visual Studio 2008 with the following code - what do I do to get this going? (error is "use of class template requires template argument list")
Thanks!
Mike
I tried adding a filter to some code, but I'm getting a compile error in Visual Studio 2008 with the following code - what do I do to get this going? (error is "use of class template requires template argument list")
Thanks!
Mike
io::filtering_ostream out;
out.push(io::zlib_compressor());
out.push(boost::archive::iterators::base64_from_binary()); // problem is here
std::string s = strFilename;
out.push(io::file_sink(s));
CString strText = "some text";
out << strText;
out.flush();
ASKER
Thanks for the response - the code you see is all the code I used - I didn't do any other initialization. What would I place in place of TypeOfArchive? I'm a beginner with templates....
A little explanation of templates...
For example, the vector class manages an array of any data type you specify. You can create a vector of ints, chars, etc... They could have made a vector class for every single data type, but instead they just made a "template" for you to specify what type of vector you would like. This is how you would declare a vector of ints.
vector<int> myIntVector;
And this is how you'd declare a vector of chars...
vector<char> myCharVector;
You get the picture... Well, one of the classes within that erroneous line of yours needs a type specified for it. That's what that error message means. It would be like declaring:
vector myVector; //creates an error because no type was specified.
Hope this helps.
For example, the vector class manages an array of any data type you specify. You can create a vector of ints, chars, etc... They could have made a vector class for every single data type, but instead they just made a "template" for you to specify what type of vector you would like. This is how you would declare a vector of ints.
vector<int> myIntVector;
And this is how you'd declare a vector of chars...
vector<char> myCharVector;
You get the picture... Well, one of the classes within that erroneous line of yours needs a type specified for it. That's what that error message means. It would be like declaring:
vector myVector; //creates an error because no type was specified.
Hope this helps.
ASKER
Hi Jonez,
Thanks for the explanation. I still have no idea how to fix this for boost though.. I tried the following with no luck:
out.push(boost::archive<ch ar>::itera tors::base 64_from_bi nary());
--> error C2882: 'archive' : illegal use of namespace identifier in expression
out.push(boost::archive::i terators:: base64_fro m_binary<c har>);
--> error C2275: 'boost::archive::iterators ::base64_f rom_binary <Base>' : illegal use of this type as an expression
1> with
1> [
1> Base=char
1> ]
Thanks for the explanation. I still have no idea how to fix this for boost though.. I tried the following with no luck:
out.push(boost::archive<ch
--> error C2882: 'archive' : illegal use of namespace identifier in expression
out.push(boost::archive::i
--> error C2275: 'boost::archive::iterators
1> with
1> [
1> Base=char
1> ]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi jkr,
Thanks for that - looks very nice - but I absolutely need to use the filter chain approach. Maybe I'm wrong, but I don't think I can use these typedefs as a filter... (am I wrong? - really not sure)
io::filtering_ostream out;
out.push(io::zlib_compress or());
out.push(boost::archive::i terators:: base64_fro m_binary() ); // problem is here
out.push(io::file_sink(s)) ;
so when I write to out - it gets zipped - it gets base64 encoded - writes to file zipped and encoded...
Thanks for that - looks very nice - but I absolutely need to use the filter chain approach. Maybe I'm wrong, but I don't think I can use these typedefs as a filter... (am I wrong? - really not sure)
io::filtering_ostream out;
out.push(io::zlib_compress
out.push(boost::archive::i
out.push(io::file_sink(s))
so when I write to out - it gets zipped - it gets base64 encoded - writes to file zipped and encoded...
out.push(boost::archive<Ty
Can you show where you initialize boost?