Skip to content

Commit

Permalink
fix - for ubuntu..
Browse files Browse the repository at this point in the history
  • Loading branch information
vztpv authored Sep 24, 2023
1 parent ea7a3f2 commit 9710bbc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
58 changes: 30 additions & 28 deletions _simdjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6002,34 +6002,36 @@ inline error_code dom_parser_implementation::allocate(size_t capacity, size_t ma
#include <memory>

namespace _simdjson {
class String {
public:
/**
* Validate the UTF-8 string.
*
* @param buf the string to validate.
* @param len the length of the string in bytes.
* @return true if the string is valid UTF-8.
*/
static _simdjson_warn_unused bool validate_utf8(const char* buf, size_t len) noexcept;
/**
* Validate the UTF-8 string.
*
* @param sv the string_view to validate.
* @return true if the string is valid UTF-8.
*/
static _simdjson_warn_unused bool validate_utf8(const std::string_view sv) noexcept {
return validate_utf8(sv.data(), sv.size());
}

/**
* Validate the UTF-8 string.
*
* @param buf the string to validate.
* @param len the length of the string in bytes.
* @return true if the string is valid UTF-8.
*/
_simdjson_warn_unused bool validate_utf8(const char * buf, size_t len) noexcept;
/**
* Validate the UTF-8 string.
*
* @param sv the string_view to validate.
* @return true if the string is valid UTF-8.
*/
_simdjson_inline _simdjson_warn_unused bool validate_utf8(const std::string_view sv) noexcept {
return validate_utf8(sv.data(), sv.size());
}

/**
* Validate the UTF-8 string.
*
* @param p the string to validate.
* @return true if the string is valid UTF-8.
*/
_simdjson_inline _simdjson_warn_unused bool validate_utf8(const std::string& s) noexcept {
return validate_utf8(s.data(), s.size());
}
/**
* Validate the UTF-8 string.
*
* @param p the string to validate.
* @return true if the string is valid UTF-8.
*/
static _simdjson_warn_unused bool validate_utf8(const std::string& s) noexcept {
return validate_utf8(s.data(), s.size());
}
};

/**
* An implementation of _simdjson for a particular CPU architecture.
Expand Down Expand Up @@ -7240,7 +7242,7 @@ SIMDJSON_DLLIMPORTEXPORT internal::atomic_ptr<const implementation>& get_active_
_simdjson_warn_unused error_code minify(const char *buf, size_t len, char *dst, size_t &dst_len) noexcept {
return get_active_implementation()->minify(reinterpret_cast<const uint8_t *>(buf), len, reinterpret_cast<uint8_t *>(dst), dst_len);
}
_simdjson_warn_unused bool validate_utf8(const char *buf, size_t len) noexcept {
_simdjson_warn_unused bool String::validate_utf8(const char *buf, size_t len) noexcept {
return get_active_implementation()->validate_utf8(buf, len);
}
const implementation * builtin_implementation() {
Expand Down
12 changes: 7 additions & 5 deletions _simdjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -3218,22 +3218,24 @@ inline error_code dom_parser_implementation::allocate(size_t capacity, size_t ma
#include <memory>

namespace _simdjson {

class String {
public:
/**
* Validate the UTF-8 string.
*
* @param buf the string to validate.
* @param len the length of the string in bytes.
* @return true if the string is valid UTF-8.
*/
_simdjson_inline _simdjson_warn_unused bool validate_utf8(const char* buf, size_t len) noexcept;
static _simdjson_warn_unused bool validate_utf8(const char* buf, size_t len) noexcept;

/**
* Validate the UTF-8 string.
*
* @param sv the string_view to validate.
* @return true if the string is valid UTF-8.
*/
_simdjson_inline _simdjson_warn_unused bool validate_utf8(const std::string_view sv) noexcept {
static _simdjson_warn_unused bool validate_utf8(const std::string_view sv) noexcept {
return validate_utf8(sv.data(), sv.size());
}

Expand All @@ -3243,10 +3245,10 @@ namespace _simdjson {
* @param p the string to validate.
* @return true if the string is valid UTF-8.
*/
_simdjson_inline _simdjson_warn_unused bool validate_utf8(const std::string& s) noexcept {
static _simdjson_warn_unused bool validate_utf8(const std::string& s) noexcept {
return validate_utf8(s.data(), s.size());
}

};
/**
* An implementation of _simdjson for a particular CPU architecture.
*
Expand Down
12 changes: 6 additions & 6 deletions claujson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ namespace claujson {

// chk... fallback..
{
bool valid = _simdjson::validate_utf8(reinterpret_cast<char*>(buf_src), len);
bool valid = _simdjson::String::validate_utf8(reinterpret_cast<char*>(buf_src), len);

if (!valid) {
free(buf_src);
Expand Down Expand Up @@ -1168,7 +1168,7 @@ namespace claujson {
buf_src[len] = '"';

{
bool valid = _simdjson::validate_utf8(reinterpret_cast<char*>(buf_src), len);
bool valid = _simdjson::String::validate_utf8(reinterpret_cast<char*>(buf_src), len);

if (!valid) {
log << warn << "not valid utf8" << "\n";
Expand Down Expand Up @@ -6717,7 +6717,7 @@ state = 2;

// chk... fallback..
{
bool valid = _simdjson::validate_utf8(reinterpret_cast<char*>(buf_src), len);
bool valid = _simdjson::String::validate_utf8(reinterpret_cast<char*>(buf_src), len);

if (!valid) {
free(buf_src);
Expand Down Expand Up @@ -6751,7 +6751,7 @@ state = 2;
buf_src[len] = '"';

{
bool valid = _simdjson::validate_utf8(reinterpret_cast<char*>(buf_src), len);
bool valid = _simdjson::String::validate_utf8(reinterpret_cast<char*>(buf_src), len);

if (!valid) {
log << warn << "not valid utf8" << "\n";
Expand Down Expand Up @@ -6800,7 +6800,7 @@ state = 2;

// chk... fallback..
{
bool valid = _simdjson::validate_utf8(reinterpret_cast<char*>(buf_src), len);
bool valid = _simdjson::String::validate_utf8(reinterpret_cast<char*>(buf_src), len);

if (!valid) {
free(buf_src);
Expand Down Expand Up @@ -6839,7 +6839,7 @@ state = 2;
buf_src[len] = '"';

{
bool valid = _simdjson::validate_utf8(reinterpret_cast<char*>(buf_src), len);
bool valid = _simdjson::String::validate_utf8(reinterpret_cast<char*>(buf_src), len);

if (!valid) {
log << warn << "not valid utf8" << "\n";
Expand Down

0 comments on commit 9710bbc

Please sign in to comment.