Pārlūkot izejas kodu

Added to CodeDweller namespace.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@65 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz pirms 10 gadiem
vecāks
revīzija
6ad20893cc
2 mainītis faili ar 21 papildinājumiem un 15 dzēšanām
  1. 5
    0
      base64codec.cpp
  2. 16
    15
      base64codec.hpp

+ 5
- 0
base64codec.cpp Parādīt failu



#include "base64codec.hpp" #include "base64codec.hpp"


using namespace std;

namespace CodeDweller {

namespace base64codec { namespace base64codec {


const static char base64encode[65] = // Base64 encoding characters. const static char base64encode[65] = // Base64 encoding characters.
return BadConversion; return BadConversion;
} }


}

+ 16
- 15
base64codec.hpp Parādīt failu

#include <cstring> #include <cstring>
#include <string> #include <string>


using namespace std;
namespace CodeDweller {


typedef vector<unsigned char> base64buffer;
typedef std::vector<unsigned char> base64buffer;


class to_base64 : public base64buffer { // Converts binary data to base 64.
class to_base64 : public base64buffer { // Converts binary data to base 64.
private: private:
bool BadConversion; // True if something went wrong. bool BadConversion; // True if something went wrong.
void convert(const unsigned char* bfr, const int len); // Does the actual work. void convert(const unsigned char* bfr, const int len); // Does the actual work.


public: public:
to_base64(const vector<unsigned char>& bfr); // Converts from a base64buffer.
to_base64(const vector<char>& bfr); // Converts from a buffer.
to_base64(const string& s); // Converts from a c++ string.
to_base64(const std::vector<unsigned char>& bfr); // Converts from a base64buffer.
to_base64(const std::vector<char>& bfr); // Converts from a buffer.
to_base64(const std::string& s); // Converts from a c++ string.
to_base64(const char* s); // Converts from a c string. to_base64(const char* s); // Converts from a c string.
to_base64(const unsigned char* bfr, const int len); // Converts from a uchar buffer. to_base64(const unsigned char* bfr, const int len); // Converts from a uchar buffer.
to_base64(const char* bfr, const int len); // Converts from a char buffer. to_base64(const char* bfr, const int len); // Converts from a char buffer.
bool Bad(); bool Bad();
};
};


class from_base64 : public base64buffer { // Convert base64 data to binary.
class from_base64 : public base64buffer { // Convert base64 data to binary.
private: private:
bool BadConversion; // True if the conversion didn't go well. bool BadConversion; // True if the conversion didn't go well.
unsigned char NextSixBits( // Helper for decoding & ingoring spaces. unsigned char NextSixBits( // Helper for decoding & ingoring spaces.
int& cursor,
const unsigned char* bfr,
const int len);
int& cursor,
const unsigned char* bfr,
const int len);
void convert(const unsigned char* bfr, const int len); // Does the actual work. void convert(const unsigned char* bfr, const int len); // Does the actual work.


public: public:
from_base64(const vector<unsigned char>& bfr); // Converts from a base64buffer.
from_base64(const vector<char>& bfr); // Converts from a buffer.
from_base64(const string& s); // Converts from a c++ string.
from_base64(const std::vector<unsigned char>& bfr); // Converts from a base64buffer.
from_base64(const std::vector<char>& bfr); // Converts from a buffer.
from_base64(const std::string& s); // Converts from a c++ string.
from_base64(const char*); // Converts from a c_string. from_base64(const char*); // Converts from a c_string.
bool Bad(); // True if conversion wasn't complete. bool Bad(); // True if conversion wasn't complete.
};
};


}


#endif #endif

Notiek ielāde…
Atcelt
Saglabāt