Browse Source

Updated to Visual Studio 2015 RC1

* Fixed some warnings
* Disabled some warnings
* Fixed std::basic_string related errors
OpenSSL is now dynamically linked
Hid Jupiter::Database's private members
release/0.19
JustinAJ 10 years ago
parent
commit
95bc71a5f6
  1. 36
      Jupiter/Base64C.c
  2. 11
      Jupiter/CString.h
  3. 45
      Jupiter/Database.cpp
  4. 7
      Jupiter/Database.h
  5. 15
      Jupiter/Jupiter.vcxproj
  6. 4
      Jupiter/Jupiter.vcxproj.filters
  7. 7
      Jupiter/Reference_String.h
  8. 11
      Jupiter/Shift_String.h
  9. 6
      Jupiter/Shift_String_Imp.h
  10. 11
      Jupiter/String.h
  11. 11
      Jupiter/String_Type.h
  12. 22
      Jupiter/String_Type_Imp.h
  13. BIN
      Release/Jupiter.lib
  14. 6
      Tester/Tester.vcxproj

36
Jupiter/Base64C.c

@ -141,12 +141,6 @@ bool Jupiter_isBase64_s(const char *in, size_t inLen)
return true; 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 int Jupiter_base64decode(const char *in, unsigned char *out)
{ {
unsigned char *outOrig = 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 the buffer is full, split it into bytes */
if (buf & 0x1000000) if (buf & 0x1000000)
{ {
*out++ = buf >> 16; *out++ = (unsigned char) (buf >> 16);
*out++ = buf >> 8; *out++ = (unsigned char) (buf >> 8);
*out++ = buf; *out++ = (unsigned char) buf;
buf = 1; buf = 1;
} }
break; break;
@ -184,10 +178,10 @@ endLoop:
if (buf & 0x40000) if (buf & 0x40000)
{ {
*out++ = buf >> 10; *out++ = (unsigned char) (buf >> 10);
*out++ = buf >> 2; *out++ = (unsigned char) (buf >> 2);
} }
else if (buf & 0x1000) *out++ = buf >> 4; else if (buf & 0x1000) *out++ = (unsigned char) (buf >> 4);
return out - outOrig; 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 the buffer is full, split it into bytes */
if (buf & 0x1000000) if (buf & 0x1000000)
{ {
*out++ = buf >> 16; *out++ = (unsigned char) (buf >> 16);
*out++ = buf >> 8; *out++ = (unsigned char) (buf >> 8);
*out++ = buf; *out++ = (unsigned char) buf;
buf = 1; buf = 1;
} }
break; break;
@ -229,15 +223,11 @@ unsigned int Jupiter_base64decode_s(const char *in, size_t inLen, unsigned char
if (buf & 0x40000) if (buf & 0x40000)
{ {
*out++ = buf >> 10; *out++ = (unsigned char) (buf >> 10);
*out++ = buf >> 2; *out++ = (unsigned char) (buf >> 2);
} }
else if (buf & 0x1000) *out++ = buf >> 4; else if (buf & 0x1000)
*out++ = (unsigned char) (buf >> 4);
return out - outOrig; return out - outOrig;
} }
/** Re-enable warning */
#if defined _MSC_VER
#pragma warning(pop)
#endif

11
Jupiter/CString.h

@ -27,6 +27,12 @@
#include "Shift_String.h" #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 namespace Jupiter
{ {
/** /**
@ -449,6 +455,11 @@ namespace Jupiter
static const Jupiter::CStringType &emptyCString = emptyCStringS; 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. */ /** Implementation for CString_Type and CString_Loose. Very scary. */
#include "CString_Imp.h" #include "CString_Imp.h"

45
Jupiter/Database.cpp

@ -8,6 +8,15 @@
#include "Database.h" #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 *) void Jupiter::Database::process_header(FILE *)
{ {
} }
@ -18,39 +27,39 @@ void Jupiter::Database::create_header(FILE *)
bool Jupiter::Database::process_file(Jupiter::ReadableString &file) bool Jupiter::Database::process_file(Jupiter::ReadableString &file)
{ {
Jupiter::Database::file_name = file; Jupiter::Database::data_->file_name = file;
return Jupiter::Database::process_file(); return Jupiter::Database::Data::process_file(this);
} }
bool Jupiter::Database::process_file(Jupiter::CStringType &file) bool Jupiter::Database::process_file(Jupiter::CStringType &file)
{ {
Jupiter::Database::file_name = file; Jupiter::Database::data_->file_name = file;
return Jupiter::Database::process_file(); return Jupiter::Database::Data::process_file(this);
} }
bool Jupiter::Database::process_file(const char *file) bool Jupiter::Database::process_file(const char *file)
{ {
Jupiter::Database::file_name = file; Jupiter::Database::data_->file_name = file;
return Jupiter::Database::process_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 (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) if (file != nullptr)
{ {
this->create_header(file); db->create_header(file);
return true; return true;
} }
} }
return false; return false;
} }
bool r = Jupiter::Database::process_file(file); bool r = db->process_file(file);
fclose(file); fclose(file);
return r; return r;
} }
@ -85,7 +94,7 @@ void Jupiter::Database::process_file_finish(FILE *)
bool Jupiter::Database::append(Jupiter::DataBuffer &data) 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) 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"); FILE *f = fopen(file, "wb");
if (file == nullptr) if (file == nullptr)
return false; 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) if (header != nullptr)
fwrite(header->getHead(), sizeof(uint8_t), header->size(), file); 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() 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;
} }

