Link to home
Start Free TrialLog in
Avatar of thready
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
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();

Open in new window

Avatar of Jonez176
Jonez176
Flag of United States of America image

It looks like you're not defining a type for one of your classes.  This is just a shot in the dark, but the compiler is probably looking for something along the lines of:

out.push(boost::archive<TypeOfArchive>::iterators::base64_from_binary());  // problem is here

Can you show where you initialize boost?
Avatar of thready
thready

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.
Avatar of thready

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<char>::iterators::base64_from_binary());
  -->  error C2882: 'archive' : illegal use of namespace identifier in expression

      out.push(boost::archive::iterators::base64_from_binary<char>);
  --> error C2275: 'boost::archive::iterators::base64_from_binary<Base>' : illegal use of this type as an expression
1>        with
1>        [
1>            Base=char
1>        ]
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thready

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_compressor());
out.push(boost::archive::iterators::base64_from_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...