Skip to content

Commit

Permalink
Test 6
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jun 6, 2024
1 parent 6cfc3db commit d4dfdf8
Showing 1 changed file with 59 additions and 56 deletions.
115 changes: 59 additions & 56 deletions include/sexpp/sexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,61 +44,6 @@
#include "sexp-public.h"
#include "sexp-error.h"

namespace sexp {

/*
* SEXP octet_t definitions
* We maintain some presumable redundancy with ctype
* However, we do enforce 'C' locale this way
*/

class SEXP_PUBLIC_SYMBOL sexp_char_defs_t {
protected:
static const bool base64digit[256]; /* true if c is base64 digit */
static const bool tokenchar[256]; /* true if c can be in a token */
static const unsigned char values[256][3]; /* values of c as { dec. hex, base64 } digit */
static std::locale c_locale;

static bool is_white_space(int c)
{
return c >= 0 && c <= 255 && std::isspace((char) c, c_locale);
};
static bool is_dec_digit(int c)
{
return c >= 0 && c <= 255 && std::isdigit((char) c, c_locale);
};
static bool is_hex_digit(int c)
{
return c >= 0 && c <= 255 && std::isxdigit((char) c, c_locale);
};
static bool is_base64_digit(int c) { return c >= 0 && c <= 255 && base64digit[c]; };
static bool is_token_char(int c) { return c >= 0 && c <= 255 && tokenchar[c]; };
static bool is_alpha(int c)
{
return c >= 0 && c <= 255 && std::isalpha((char) c, c_locale);
};

/* decvalue(c) is value of c as dec digit */
static unsigned char decvalue(int c) { return (c >= 0 && c <= 255) ? values[c][0] : 0; };
/* hexvalue(c) is value of c as a hex digit */
static unsigned char hexvalue(int c) { return (c >= 0 && c <= 255) ? values[c][1] : 0; };
/* base64value(c) is value of c as base64 digit */
static unsigned char base64value(int c)
{
return (c >= 0 && c <= 255) ? values[c][2] : 0;
};
};

class sexp_string_t;
class sexp_list_t;

class sexp_output_stream_t;
class sexp_input_stream_t;

/*
* SEXP simple string
*/

using octet_t = uint8_t;

template<>
Expand Down Expand Up @@ -126,7 +71,7 @@ using octet_t = uint8_t;

static size_t
length(const char_type* __s)
{ return strlen(__s); }
{ return strlen(reinterpret_cast<const char *>(__s)); }

static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
Expand Down Expand Up @@ -167,6 +112,64 @@ using octet_t = uint8_t;
{ return (__c == eof()) ? 0 : __c; }
};



namespace sexp {

/*
* SEXP octet_t definitions
* We maintain some presumable redundancy with ctype
* However, we do enforce 'C' locale this way
*/

class SEXP_PUBLIC_SYMBOL sexp_char_defs_t {
protected:
static const bool base64digit[256]; /* true if c is base64 digit */
static const bool tokenchar[256]; /* true if c can be in a token */
static const unsigned char values[256][3]; /* values of c as { dec. hex, base64 } digit */
static std::locale c_locale;

static bool is_white_space(int c)
{
return c >= 0 && c <= 255 && std::isspace((char) c, c_locale);
};
static bool is_dec_digit(int c)
{
return c >= 0 && c <= 255 && std::isdigit((char) c, c_locale);
};
static bool is_hex_digit(int c)
{
return c >= 0 && c <= 255 && std::isxdigit((char) c, c_locale);
};
static bool is_base64_digit(int c) { return c >= 0 && c <= 255 && base64digit[c]; };
static bool is_token_char(int c) { return c >= 0 && c <= 255 && tokenchar[c]; };
static bool is_alpha(int c)
{
return c >= 0 && c <= 255 && std::isalpha((char) c, c_locale);
};

/* decvalue(c) is value of c as dec digit */
static unsigned char decvalue(int c) { return (c >= 0 && c <= 255) ? values[c][0] : 0; };
/* hexvalue(c) is value of c as a hex digit */
static unsigned char hexvalue(int c) { return (c >= 0 && c <= 255) ? values[c][1] : 0; };
/* base64value(c) is value of c as base64 digit */
static unsigned char base64value(int c)
{
return (c >= 0 && c <= 255) ? values[c][2] : 0;
};
};

class sexp_string_t;
class sexp_list_t;

class sexp_output_stream_t;
class sexp_input_stream_t;

/*
* SEXP simple string
*/


using octet_traits = std::char_traits<octet_t>;
using octet_string = std::basic_string<octet_t, octet_traits>;

Expand Down

0 comments on commit d4dfdf8

Please sign in to comment.