Library code style update + some minor backports from Pro edition
This commit is contained in:
parent
593b291e85
commit
2607113727
68 changed files with 4538 additions and 4665 deletions
45
lib/encode.h
45
lib/encode.h
|
@ -2,41 +2,42 @@
|
|||
#include <string>
|
||||
|
||||
/// Namespace for character encoding functions and classes
|
||||
namespace Encodings {
|
||||
namespace Encodings{
|
||||
|
||||
/// Holds base64 decoding and encoding functions.
|
||||
class Base64 {
|
||||
private:
|
||||
static const std::string chars;
|
||||
static inline bool is_base64(unsigned char c);
|
||||
public:
|
||||
static std::string encode(std::string const input);
|
||||
static std::string decode(std::string const & encoded_string);
|
||||
class Base64{
|
||||
private:
|
||||
static const std::string chars;
|
||||
static inline bool is_base64(unsigned char c);
|
||||
|
||||
public:
|
||||
static std::string encode(std::string const input);
|
||||
static std::string decode(std::string const &encoded_string);
|
||||
};
|
||||
|
||||
/// urlencoding and urldecoding functions
|
||||
class URL {
|
||||
public:
|
||||
/// urldecodes std::string data, parsing out both %-encoded characters and +-encoded spaces.
|
||||
static std::string decode(const std::string & in);
|
||||
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
|
||||
static std::string encode(const std::string & c, const std::string &ign = "");
|
||||
|
||||
class URL{
|
||||
public:
|
||||
/// urldecodes std::string data, parsing out both %-encoded characters and +-encoded spaces.
|
||||
static std::string decode(const std::string &in);
|
||||
/// urlencodes std::string data, leaving only the characters A-Za-z0-9~!&()' alone.
|
||||
static std::string encode(const std::string &c, const std::string &ign = "");
|
||||
};
|
||||
|
||||
/// Hexadecimal-related functions
|
||||
class Hex {
|
||||
public:
|
||||
class Hex{
|
||||
public:
|
||||
/// Decodes a single hexadecimal character to integer, case-insensitive.
|
||||
static inline int ord(char c){
|
||||
return ((c&15) + (((c&64)>>6) | ((c&64)>>3)));
|
||||
}
|
||||
static inline int ord(char c){return ((c & 15) + (((c & 64) >> 6) | ((c & 64) >> 3)));}
|
||||
/// Encodes a single character as two hex digits in string form.
|
||||
static std::string chr(char dec);
|
||||
|
||||
/// Decodes a hex-encoded std::string to a raw binary std::string.
|
||||
static std::string decode(const std::string & in);
|
||||
static std::string decode(const std::string &in);
|
||||
|
||||
/// Encodes a raw binary std::string to its hex-encoded form
|
||||
static std::string encode(const std::string &in);
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace Encodings
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue