From 8365d3444bb41238e3a4908b16b97f2160d67a15 Mon Sep 17 00:00:00 2001 From: mrexodia Date: Sun, 5 Jun 2016 16:07:04 +0200 Subject: [PATCH] added x64 + fixed code issues --- btparser.sln | 6 +++++ btparser/btparser.vcxproj | 51 +++++++++++++++++++++++++++++++++++++++ btparser/filehelper.cpp | 3 +-- btparser/main.cpp | 13 +++++----- btparser/stringutils.cpp | 6 ++--- btparser/stringutils.h | 1 - 6 files changed, 67 insertions(+), 13 deletions(-) diff --git a/btparser.sln b/btparser.sln index 681d892..d664ad8 100644 --- a/btparser.sln +++ b/btparser.sln @@ -8,13 +8,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Debug|Win32.ActiveCfg = Debug|Win32 {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Debug|Win32.Build.0 = Debug|Win32 + {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Debug|x64.ActiveCfg = Debug|x64 + {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Debug|x64.Build.0 = Debug|x64 {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Release|Win32.ActiveCfg = Release|Win32 {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Release|Win32.Build.0 = Release|Win32 + {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Release|x64.ActiveCfg = Release|x64 + {B0411C78-2F06-49E0-8DE9-5C52A466F5DE}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/btparser/btparser.vcxproj b/btparser/btparser.vcxproj index 6460f6f..f8d4fef 100644 --- a/btparser/btparser.vcxproj +++ b/btparser/btparser.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + @@ -35,6 +43,12 @@ v120 MultiByte + + Application + true + v120 + MultiByte + Application false @@ -42,15 +56,28 @@ true MultiByte + + Application + false + v120 + true + MultiByte + + + + + + + @@ -63,6 +90,16 @@ true + + + Level3 + Disabled + true + + + true + + Level3 @@ -77,6 +114,20 @@ true + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + diff --git a/btparser/filehelper.cpp b/btparser/filehelper.cpp index 167a162..260ed9c 100644 --- a/btparser/filehelper.cpp +++ b/btparser/filehelper.cpp @@ -1,6 +1,5 @@ #include "filehelper.h" #include "handle.h" -#include "dynamicmem.h" #include "stringutils.h" bool FileHelper::ReadAllData(const String & fileName, std::vector & content) @@ -8,7 +7,7 @@ bool FileHelper::ReadAllData(const String & fileName, std::vector Handle hFile = CreateFileW(StringUtils::Utf8ToUtf16(fileName).c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); if(hFile == INVALID_HANDLE_VALUE) return false; - unsigned int filesize = GetFileSize(hFile, 0); + unsigned int filesize = GetFileSize(hFile, nullptr); if(!filesize) { content.clear(); diff --git a/btparser/main.cpp b/btparser/main.cpp index e7b69db..c4f71e7 100644 --- a/btparser/main.cpp +++ b/btparser/main.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include "filehelper.h" #include "stringutils.h" #include "testfiles.h" @@ -65,8 +64,8 @@ struct Lexer string NumStr; char CharLit = '\0'; int LastChar = ' '; - int CurLine = 0; - int LineIndex = 0; + size_t CurLine = 0; + size_t LineIndex = 0; static void clearReserve(string & str, size_t reserve = DEFAULT_STRING_BUFFER) { @@ -151,7 +150,7 @@ struct Lexer { case tok_eof: return "tok_eof"; case tok_error: return StringUtils::sprintf("error(line %d, col %d, \"%s\")", CurLine + 1, LineIndex, Error.c_str()); - case tok_identifier: return IdentifierStr.c_str(); + case tok_identifier: return IdentifierStr; case tok_number: return StringUtils::sprintf(IsHexNumberVal ? "0x%llX" : "%llu", NumberVal); case tok_stringlit: return StringUtils::sprintf("\"%s\"", StringUtils::Escape(StringLit).c_str()); case tok_charlit: @@ -170,7 +169,7 @@ struct Lexer } } - int PeekChar(int distance = 0) + int PeekChar(size_t distance = 0) { if (Index + distance >= Input.size()) return EOF; @@ -508,9 +507,9 @@ struct Lexer return FileHelper::ReadAllData(filename, Input); } - bool TestLex(function lexEnum, bool output = true) + bool TestLex(const function & lexEnum, bool output = true) { - auto line = 0; + size_t line = 0; if (output) lexEnum("1: "); int tok; diff --git a/btparser/stringutils.cpp b/btparser/stringutils.cpp index e98a095..81e3e1b 100644 --- a/btparser/stringutils.cpp +++ b/btparser/stringutils.cpp @@ -96,11 +96,11 @@ String StringUtils::TrimRight(const String & s) String StringUtils::Utf16ToUtf8(const WString & wstr) { String convertedString; - int requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, 0, 0, 0, 0); + auto requiredSize = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, nullptr, nullptr); if(requiredSize > 0) { std::vector buffer(requiredSize); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], requiredSize, 0, 0); + WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &buffer[0], requiredSize, nullptr, nullptr); convertedString.assign(buffer.begin(), buffer.end() - 1); } return convertedString; @@ -114,7 +114,7 @@ String StringUtils::Utf16ToUtf8(const wchar_t* wstr) WString StringUtils::Utf8ToUtf16(const String & str) { WString convertedString; - int requiredSize = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, 0, 0); + int requiredSize = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0); if(requiredSize > 0) { std::vector buffer(requiredSize); diff --git a/btparser/stringutils.h b/btparser/stringutils.h index 1f6f512..04b53b5 100644 --- a/btparser/stringutils.h +++ b/btparser/stringutils.h @@ -1,7 +1,6 @@ #ifndef _STRINGUTILS_H #define _STRINGUTILS_H -#include #include typedef std::string String;