diff --git a/Jupiter/Base64C.c b/Jupiter/Base64C.c index f809e7a..abf6a0a 100644 --- a/Jupiter/Base64C.c +++ b/Jupiter/Base64C.c @@ -141,12 +141,6 @@ bool Jupiter_isBase64_s(const char *in, size_t inLen) return true; } -/** Disable warning 4244 */ -#if defined _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4244) // conversion from 'size_t' to 'unsigned char', possible loss of data -#endif - unsigned int Jupiter_base64decode(const char *in, unsigned char *out) { unsigned char *outOrig = out; @@ -172,9 +166,9 @@ unsigned int Jupiter_base64decode(const char *in, unsigned char *out) /* If the buffer is full, split it into bytes */ if (buf & 0x1000000) { - *out++ = buf >> 16; - *out++ = buf >> 8; - *out++ = buf; + *out++ = (unsigned char) (buf >> 16); + *out++ = (unsigned char) (buf >> 8); + *out++ = (unsigned char) buf; buf = 1; } break; @@ -184,10 +178,10 @@ endLoop: if (buf & 0x40000) { - *out++ = buf >> 10; - *out++ = buf >> 2; + *out++ = (unsigned char) (buf >> 10); + *out++ = (unsigned char) (buf >> 2); } - else if (buf & 0x1000) *out++ = buf >> 4; + else if (buf & 0x1000) *out++ = (unsigned char) (buf >> 4); return out - outOrig; } @@ -218,9 +212,9 @@ unsigned int Jupiter_base64decode_s(const char *in, size_t inLen, unsigned char /* If the buffer is full, split it into bytes */ if (buf & 0x1000000) { - *out++ = buf >> 16; - *out++ = buf >> 8; - *out++ = buf; + *out++ = (unsigned char) (buf >> 16); + *out++ = (unsigned char) (buf >> 8); + *out++ = (unsigned char) buf; buf = 1; } break; @@ -229,15 +223,11 @@ unsigned int Jupiter_base64decode_s(const char *in, size_t inLen, unsigned char if (buf & 0x40000) { - *out++ = buf >> 10; - *out++ = buf >> 2; + *out++ = (unsigned char) (buf >> 10); + *out++ = (unsigned char) (buf >> 2); } - else if (buf & 0x1000) *out++ = buf >> 4; + else if (buf & 0x1000) + *out++ = (unsigned char) (buf >> 4); return out - outOrig; } - -/** Re-enable warning */ -#if defined _MSC_VER -#pragma warning(pop) -#endif \ No newline at end of file diff --git a/Jupiter/CString.h b/Jupiter/CString.h index 565c8f5..8f3ee00 100644 --- a/Jupiter/CString.h +++ b/Jupiter/CString.h @@ -27,6 +27,12 @@ #include "Shift_String.h" +/** Disable warning 4458 */ +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4458) // declaration of 'length' hides class member +#endif + namespace Jupiter { /** @@ -449,6 +455,11 @@ namespace Jupiter static const Jupiter::CStringType &emptyCString = emptyCStringS; } +/** Re-enable warning */ +#if defined _MSC_VER +#pragma warning(pop) +#endif + /** Implementation for CString_Type and CString_Loose. Very scary. */ #include "CString_Imp.h" diff --git a/Jupiter/Database.cpp b/Jupiter/Database.cpp index 59bc6b4..f305989 100644 --- a/Jupiter/Database.cpp +++ b/Jupiter/Database.cpp @@ -8,6 +8,15 @@ #include "Database.h" +struct Jupiter::Database::Data +{ + static bool process_file(Jupiter::Database *db); + static bool create_database(FILE *file, Jupiter::DataBuffer *header); + + bool auto_create = true; + Jupiter::CStringS file_name; +}; + void Jupiter::Database::process_header(FILE *) { } @@ -18,39 +27,39 @@ void Jupiter::Database::create_header(FILE *) bool Jupiter::Database::process_file(Jupiter::ReadableString &file) { - Jupiter::Database::file_name = file; - return Jupiter::Database::process_file(); + Jupiter::Database::data_->file_name = file; + return Jupiter::Database::Data::process_file(this); } bool Jupiter::Database::process_file(Jupiter::CStringType &file) { - Jupiter::Database::file_name = file; - return Jupiter::Database::process_file(); + Jupiter::Database::data_->file_name = file; + return Jupiter::Database::Data::process_file(this); } bool Jupiter::Database::process_file(const char *file) { - Jupiter::Database::file_name = file; - return Jupiter::Database::process_file(); + Jupiter::Database::data_->file_name = file; + return Jupiter::Database::Data::process_file(this); } -bool Jupiter::Database::process_file() +bool Jupiter::Database::Data::process_file(Jupiter::Database *db) { - FILE *file = fopen(Jupiter::Database::file_name.c_str(), "rb"); + FILE *file = fopen(db->data_->file_name.c_str(), "rb"); if (file == nullptr) { - if (Jupiter::Database::auto_create) + if (db->data_->auto_create) { - file = fopen(Jupiter::Database::file_name.c_str(), "wb"); + file = fopen(db->data_->file_name.c_str(), "wb"); if (file != nullptr) { - this->create_header(file); + db->create_header(file); return true; } } return false; } - bool r = Jupiter::Database::process_file(file); + bool r = db->process_file(file); fclose(file); return r; } @@ -85,7 +94,7 @@ void Jupiter::Database::process_file_finish(FILE *) bool Jupiter::Database::append(Jupiter::DataBuffer &data) { - return Jupiter::Database::append(Jupiter::Database::file_name, data); + return Jupiter::Database::append(Jupiter::Database::data_->file_name, data); } bool Jupiter::Database::append(Jupiter::ReadableString &file, Jupiter::DataBuffer &data) @@ -145,10 +154,10 @@ bool Jupiter::Database::create_database(const char *file, Jupiter::DataBuffer *h FILE *f = fopen(file, "wb"); if (file == nullptr) return false; - return Jupiter::Database::create_database(f, header); + return Jupiter::Database::Data::create_database(f, header); } -bool Jupiter::Database::create_database(FILE *file, Jupiter::DataBuffer *header) +bool Jupiter::Database::Data::create_database(FILE *file, Jupiter::DataBuffer *header) { if (header != nullptr) fwrite(header->getHead(), sizeof(uint8_t), header->size(), file); @@ -158,10 +167,10 @@ bool Jupiter::Database::create_database(FILE *file, Jupiter::DataBuffer *header) bool Jupiter::Database::is_auto_create() { - return Jupiter::Database::auto_create; + return Jupiter::Database::data_->auto_create; } -void Jupiter::Database::set_auto_create(bool auto_create_) +void Jupiter::Database::set_auto_create(bool in) { - Jupiter::Database::auto_create = auto_create_; + Jupiter::Database::data_->auto_create = in; } \ No newline at end of file diff --git a/Jupiter/Database.h b/Jupiter/Database.h index e2598af..af515d3 100644 --- a/Jupiter/Database.h +++ b/Jupiter/Database.h @@ -123,11 +123,8 @@ namespace Jupiter void set_auto_create(bool auto_create); private: - bool process_file(); - static bool create_database(FILE *file, Jupiter::DataBuffer *header); - - bool auto_create = true; - Jupiter::CStringS file_name; + struct Data; + Data *data_; }; } diff --git a/Jupiter/Jupiter.vcxproj b/Jupiter/Jupiter.vcxproj index 47ccdc0..9c6a10f 100644 --- a/Jupiter/Jupiter.vcxproj +++ b/Jupiter/Jupiter.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -23,33 +23,34 @@ Win32Proj IRCBot Jupiter + 10.0.10069.0 Application true Unicode - v120 + v140 Application true Unicode - v120 + v140 DynamicLibrary false true Unicode - v120 + v140 DynamicLibrary false true Unicode - v120 + v140 @@ -249,8 +250,8 @@ - - + + diff --git a/Jupiter/Jupiter.vcxproj.filters b/Jupiter/Jupiter.vcxproj.filters index 0c4fa0f..4947af3 100644 --- a/Jupiter/Jupiter.vcxproj.filters +++ b/Jupiter/Jupiter.vcxproj.filters @@ -261,10 +261,10 @@ - + Resource Files - + Resource Files diff --git a/Jupiter/Reference_String.h b/Jupiter/Reference_String.h index 5b4fb59..46e49f9 100644 --- a/Jupiter/Reference_String.h +++ b/Jupiter/Reference_String.h @@ -234,6 +234,13 @@ namespace Jupiter static Reference_String gotoToken(const Jupiter::Readable_String &in, size_t pos, const T &token); static Reference_String gotoToken(const Jupiter::Readable_String &in, size_t pos, const Jupiter::Readable_String &token); + /** Mutative operators */ + inline Readable_String &operator-=(size_t right) { this->truncate(right); return *this; }; + inline Readable_String &operator=(const Readable_String &right) { this->set(right); return *this; }; + inline Readable_String &operator=(const Reference_String &right) { this->set(right); return *this; }; + inline Readable_String &operator=(const std::basic_string &right) { this->set(right); return *this; }; + inline Readable_String &operator=(const T *right) { this->set(right); return *this; }; + /** * @brief Default constructor for the Reference_String class. */ diff --git a/Jupiter/Shift_String.h b/Jupiter/Shift_String.h index 03882dd..7ecf043 100644 --- a/Jupiter/Shift_String.h +++ b/Jupiter/Shift_String.h @@ -25,6 +25,12 @@ #include "String_Type.h" +/** Disable warning 4458 */ +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4458) // declaration of 'length' hides class member +#endif + namespace Jupiter { @@ -109,6 +115,11 @@ namespace Jupiter }; } +/** Re-enable warning */ +#if defined _MSC_VER +#pragma warning(pop) +#endif + #include "Shift_String_Imp.h" #endif // _SHIFT_STRING_H_HEADER \ No newline at end of file diff --git a/Jupiter/Shift_String_Imp.h b/Jupiter/Shift_String_Imp.h index 7a88645..7465128 100644 --- a/Jupiter/Shift_String_Imp.h +++ b/Jupiter/Shift_String_Imp.h @@ -64,12 +64,12 @@ template bool Jupiter::Shift_String_Type::remove(const T &value) return Jupiter::String_Type::remove(value); } -template void Jupiter::Shift_String_Type::remove(size_t index, size_t length) +template void Jupiter::Shift_String_Type::remove(size_t index, size_t len) { if (index == 0) - this->shiftRight(length); + this->shiftRight(len); else - Jupiter::String_Type::remove(index, length); + Jupiter::String_Type::remove(index, len); } template bool Jupiter::Shift_String_Type::setBufferSize(size_t len) diff --git a/Jupiter/String.h b/Jupiter/String.h index ff0bd41..6b842ec 100644 --- a/Jupiter/String.h +++ b/Jupiter/String.h @@ -27,6 +27,12 @@ #include "Shift_String.h" +/** Disable warning 4458 */ +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4458) // declaration of 'length' hides class member +#endif + namespace Jupiter { @@ -485,6 +491,11 @@ namespace Jupiter //static const Jupiter::StringType &emptyString = emptyStringS; } +/** Re-enable warning */ +#if defined _MSC_VER +#pragma warning(pop) +#endif + /** Implementation for String_Strict and String_Loose. Very scary. */ #include "String_Imp.h" diff --git a/Jupiter/String_Type.h b/Jupiter/String_Type.h index 2e31cbd..f7ae093 100644 --- a/Jupiter/String_Type.h +++ b/Jupiter/String_Type.h @@ -27,6 +27,12 @@ #include // va_list #include "Readable_String.h" +/** Disable warning 4458 */ +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4458) // declaration of 'length' hides class member +#endif + namespace Jupiter { @@ -285,6 +291,11 @@ namespace Jupiter } +/** Re-enable warning */ +#if defined _MSC_VER +#pragma warning(pop) +#endif + /** Implementation for String_Type. */ #include "String_Type_Imp.h" diff --git a/Jupiter/String_Type_Imp.h b/Jupiter/String_Type_Imp.h index 590363c..18cd758 100644 --- a/Jupiter/String_Type_Imp.h +++ b/Jupiter/String_Type_Imp.h @@ -59,10 +59,11 @@ template const T *Jupiter::String_Type::ptr() const template size_t Jupiter::String_Type::format(const std::basic_string &format, ...) { + const char *ptr = format.c_str(); size_t r; va_list args; - va_start(args, format); - r = this->vformat(format.c_str(), args); + va_start(args, ptr); + r = this->vformat(ptr, args); va_end(args); return r; } @@ -81,10 +82,11 @@ template size_t Jupiter::String_Type::format(const T *format, ... template size_t Jupiter::String_Type::aformat(const std::basic_string &format, ...) { + const char *ptr = format.c_str(); size_t r; va_list args; - va_start(args, format); - r = this->avformat(format.c_str(), args); + va_start(args, ptr); + r = this->avformat(ptr, args); va_end(args); return r; } @@ -132,21 +134,21 @@ template bool Jupiter::String_Type::remove(const T &value) return false; } -template void Jupiter::String_Type::remove(size_t index, size_t length) +template void Jupiter::String_Type::remove(size_t index, size_t len) { if (index >= Jupiter::String_Type::length) return; - if (index + length >= Jupiter::String_Type::length) + if (index + len >= Jupiter::String_Type::length) Jupiter::String_Type::length = index; else { - Jupiter::String_Type::length -= length; - length += index; + Jupiter::String_Type::length -= len; + len += index; - Jupiter::String_Type::str[index] = Jupiter::String_Type::str[length]; + Jupiter::String_Type::str[index] = Jupiter::String_Type::str[len]; while (++index != Jupiter::String_Type::length) - Jupiter::String_Type::str[index] = Jupiter::String_Type::str[++length]; + Jupiter::String_Type::str[index] = Jupiter::String_Type::str[++len]; } } diff --git a/Release/Jupiter.lib b/Release/Jupiter.lib index 0d9c344..fe0ce60 100644 Binary files a/Release/Jupiter.lib and b/Release/Jupiter.lib differ diff --git a/Tester/Tester.vcxproj b/Tester/Tester.vcxproj index 76ad844..93aa3d3 100644 --- a/Tester/Tester.vcxproj +++ b/Tester/Tester.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,13 +19,13 @@ Application true - v120 + v140 Unicode Application false - v120 + v140 true Unicode