7
Jupiter/Database.h

@ -123,11 +123,8 @@ namespace Jupiter
void set_auto_create(bool auto_create); void set_auto_create(bool auto_create);
private: private:
bool process_file(); struct Data;
static bool create_database(FILE *file, Jupiter::DataBuffer *header); Data *data_;
bool auto_create = true;
Jupiter::CStringS file_name;
}; };
} }

15
Jupiter/Jupiter.vcxproj

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -23,33 +23,34 @@
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>IRCBot</RootNamespace> <RootNamespace>IRCBot</RootNamespace>
<ProjectName>Jupiter</ProjectName> <ProjectName>Jupiter</ProjectName>
<TargetPlatformVersion>10.0.10069.0</TargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
@ -249,8 +250,8 @@
<ResourceCompile Include="Jupiter.rc" /> <ResourceCompile Include="Jupiter.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Library Include="..\..\..\OpenSSL\Win32\lib\VC\static\libeay32MD.lib" /> <Library Include="..\..\..\OpenSSL\Win32\lib\VC\libeay32MD.lib" />
<Library Include="..\..\..\OpenSSL\Win32\lib\VC\static\ssleay32MD.lib" /> <Library Include="..\..\..\OpenSSL\Win32\lib\VC\ssleay32MD.lib" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

4
Jupiter/Jupiter.vcxproj.filters

@ -261,10 +261,10 @@
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Library Include="..\..\..\OpenSSL\Win32\lib\VC\static\libeay32MD.lib"> <Library Include="..\..\..\OpenSSL\Win32\lib\VC\libeay32MD.lib">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Library> </Library>
<Library Include="..\..\..\OpenSSL\Win32\lib\VC\static\ssleay32MD.lib"> <Library Include="..\..\..\OpenSSL\Win32\lib\VC\ssleay32MD.lib">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Library> </Library>
</ItemGroup> </ItemGroup>

7
Jupiter/Reference_String.h

@ -234,6 +234,13 @@ namespace Jupiter
static Reference_String<T> gotoToken(const Jupiter::Readable_String<T> &in, size_t pos, const T &token); static Reference_String<T> gotoToken(const Jupiter::Readable_String<T> &in, size_t pos, const T &token);
static Reference_String<T> gotoToken(const Jupiter::Readable_String<T> &in, size_t pos, const Jupiter::Readable_String<T> &token); static Reference_String<T> gotoToken(const Jupiter::Readable_String<T> &in, size_t pos, const Jupiter::Readable_String<T> &token);
/** Mutative operators */
inline Readable_String<T> &operator-=(size_t right) { this->truncate(right); return *this; };
inline Readable_String<T> &operator=(const Readable_String<T> &right) { this->set(right); return *this; };
inline Readable_String<T> &operator=(const Reference_String<T> &right) { this->set(right); return *this; };
inline Readable_String<T> &operator=(const std::basic_string<T> &right) { this->set(right); return *this; };
inline Readable_String<T> &operator=(const T *right) { this->set(right); return *this; };
/** /**
* @brief Default constructor for the Reference_String class. * @brief Default constructor for the Reference_String class.
*/ */

11
Jupiter/Shift_String.h

@ -25,6 +25,12 @@
#include "String_Type.h" #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 namespace Jupiter
{ {
@ -109,6 +115,11 @@ namespace Jupiter
}; };
} }
/** Re-enable warning */
#if defined _MSC_VER
#pragma warning(pop)
#endif
#include "Shift_String_Imp.h" #include "Shift_String_Imp.h"
#endif // _SHIFT_STRING_H_HEADER #endif // _SHIFT_STRING_H_HEADER

