Skip to content

Commit 5dc07ed

Browse files
committed
It builds.
1 parent 064d425 commit 5dc07ed

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

include/simdjson/implementation.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ class implementation {
8383
* @return the error code, or SUCCESS if there was no error.
8484
*/
8585
WARN_UNUSED virtual error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept = 0;
86+
87+
88+
/**
89+
* Validate the UTF-8 string.
90+
*
91+
* Overridden by each implementation.
92+
*
93+
* @param buf the string to validate.
94+
* @param len the length of the string in bytes.
95+
* @return true if and only if the string is valid UTF-8.
96+
*/
97+
WARN_UNUSED virtual bool utf8_validate(const char *buf, size_t len) const noexcept = 0;
8698

8799
protected:
88100
/** @private Construct an implementation with the given name and description. For subclasses. */

src/arm64/implementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class implementation final : public simdjson::implementation {
1818
std::unique_ptr<internal::dom_parser_implementation>& dst
1919
) const noexcept final;
2020
WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final;
21-
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept;//mark final
21+
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept final;
2222
};
2323

2424
} // namespace arm64

src/fallback/implementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class implementation final : public simdjson::implementation {
2222
std::unique_ptr<internal::dom_parser_implementation>& dst
2323
) const noexcept final;
2424
WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final;
25-
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept;//mark final
25+
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept final;
2626
};
2727

2828
} // namespace fallback

src/haswell/implementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class implementation final : public simdjson::implementation {
2020
std::unique_ptr<internal::dom_parser_implementation>& dst
2121
) const noexcept final;
2222
WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final;
23-
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept;//mark final
23+
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept final;
2424
};
2525

2626
} // namespace haswell

src/implementation.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class detect_best_supported_implementation_on_first_use final : public implement
4848
WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final {
4949
return set_best()->minify(buf, len, dst, dst_len);
5050
}
51-
51+
WARN_UNUSED bool utf8_validate(const char * buf, size_t len) const noexcept final override {
52+
return set_best()->utf8_validate(buf, len);
53+
}
5254
really_inline detect_best_supported_implementation_on_first_use() noexcept : implementation("best_supported_detector", "Detects the best supported implementation and sets it", 0) {}
5355
private:
5456
const implementation *set_best() const noexcept;
@@ -83,10 +85,12 @@ class unsupported_implementation final : public implementation {
8385
) const noexcept final {
8486
return UNSUPPORTED_ARCHITECTURE;
8587
}
86-
WARN_UNUSED error_code minify(const uint8_t *, size_t, uint8_t *, size_t &) const noexcept final {
88+
WARN_UNUSED error_code minify(const uint8_t *, size_t, uint8_t *, size_t &) const noexcept final override {
8789
return UNSUPPORTED_ARCHITECTURE;
8890
}
89-
91+
WARN_UNUSED bool utf8_validate(const char *, size_t) const noexcept final override {
92+
return false; // just refuse the validate
93+
}
9094
unsupported_implementation() : implementation("unsupported", "Unsupported CPU (no detected SIMD instructions)", 0) {}
9195
};
9296

src/westmere/implementation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class implementation final : public simdjson::implementation {
1919
std::unique_ptr<internal::dom_parser_implementation>& dst
2020
) const noexcept final;
2121
WARN_UNUSED error_code minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept final;
22-
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept;//mark final
22+
WARN_UNUSED bool utf8_validate(const char *buf, size_t len) const noexcept final;
2323
};
2424

2525
} // namespace westmere

0 commit comments

Comments
 (0)