Skip to content

Commit

Permalink
Support for 64-bit integers (for chunk files); std::numeric_limits in…
Browse files Browse the repository at this point in the history
…stead of constants in writer; removed VS project files - use CMake for solution generation
  • Loading branch information
hedger committed Mar 4, 2014
1 parent 23c34ea commit 3f825b4
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 232 deletions.
22 changes: 0 additions & 22 deletions BWXML.sln

This file was deleted.

3 changes: 2 additions & 1 deletion BWXML/BW.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,6 +35,7 @@ namespace BigWorld
};

#pragma pack(push, 1)
// FIXME: use union?
class DataDescriptor
{
unsigned int __raw;
Expand Down
20 changes: 11 additions & 9 deletions BWXML/BWCommon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,31 +28,33 @@ namespace BWPack
using namespace BigWorld;
using namespace IO;

static std::string serializeF(std::vector<float> floatVals)
static std::string serializeF(const std::vector<float>& floatVals)
{
std::stringstream _ret;
StreamBufWriter ret(_ret.rdbuf());
std::for_each(floatVals.begin(), floatVals.end(), [&](float v){ ret.put<float>(v); });
return _ret.str();
}

static std::string serializeI(int intVal)
static std::string serializeI(const long long& intVal)
{
std::stringstream _ret;
StreamBufWriter ret(_ret.rdbuf());

unsigned int absVal = abs(intVal);
if (absVal > 0x7FFF)
ret.put<int>(intVal);
else if (absVal > 0x7F)
unsigned long long absVal = abs(intVal);
if (absVal > std::numeric_limits<long>::max())
ret.put<long long>(intVal);
else if (absVal > std::numeric_limits<short>::max())
ret.put<int>(static_cast<int>(intVal));
else if (absVal > std::numeric_limits<char>::max())
ret.put<short>(static_cast<short>(intVal));
else if (absVal != 0)
ret.put<char>(static_cast<char>(intVal));

return _ret.str();
}

static std::string serializeB(bool boolVal)
static std::string serializeB(const bool boolVal)
{
std::stringstream _ret;
StreamBufWriter ret(_ret.rdbuf());
Expand Down Expand Up @@ -96,7 +98,7 @@ namespace BWPack
{
std::stringstream ss;
ss << strVal;
int i;
long long i;
ss >> i;
if (!ss.fail() && ss.eof())
return rawDataBlock(BW_Int, serializeI(i));
Expand Down
2 changes: 1 addition & 1 deletion BWXML/BWCommon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 4 additions & 1 deletion BWXML/BWReader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,6 +78,9 @@ namespace BWPack
case BW_Int:
switch (var_size)
{
case 8:
current_node.put_value(mStream.get<long long>());
break;
case 4:
current_node.put_value(mStream.get<int>());
break;
Expand Down
2 changes: 1 addition & 1 deletion BWXML/BWReader.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion BWXML/BWWriter.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion BWXML/BWWriter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
119 changes: 0 additions & 119 deletions BWXML/BWXML.vcxproj

This file was deleted.

69 changes: 0 additions & 69 deletions BWXML/BWXML.vcxproj.filters

This file was deleted.

2 changes: 1 addition & 1 deletion BWXML/Base64.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion BWXML/Base64.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion BWXML/DataStream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion BWXML/DataStream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions BWXML/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2013 hedger
Copyright 2013-2014 hedger
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,7 +72,7 @@ int main(int argc, char* argv[])

bpo::variables_map vm;

std::cout << "BWXML v1.01 by hedger" << std::endl;
std::cout << "BWXML v1.02 by hedger" << std::endl;

try
{
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ aux_source_directory(BWXML SOURCES)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(BWXML ${Boost_INCLUDE_DIRS})

add_executable(bwxml ${SOURCES})
file (GLOB headers BWXML/*.h*)
add_executable(bwxml ${SOURCES} ${headers})
target_link_libraries(bwxml ${Boost_LIBRARIES})

#
Expand Down
4 changes: 4 additions & 0 deletions make_vs_solution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir build
cd build
cmake -G "Visual Studio 11" ..
BWXML.sln

0 comments on commit 3f825b4

Please sign in to comment.