6
Jupiter/Shift_String_Imp.h

@ -64,12 +64,12 @@ template<typename T> bool Jupiter::Shift_String_Type<T>::remove(const T &value)
return Jupiter::String_Type<T>::remove(value); return Jupiter::String_Type<T>::remove(value);
} }
template<typename T> void Jupiter::Shift_String_Type<T>::remove(size_t index, size_t length) template<typename T> void Jupiter::Shift_String_Type<T>::remove(size_t index, size_t len)
{ {
if (index == 0) if (index == 0)
this->shiftRight(length); this->shiftRight(len);
else else
Jupiter::String_Type<T>::remove(index, length); Jupiter::String_Type<T>::remove(index, len);
} }
template<typename T> bool Jupiter::Shift_String_Type<T>::setBufferSize(size_t len) template<typename T> bool Jupiter::Shift_String_Type<T>::setBufferSize(size_t len)

11
Jupiter/String.h

@ -27,6 +27,12 @@
#include "Shift_String.h" #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 namespace Jupiter
{ {
@ -485,6 +491,11 @@ namespace Jupiter
//static const Jupiter::StringType &emptyString = emptyStringS; //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. */ /** Implementation for String_Strict and String_Loose. Very scary. */
#include "String_Imp.h" #include "String_Imp.h"

11
Jupiter/String_Type.h

@ -27,6 +27,12 @@
#include <cstdarg> // va_list #include <cstdarg> // va_list
#include "Readable_String.h" #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 namespace Jupiter
{ {
@ -285,6 +291,11 @@ namespace Jupiter
} }
/** Re-enable warning */
#if defined _MSC_VER
#pragma warning(pop)
#endif
/** Implementation for String_Type. */ /** Implementation for String_Type. */
#include "String_Type_Imp.h" #include "String_Type_Imp.h"

22
Jupiter/String_Type_Imp.h

@ -59,10 +59,11 @@ template<typename T> const T *Jupiter::String_Type<T>::ptr() const
template<typename T> size_t Jupiter::String_Type<T>::format(const std::basic_string<T> &format, ...) template<typename T> size_t Jupiter::String_Type<T>::format(const std::basic_string<T> &format, ...)
{ {
const char *ptr = format.c_str();
size_t r; size_t r;
va_list args; va_list args;
va_start(args, format); va_start(args, ptr);
r = this->vformat(format.c_str(), args); r = this->vformat(ptr, args);
va_end(args); va_end(args);
return r; return r;
} }
@ -81,10 +82,11 @@ template<typename T> size_t Jupiter::String_Type<T>::format(const T *format, ...
template<typename T> size_t Jupiter::String_Type<T>::aformat(const std::basic_string<T> &format, ...) template<typename T> size_t Jupiter::String_Type<T>::aformat(const std::basic_string<T> &format, ...)
{ {
const char *ptr = format.c_str();
size_t r; size_t r;
va_list args; va_list args;
va_start(args, format); va_start(args, ptr);
r = this->avformat(format.c_str(), args); r = this->avformat(ptr, args);
va_end(args); va_end(args);
return r; return r;
} }
@ -132,21 +134,21 @@ template<typename T> bool Jupiter::String_Type<T>::remove(const T &value)
return false; return false;
} }
template<typename T> void Jupiter::String_Type<T>::remove(size_t index, size_t length) template<typename T> void Jupiter::String_Type<T>::remove(size_t index, size_t len)
{ {
if (index >= Jupiter::String_Type<T>::length) if (index >= Jupiter::String_Type<T>::length)
return; return;
if (index + length >= Jupiter::String_Type<T>::length) if (index + len >= Jupiter::String_Type<T>::length)
Jupiter::String_Type<T>::length = index; Jupiter::String_Type<T>::length = index;
else else
{ {
Jupiter::String_Type<T>::length -= length; Jupiter::String_Type<T>::length -= len;
length += index; len += index;
Jupiter::String_Type<T>::str[index] = Jupiter::String_Type<T>::str[length]; Jupiter::String_Type<T>::str[index] = Jupiter::String_Type<T>::str[len];
while (++index != Jupiter::String_Type<T>::length) while (++index != Jupiter::String_Type<T>::length)
Jupiter::String_Type<T>::str[index] = Jupiter::String_Type<T>::str[++length]; Jupiter::String_Type<T>::str[index] = Jupiter::String_Type<T>::str[++len];
} }
} }

BIN
Release/Jupiter.lib

Binary file not shown.

6
Tester/Tester.vcxproj

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -19,13 +19,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save