corrected various function signatures

This commit is contained in:
jez_higgins 2002-09-02 15:52:19 +00:00
parent cc0523251e
commit f8f39d636b
2 changed files with 28 additions and 23 deletions

View file

@ -13,7 +13,7 @@ base64_codecvt::~base64_codecvt()
{
} // ~base64_codecvt
std::codecvt_base::result base64_codecvt::do_out(mbstate_t& state,
std::codecvt_base::result base64_codecvt::do_out(state_t& state,
const char* from,
const char* from_end,
const char*& from_next,
@ -71,7 +71,7 @@ std::codecvt_base::result base64_codecvt::do_out(mbstate_t& state,
return ((getState() == 0) && (getCurrentOutChar() == NO_MORE) && (getPreviousChar() == 0)) ? std::codecvt_base::ok : std::codecvt_base::partial;
} // do_out
std::codecvt_base::result base64_codecvt::do_in(mbstate_t& state,
std::codecvt_base::result base64_codecvt::do_in(state_t& state,
const char* from,
const char* from_end,
const char*& from_next,
@ -86,9 +86,10 @@ std::codecvt_base::result base64_codecvt::do_in(mbstate_t& state,
while((from_next != from_end) && (to != to_limit))
{
char c = base64_charset.find(*from_next++);
if(c == std::string::npos)
size_t i = base64_charset.find(*from_next++);
if(i == std::string::npos)
continue;
char c = static_cast<char>(i);
char p = getPreviousChar();
switch(getState())
@ -112,17 +113,17 @@ std::codecvt_base::result base64_codecvt::do_in(mbstate_t& state,
return (from_next == from_end) ? std::codecvt_base::ok : std::codecvt_base::partial;
} // do_in
std::codecvt_base::result base64_codecvt::do_unshift(mbstate_t& state,
std::codecvt_base::result base64_codecvt::do_unshift(state_t& state,
char* to,
char* /* to_limit */,
char*& to_next) const
{
to_next = to;
state = 0;
state = state_t(0);
return codecvt_base::ok;
} // do_unshift
mbstate_t base64_codecvt::do_encoding() const throw()
int base64_codecvt::do_encoding() const throw()
{
return 0;
} // do_encoding
@ -132,7 +133,7 @@ bool base64_codecvt::do_always_noconv() const throw()
return false;
} // do_always_noconv
mbstate_t base64_codecvt::do_length(const mbstate_t&,
int base64_codecvt::do_length(const state_t&,
const char* from,
const char* end,
size_t max) const
@ -152,20 +153,21 @@ mbstate_t base64_codecvt::do_length(const mbstate_t&,
return length;
} // do_length
mbstate_t base64_codecvt::do_max_length() const throw()
int base64_codecvt::do_max_length() const throw()
{
return 2;
} // do_max_length
mbstate_t base64_codecvt::getState() const
int base64_codecvt::getState() const
{
return (*state_) & 0xff;
} // getState
void base64_codecvt::nextState() const
{
mbstate_t s = getState();
if(++s == 4)
state_t s = getState();
s = s + 1;
if(s == 4)
s = 0;
*state_ &= 0xffffff00;
@ -206,4 +208,4 @@ void base64_codecvt::consumeOutChar() const
setPreviousChar(0);
} // consumeOutChar
// end of file
// end of file

View file

@ -8,12 +8,15 @@
#include <locale>
class base64_codecvt : public std::codecvt<char, char, mbstate_t>
class base64_codecvt : public std::codecvt<char, char, std::char_traits<char>::state_type>
{
public:
typedef std::char_traits<char>::state_type state_t;
protected:
virtual ~base64_codecvt();
virtual result do_out(mbstate_t& state,
virtual result do_out(state_t& state,
const char* from,
const char* from_end,
const char*& from_next,
@ -21,7 +24,7 @@ protected:
char* to_limit,
char*& to_next) const;
virtual result do_in(mbstate_t& state,
virtual result do_in(state_t& state,
const char* from,
const char* from_end,
const char*& from_next,
@ -29,35 +32,35 @@ protected:
char* to_limit,
char*& to_next) const;
virtual result do_unshift(mbstate_t& state,
virtual result do_unshift(state_t& state,
char* to,
char* to_limit,
char*& to_next) const;
virtual mbstate_t do_encoding() const throw();
virtual int do_encoding() const throw();
virtual bool do_always_noconv() const throw();
virtual mbstate_t do_length(const mbstate_t&,
virtual int do_length(const state_t&,
const char* from,
const char* end,
size_t max) const;
virtual mbstate_t do_max_length() const throw();
virtual int do_max_length() const throw();
private:
// state here is a little tricky - we need the previous char and
// the state counter, and in some case we need to "pad" the input
// strings. I use these helper functions to mungle them
// together and keep the details neater (or try to anyway)
mutable mbstate_t* state_;
mutable state_t* state_;
mutable const char** from_next_;
mutable const char** from_end_;
void grabState(mbstate_t& state) const { state_ = &state; }
void grabState(state_t& state) const { state_ = &state; }
void grabFromNext(const char*& from_next) const { from_next_ = &from_next; }
void grabFromEnd(const char*& from_end) const { from_end_ = &from_end; }
mbstate_t getState() const;
int getState() const;
void nextState() const;
int getCurrentOutChar() const;
void consumeOutChar() const;