Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tree 1c #49

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
*~
*.tmp
Debug
Release
*.o
*.d
tmp
.codelite
.VS
*.json
v8unpack.txt
*.workspace
Makefile
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ build_script:

after_build:
- cmd: >-
SET PATH=%PATH%;"C:/Program Files (x86)/WiX Toolset v3.10/bin"
SET PATH=%PATH%;"C:/Program Files (x86)/WiX Toolset v3.11/bin"

candle v8unpack.wxs

Expand Down
14 changes: 14 additions & 0 deletions src/SystemClasses/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

*.o
bin/*
obj/*
build/*
Debug/*
x64/*

*.layout
*.depend

*.a
*.out

33 changes: 33 additions & 0 deletions src/SystemClasses/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required (VERSION 2.8)
project (SystemClasses)

set (SYSTEM_SOURCES String.cpp System.Classes.cpp System.cpp
System.IOUtils.cpp TFileStream.cpp TMemoryStream.cpp TStream.cpp
TStreamReader.cpp TStreamWriter.cpp System.SysUtils.cpp
GetTickCount.cpp)
set (SYSTEM_HEADERS String.hpp System.Classes.hpp System.hpp
System.IOUtils.hpp TFileStream.hpp TMemoryStream.hpp TStream.hpp
TStreamReader.hpp TStreamWriter.hpp System.SysUtils.hpp
GetTickCount.hpp)

if (CMAKE_VERSION VERSION_LESS "3.1")
if(CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif()
else()
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED YES)
set (CMAKE_CXX_EXTENSIONS OFF)
endif()

add_library (SystemClasses STATIC ${SYSTEM_SOURCES} ${SYSTEM_HEADERS})

add_definitions (-DBOOST_ALL_NO_LIB)
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_MULTITHREADED OFF)
set (Boost_USE_STATIC_RUNTIME ON)

find_package (Boost 1.53 REQUIRED COMPONENTS filesystem regex system)

include_directories (${Boost_INCLUDE_DIRS})
target_link_libraries (SystemClasses ${Boost_LIBRARIES})
8 changes: 8 additions & 0 deletions src/SystemClasses/Classes.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CLASSES_HPP
#define CLASSES_HPP

#include "System.Classes.hpp"

#endif


38 changes: 38 additions & 0 deletions src/SystemClasses/DynamicArray.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef SYSTEM_DYNAMICARRAY_HPP
#define SYSTEM_DYNAMICARRAY_HPP

#include <vector>

namespace System {

template <typename T>
class DynamicArray : public std::vector<T> {

public:

int get_length() const
{
return this->size();
}

void set_length(int new_length)
{
this->resize(new_length);
}

int GetLength() const
{
return this->size();
}

void SetLength(int NewSize)
{
this->resize(NewSize);
}

};

}

#endif

64 changes: 64 additions & 0 deletions src/SystemClasses/Exception.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef SYSTEM__EXCEPTION_HPP
#define SYSTEM__EXCEPTION_HPP

#include <string>
#include "String.hpp"

namespace System {

// http://stackoverflow.com/a/8152888
class Exception: public std::exception
{
public:
/** Constructor (C strings).
* @param message C-style string error message.
* The string contents are copied upon construction.
* Hence, responsibility for deleting the char* lies
* with the caller.
*/
explicit Exception(const char* message):
msg_(message)
{
}

explicit Exception(const wchar_t* message):
msg_("")
{
}

/** Constructor (C++ STL strings).
* @param message The error message.
*/
explicit Exception(const std::string& message):
msg_(message)
{}

/** Destructor.
* Virtual to allow for subclassing.
*/
virtual ~Exception() throw (){}

/** Returns a pointer to the (constant) error description.
* @return A pointer to a const char*. The underlying memory
* is in posession of the Exception object. Callers must
* not attempt to free the memory.
*/
virtual const char* what() const throw (){
return msg_.c_str();
}

String Message() const
{
return msg_;
}

protected:
/** Error message.
*/
std::string msg_;
};

} // System

#endif

30 changes: 30 additions & 0 deletions src/SystemClasses/GetTickCount.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "GetTickCount.hpp"

#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif // _WIN32

namespace System {

namespace Classes {

// (c) http://www.doctort.org/adam/nerd-notes/linux-equivalent-of-the-windows-gettickcount-function.html
unsigned long GetTickCount()
{
#ifdef _WIN32
return (unsigned long)(::GetTickCount());
#else
struct timeval tv;
if(gettimeofday(&tv, nullptr) != 0) {
return 0;
}

return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
#endif // _WIN32
}

} // Classe

} // System
15 changes: 15 additions & 0 deletions src/SystemClasses/GetTickCount.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef GETTICKCOUNT_HPP_INCLUDED
#define GETTICKCOUNT_HPP_INCLUDED

namespace System {

namespace Classes {

unsigned long GetTickCount();

}

}


#endif // GETTICKCOUNT_HPP_INCLUDED
Loading