remove format changes

v1
Brett 2023-07-24 02:55:03 -04:00
parent 85fdc4fa65
commit f5d6ef19a4
2 changed files with 6 additions and 7 deletions

View File

@ -11,7 +11,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <blt/math/math.h> #include <blt/math/math.h>
#include <blt/std/memory.h>
namespace blt::string { namespace blt::string {
@ -64,12 +63,12 @@ namespace blt::string {
} }
struct utf8_string { struct utf8_string {
blt::scoped_buffer<char> characters; char* characters;
unsigned int size;
}; };
// taken from java, adapted for c++. // taken from java, adapted for c++.
static inline utf8_string createUTFString(const std::string& str) { static inline utf8_string createUTFString(const std::string& str) {
const auto strlen = (unsigned int) str.size(); const auto strlen = (unsigned int) str.size();
unsigned int utflen = strlen; unsigned int utflen = strlen;
@ -82,7 +81,9 @@ namespace blt::string {
if (utflen > 65535 || /* overflow */ utflen < strlen) if (utflen > 65535 || /* overflow */ utflen < strlen)
throw "UTF Error"; throw "UTF Error";
utf8_string chars{scoped_buffer<char>{utflen + 2}}; utf8_string chars{};
chars.size = utflen + 2;
chars.characters = new char[chars.size];
int count = 0; int count = 0;
chars.characters[count++] = (char) ((utflen >> 0) & 0xFF); chars.characters[count++] = (char) ((utflen >> 0) & 0xFF);

View File

@ -58,9 +58,7 @@ namespace blt {
* Creates an encapsulation of a T array which will be automatically deleted when this object goes out of scope. * Creates an encapsulation of a T array which will be automatically deleted when this object goes out of scope.
* This is a simple buffer meant to be used only inside of a function and not moved around, with a few minor exceptions. * This is a simple buffer meant to be used only inside of a function and not moved around, with a few minor exceptions.
* The internal buffer is allocated on the heap. * The internal buffer is allocated on the heap.
* The operator * has been overloaded to return the internal buffer. (or just use scoped_buffer.buffer if you wish to be explicit) * The operator * has been overloaded to return the internal buffer.
* The operator & was not used because I think it is stupid to do so.
* "*" on a reference is fine however since it isn't used to dereference in the case.
* @tparam T type that is stored in buffer eg char * @tparam T type that is stored in buffer eg char
*/ */
template<typename T> template<typename T>