Skip to content

Commit

Permalink
Move implementation of Bytes::[lower|upper] to cc file.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Dec 17, 2024
1 parent b45bbc4 commit 359c3f5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 2 additions & 9 deletions hilti/runtime/include/types/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <hilti/rt/json-fwd.h>
#include <hilti/rt/result.h>
#include <hilti/rt/safe-int.h>
#include <hilti/rt/types/string.h>
#include <hilti/rt/types/time.h>
#include <hilti/rt/types/vector.h>
#include <hilti/rt/unicode.h>
Expand Down Expand Up @@ -445,10 +444,7 @@ class Bytes : protected std::string {
* @param errors how to handle errors when decoding/encoding the data
* @return an upper case version of the instance
*/
Bytes upper(unicode::Charset cs,
unicode::DecodeErrorStrategy errors = unicode::DecodeErrorStrategy::REPLACE) const {
return hilti::rt::string::encode(hilti::rt::string::upper(decode(cs, errors), errors), cs, errors);
}
Bytes upper(unicode::Charset cs, unicode::DecodeErrorStrategy errors = unicode::DecodeErrorStrategy::REPLACE) const;

/**
* Returns an upper-case version of the instance.
Expand All @@ -457,10 +453,7 @@ class Bytes : protected std::string {
* @param errors how to handle errors when decoding/encoding the data
* @return a lower case version of the instance
*/
Bytes lower(unicode::Charset cs,
unicode::DecodeErrorStrategy errors = unicode::DecodeErrorStrategy::REPLACE) const {
return hilti::rt::string::encode(hilti::rt::string::lower(decode(cs, errors), errors), cs, errors);
}
Bytes lower(unicode::Charset cs, unicode::DecodeErrorStrategy errors = unicode::DecodeErrorStrategy::REPLACE) const;

/**
* Removes leading and/or trailing sequences of all characters of a set
Expand Down
1 change: 1 addition & 0 deletions hilti/runtime/src/tests/integer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <hilti/rt/safe-int.h>
#include <hilti/rt/types/bytes.h>
#include <hilti/rt/types/integer.h>
#include <hilti/rt/types/string.h>
#include <hilti/rt/types/tuple.h>

using namespace hilti::rt;
Expand Down
1 change: 1 addition & 0 deletions hilti/runtime/src/tests/union.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <hilti/rt/doctest.h>
#include <hilti/rt/extension-points.h>
#include <hilti/rt/types/integer.h>
#include <hilti/rt/types/string.h>
#include <hilti/rt/types/union.h>

using namespace hilti::rt;
Expand Down
8 changes: 8 additions & 0 deletions hilti/runtime/src/types/bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ Bytes Bytes::strip(bytes::Side side) const {
cannot_be_reached();
}

Bytes Bytes::upper(unicode::Charset cs, unicode::DecodeErrorStrategy errors) const {
return string::encode(string::upper(decode(cs, errors), errors), cs, errors);
}

integer::safe<int64_t> Bytes::toInt(uint64_t base) const {
int64_t x = 0;
if ( hilti::rt::atoi_n(str().begin(), str().end(), base, &x) == str().end() )
Expand Down Expand Up @@ -315,6 +319,10 @@ double Bytes::toReal() const {
return d;
}

Bytes Bytes::lower(unicode::Charset cs, unicode::DecodeErrorStrategy errors) const {
return string::encode(string::lower(decode(cs, errors), errors), cs, errors);
}

Result<Bytes> Bytes::match(const RegExp& re, unsigned int group) const {
auto groups = re.matchGroups(*this);

Expand Down

0 comments on commit 359c3f5

Please sign in to comment.