Commit f15d849e authored by Alexey.Musinov's avatar Alexey.Musinov Committed by Alexander Trofimov

(1.0.0.123) upвыпиливание boost'a



git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52999 954022d7-b5bf-4e40-9824-e11837661b57
parent 29ca0486
......@@ -6,10 +6,6 @@
#include "..\..\Common\OfficeFileTemplate.h"
#include "..\DocxDocConverter\FileConverter.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
// IOfficeDocFile
[
object,
......
......@@ -150,7 +150,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\Common\ASCDocxFormat\Source\Utility;..\..\Common\ASCDocxFormat\Source\DocxFormat;..\..\Common\ASCDocxFormat\Source\Common;..\..\Common\ASCDocxFormat\Source\XML;&quot;..\ZLIB\zlib-1.2.3\contrib\minizip&quot;;&quot;..\ZLIB\zlib-1.2.3&quot;;..\..\ASCImageStudio3\ASCGraphics\OfficeSvmFile"
AdditionalIncludeDirectories="..\..\Common\ASCDocxFormat\Source\Utility;..\..\Common\ASCDocxFormat\Source\DocxFormat;..\..\Common\ASCDocxFormat\Source\Common;..\..\Common\ASCDocxFormat\Source\XML;&quot;..\ZLIB\zlib-1.2.3\contrib\minizip&quot;;&quot;..\ZLIB\zlib-1.2.3&quot;"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_ATL_ATTRIBUTES"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
......
......@@ -36,6 +36,7 @@
// ATL
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
......@@ -46,6 +47,8 @@
#include <atlconv.h>
#include <ole2.h>
using namespace ATL;
// C
#include <io.h>
......@@ -58,6 +61,9 @@
#include <share.h>
#include <iosfwd>
#include <sstream>
#include <stdarg.h>
#include <wchar.h>
#include <time.h>
// STL
......@@ -68,8 +74,7 @@
#include <algorithm>
#include <bitset>
#include <set>
using namespace ATL;
#include <stdexcept>
#include "..\Common\TargetOptions.h"
#include "..\Common\FormatUtils.h"
......@@ -97,4 +102,9 @@ struct ProgressCallback
LPVOID caller;
};
#pragma comment(lib, "Utility.lib")
#pragma comment(lib, "Common.lib")
#pragma comment(lib, "DocxFormat.lib")
#pragma comment(lib, "XML.lib")
#include "Resource.h"
\ No newline at end of file
......@@ -2,6 +2,6 @@
//1
//0
//0
//122
#define INTVER 1,0,0,122
#define STRVER "1,0,0,122\0"
//123
#define INTVER 1,0,0,123
#define STRVER "1,0,0,123\0"
......@@ -33,7 +33,7 @@ namespace ASCDocFormatUtils
{
template <typename T> void operator()( const T* ptr ) const
{
RELEASEOBJECT( ptr );
RELEASEOBJECT(ptr);
}
};
......@@ -75,8 +75,6 @@ namespace ASCDocFormatUtils
return ( ( value & mask ) == mask );
}
/*========================================================================================================*/
static inline int BytesToInt32( const unsigned char *b, unsigned int start, unsigned int length )
{
if ( ( b == NULL ) || ( ( start + 3 ) >= length ) )
......@@ -90,7 +88,6 @@ namespace ASCDocFormatUtils
BYTE b2 = b[start+2];
BYTE b3 = b[start+3];
long intValue = ((b3 << 24) | (b2 << 16) | (b1 << 8) | b0);
//int b0 = (int)b[start];
......@@ -104,8 +101,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline unsigned int BytesToUInt32( const unsigned char *b, unsigned int start, unsigned int length )
{
if ( ( b == NULL ) || ( ( start + 3 ) >= length ) )
......@@ -125,8 +120,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline short BytesToInt16( const unsigned char *b, unsigned int start, unsigned int length )
{
if ( ( b == NULL ) || ( ( start + 1 ) >= length ) )
......@@ -144,8 +137,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline unsigned short BytesToUInt16( const unsigned char *b, unsigned int start, unsigned int length )
{
if ( ( b == NULL ) || ( ( start + 1 ) >= length ) )
......@@ -176,35 +167,11 @@ namespace ASCDocFormatUtils
return pBuffer [start];
}
/*========================================================================================================*/
/*static list<wchar_t>* ToUnicodeChars( const list<byte> *chars )
{
list<byte>::const_iterator iter = chars->begin();
list<wchar_t> *unicodeChars = new list<wchar_t>();
byte bytes[2] = { 0, 0 };
while( iter != chars->end() )
{
bytes[0] = *iter++;
bytes[1] = *iter++;
unicodeChars->push_back( FormatUtils::BytesToUInt16( bytes, 0, 2 ) );
}
return unicodeChars;
}*/
/*========================================================================================================*/
static inline bool IsControlSymbol( unsigned short c )
{
return ( c <= 31 ) ? ( true ) : ( false );
}
/*========================================================================================================*/
static inline wstring GetXMLSymbol( const WCHAR c )
{
wstring result;
......@@ -252,8 +219,6 @@ namespace ASCDocFormatUtils
return result;
}
/*========================================================================================================*/
static inline WCHAR MapByteToWChar( byte byteSymbol )
{
WCHAR wcharSymbol = 0;
......@@ -414,8 +379,6 @@ namespace ASCDocFormatUtils
return wcharSymbol;
}
/*========================================================================================================*/
template<class T> static bool GetSTLCollectionFromBytes( T *STLCollection, byte *bytes, int size, Encoding encoding )
{
if ( ( STLCollection == NULL ) || ( bytes == NULL ) )
......@@ -453,8 +416,6 @@ namespace ASCDocFormatUtils
return false;
}
/*========================================================================================================*/
static int BitmaskToInt( int value, int mask )
{
int ret = value & mask;
......@@ -477,8 +438,6 @@ namespace ASCDocFormatUtils
return ret;
}
/*========================================================================================================*/
static inline int GetIntFromBits( int value, unsigned int startBit, unsigned int bitsCount )
{
int retval = value >> startBit; // Move to start bit.
......@@ -488,8 +447,6 @@ namespace ASCDocFormatUtils
return ( retval & bitmask ); // Get value.
}
/*========================================================================================================*/
static inline bool GetBitFromInt( int value, unsigned int bit )
{
if ( bit >= ( sizeof(int) * 8 ) )
......@@ -500,8 +457,6 @@ namespace ASCDocFormatUtils
return ( ( value >> bit ) & 0x00000001 );
}
/*========================================================================================================*/
static inline unsigned int GetUIntFromBytesBits( byte* bytes, unsigned int size, unsigned int startBit, unsigned int bitsCount )
{
if ( ( bytes == NULL ) || ( startBit >= ( size * 8 ) ) || ( bitsCount > ( ( size * 8 ) - startBit ) ) )
......@@ -530,8 +485,6 @@ namespace ASCDocFormatUtils
return result;
}
/*========================================================================================================*/
static inline bool GetBitFromBytes( byte* bytes, unsigned int size, unsigned int bit )
{
if ( ( bytes == NULL ) || ( bit >= ( size * 8 ) ) )
......@@ -542,8 +495,6 @@ namespace ASCDocFormatUtils
return (bool)GetBitFromInt( bytes[bit/8], bit%8 );
}
/*========================================================================================================*/
static int ArraySum( byte* values, int size )
{
int ret = 0;
......@@ -559,8 +510,6 @@ namespace ASCDocFormatUtils
return ret;
}
/*========================================================================================================*/
static inline byte* GetBytes( int value )
{
byte *bytes = new byte[4];
......@@ -630,8 +579,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline wstring IntToFormattedWideString( int value, const WCHAR* format )
{
const int size = 33;
......@@ -646,8 +593,6 @@ namespace ASCDocFormatUtils
return wstring( strValue );
}
/*========================================================================================================*/
static inline wstring DoubleToFormattedWideString( double value, WCHAR* format )
{
wstring wstr;
......@@ -671,8 +616,6 @@ namespace ASCDocFormatUtils
return wstr;
}
/*========================================================================================================*/
static inline void SetBytes( byte *bytes, int value )
{
if ( bytes != NULL )
......@@ -684,8 +627,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline void SetBytes( byte *bytes, short value )
{
if ( bytes != NULL )
......@@ -695,8 +636,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline void SetBytes( byte *bytes, unsigned int value )
{
if ( bytes != NULL )
......@@ -708,8 +647,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static inline void SetBytes( byte *bytes, unsigned short value )
{
if ( bytes != NULL )
......@@ -719,8 +656,6 @@ namespace ASCDocFormatUtils
}
}
/*========================================================================================================*/
static wstring UTF8Decode( const string& text )
{
wstring wstrText( text.size(), 0 );
......@@ -733,6 +668,7 @@ namespace ASCDocFormatUtils
struct Rectangle
{
public:
Rectangle()
{
topLeftAngle.x = 0;
......@@ -741,7 +677,6 @@ namespace ASCDocFormatUtils
size.cx = 0;
size.cy = 0;
}
Rectangle(const POINT& oTopLeftAngle, const SIZE& oSize)
{
topLeftAngle.x = oTopLeftAngle.x;
......@@ -751,8 +686,9 @@ namespace ASCDocFormatUtils
size.cy = oSize.cy;
}
POINT topLeftAngle;
SIZE size;
public:
POINT topLeftAngle;
SIZE size;
};
class BitSet
......@@ -782,7 +718,7 @@ namespace ASCDocFormatUtils
}
}
template<class T> inline void SetBits(T bits, unsigned int startBit, unsigned int countOfBits = ( 8 * sizeof(T) ))
template<class T> inline void SetBits(T bits, unsigned int startBit, unsigned int countOfBits = (8 * sizeof(T)))
{
if ( ( this->bytes != NULL ) && ( startBit < ( 8 * this->size ) ) )
{
......@@ -814,8 +750,7 @@ namespace ASCDocFormatUtils
}
private:
unsigned int size;
byte* bytes;
unsigned int size;
byte* bytes;
};
}
......@@ -9,11 +9,6 @@
#include "InternalElements.h"
#include "TableUtils.h"
#pragma comment(lib, "Utility.lib")
#pragma comment(lib, "Common.lib")
#pragma comment(lib, "DocxFormat.lib")
#pragma comment(lib, "XML.lib")
namespace DOCXTODOC
{
class CPrCopier
......
......@@ -23,11 +23,13 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
......
......@@ -2,4 +2,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
</Project>
\ No newline at end of file
......@@ -39,7 +39,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\..\Source\Utility;.\..\Source\XML;.\..\Source\Common;..\..\..\..\..\Redist;..\..\..\..\AVSImageStudio3\AVSGraphics\OfficeSvmFile\"
AdditionalIncludeDirectories=".\..\Source\Utility;.\..\Source\XML;.\..\Source\Common;..\..\..\..\..\Redist"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
......@@ -105,7 +105,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories=".\..\Source\Utility;.\..\Source\XML;.\..\Source\Common;..\..\..\..\..\Redist;..\..\..\..\AVSImageStudio3\AVSGraphics\OfficeSvmFile\"
AdditionalIncludeDirectories=".\..\Source\Utility;.\..\Source\XML;.\..\Source\Common;..\..\..\..\..\Redist"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
......
......@@ -349,6 +349,10 @@
RelativePath="..\Source\Utility\ASCStlUtils.h"
>
</File>
<File
RelativePath="..\Source\Utility\CallTraits.h"
>
</File>
<File
RelativePath="..\Source\Utility\codecvt.cpp"
>
......@@ -461,30 +465,6 @@
RelativePath="..\Source\Utility\Log.h"
>
</File>
<File
RelativePath="..\Source\Utility\LogDetails.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\Utility\"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)\Utility\"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\Source\Utility\LogDetails.h"
>
</File>
<File
RelativePath="..\Source\Utility\nullable.h"
>
......
......@@ -5,35 +5,29 @@
#include "Path.h"
namespace OOX
{
namespace Theme
{
Path::Path()
{
}
Path::~Path()
{
}
Path::Path(const XML::XNode& node)
{
fromXML(node);
}
const Path& Path::operator =(const XML::XNode& node)
{
fromXML(node);
return *this;
}
void Path::fromXML(const XML::XNode& node)
{
const XML::XElement element(node);
......@@ -43,10 +37,9 @@ namespace OOX
m_fillToRect = element.element("fillToRect");
}
const XML::XNode Path::toXML() const
{
return XML::XElement();
return XML::XElement();
}
} // namespace Theme
......
......@@ -25,17 +25,4 @@
#include "../../../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include "../../../../Common/DocxFormat/Source/Base/SmartPtr.h"
#include "../../../../Common/DocxFormat/Source/Base/Nullable.h"
#include "../../../../Common/DocxFormat/Source/Xml/XmlUtils.h"
///////////////////////////////////////////////
#include "Utility.h"
#include "Log.h"
#include "XML.h"
#include "property.h"
#include "nullable.h"
#include "ToString.h"
#include "nullable_property.h"
#include "setter.h"
#include "getter.h"
#include "Common.h"
#include "../../../../Common/DocxFormat/Source/Xml/XmlUtils.h"
\ No newline at end of file
#pragma once
#ifndef CALL_TRAITS_INCLUDE_H_
#define CALL_TRAITS_INCLUDE_H_
template <typename T>
struct NSCT_IMP
{
typedef const T& param_type;
};
template <typename T>
struct NSCallTraits
{
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef typename NSCT_IMP<T>::param_type param_type;
};
#endif // CALL_TRAITS_INCLUDE_H_
\ No newline at end of file
......@@ -3,7 +3,8 @@
#define UTILITY_GETTER_INCLUDE_H_
#include <stdexcept>
#include <boost/call_traits.hpp>
#include "CallTraits.h"
namespace getter
{
......@@ -11,15 +12,14 @@ namespace getter
class base_getter
{
protected:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
const Type operator()(Parameter _value) const
{
must_release();
//must_release();
}
};
template<typename Type>
class simple : private base_getter<Type>
{
......@@ -29,18 +29,6 @@ namespace getter
return _value;
}
};
template<typename Type>
class write_only : private base_getter<Type>
{
public:
const Type operator()(Parameter _value) const
{
it_is_write_only();
}
};
} // namespace getter
}
#endif // UTILITY_GETTER_INCLUDE_H_
\ No newline at end of file
......@@ -4,56 +4,36 @@
// auto inserted precompiled end
#include "Log.h"
#include <fstream>
#include <iostream>
Details::Log Log::s_loger("converter.log", "converter.err");
void Log::event(const std::string& message)
{
s_loger.event(message);
}
void Log::event(const std::wstring& message)
{
s_loger.event(message);
}
void Log::warning(const std::string& message)
{
s_loger.warning(message);
}
void Log::warning(const std::wstring& message)
{
s_loger.warning(message);
}
void Log::error(const std::string& message)
{
s_loger.error(message);
}
void Log::error(const std::wstring& message)
{
s_loger.error(message);
}
void Log::message(const std::string& message)
{
s_loger.message(message);
}
void Log::message(const std::wstring& message)
{
s_loger.message(message);
}
\ No newline at end of file
......@@ -3,8 +3,6 @@
#define UTILITY_LOG_INCLUDE_H_
#include <string>
#include "LogDetails.h"
class Log
{
......@@ -17,9 +15,6 @@ public:
static void warning(const std::wstring& message);
static void error(const std::string& message);
static void error(const std::wstring& message);
private:
static Details::Log s_loger;
};
#endif // UTILITY_LOG_INCLUDE_H_
\ No newline at end of file
......@@ -3,27 +3,25 @@
#define UTILITY_SETTER_INCLUDE_H_
#include <stdexcept>
#include <boost/call_traits.hpp>
#include <algorithm>
#include <set>
#include "CallTraits.h"
namespace setter
{
template<typename Type>
class base_setter
template<typename Type> class base_setter
{
protected:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
void operator()(Type& _value, Parameter value)
{
must_release();
// must_release();
}
};
class none
{
public:
......@@ -33,7 +31,6 @@ namespace setter
}
};
template<typename Type>
class simple : private base_setter<Type>
{
......@@ -44,18 +41,16 @@ namespace setter
}
};
class read_only
{
public:
template<typename T, typename E>
void operator()(T, E)
{
it_is_read_only();
//it_is_read_only();
}
};
template<typename Type>
class only_positive : private base_setter<Type>
{
......
......@@ -2,20 +2,20 @@
#ifndef UTILITY_NULLABLE_PROPERTY_INCLUDE_H_
#define UTILITY_NULLABLE_PROPERTY_INCLUDE_H_
#include <string>
#include "Setter.h"
#include "Getter.h"
#include "nullable.h"
#include <boost/call_traits.hpp>
#include <boost/type_traits.hpp>
#include <string>
#include "ToString.h"
#include "CallTraits.h"
template<typename Type, class Setter = setter::simple<Type>, class Getter = getter::simple<Type> >
class nullable_property
{
private:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
nullable_property() {}
......@@ -27,41 +27,40 @@ public:
: _value(rhs, setter, getter) {}
nullable_property(const nullable__<Type>& value) : _value(value) {}
template<typename U>
const nullable_property& operator =(const U& value)
template<typename U> const nullable_property& operator =(const U& value)
{
return ::nullable_property_setter(*this, value);
}
const nullable_property& operator =(const nullable_property& value)
{
return ::nullable_property_setter(*this, value);
}
template<typename U>
const nullable_property& nullable_property_setter(const U& value)
template<typename U> const nullable_property& nullable_property_setter(const U& value)
{
_value = static_cast<Type>(value);
return *this;
}
const nullable_property& nullable_property_setter(const nullable_property& value)
{
_value = value;
return *this;
}
template<typename U, class S, class G>
const nullable_property& nullable_property_setter(const nullable_property<U, S, G>& value)
template<typename U, class S, class G> const nullable_property& nullable_property_setter(const nullable_property<U, S, G>& value)
{
_value = value;
return *this;
}
const nullable_property& nullable_property_setter(const nullable__<Type>& value)
{
_value = value;
return *this;
}
operator const Type() const {return get();}
operator const nullable__<Type>() const {return _value.get_nullable();}
const Type get() const {return _value.get();}
......@@ -104,16 +103,15 @@ public:
private:
template<typename Type, class Setter, class Getter, bool simple>
class _nullable_property
class InternalNullableProperty
{
private:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
_nullable_property() {}
_nullable_property(Parameter value, const Setter&, const Getter&)
: _value(value) {Setter()(*_value, value);}
_nullable_property(const nullable__<Type>& value)
InternalNullableProperty() {}
InternalNullableProperty(Parameter value, const Setter&, const Getter&) : _value(value) { Setter()(*_value, value); }
InternalNullableProperty(const nullable__<Type>& value)
{
if (value.is_init())
{
......@@ -122,12 +120,12 @@ private:
}
}
void operator =(Parameter value)
inline void operator =(Parameter value)
{
_value = value;
Setter()(*_value, value);
}
template<typename U, class S, class G>
void operator =(const nullable_property<U, S, G>& rhs)
{
......@@ -141,7 +139,8 @@ private:
_value = nullable__<Type>();
}
}
void operator =(const nullable__<Type>& value)
inline void operator =(const nullable__<Type>& value)
{
if (value.is_init())
{
......@@ -154,48 +153,47 @@ private:
}
}
inline const Type get() const {return Getter()(*_value);}
inline const nullable__<Type> get_nullable() const {return is_init() ? nullable__<Type>(get()) : nullable__<Type>();}
inline Type const* const get_ptr() const {return _value.get_ptr();}
inline Type* get_ptr() {return _value.get_ptr();}
const Type get() const {return Getter()(*_value);}
const nullable__<Type> get_nullable() const {return is_init() ? nullable__<Type>(get()) : nullable__<Type>();}
Type const* const get_ptr() const {return _value.get_ptr();}
Type* get_ptr() {return _value.get_ptr();}
Type& operator*() {return *_value;}
inline Type& operator*() {return *_value;}
const bool is_init() const {return _value.is_init();}
void reset() {_value.reset();}
void init() {_value.init();}
inline const bool is_init() const {return _value.is_init();}
inline void reset() {_value.reset();}
inline void init() {_value.init();}
private:
nullable__<Type> _value;
};
template<typename Type, class Setter, class Getter>
class _nullable_property<Type, Setter, Getter, false>
class InternalNullableProperty<Type, Setter, Getter, false>
{
private:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
_nullable_property() {}
_nullable_property(const Setter& setter, const Getter& getter)
InternalNullableProperty() {}
InternalNullableProperty(const Setter& setter, const Getter& getter)
:
_setter(setter),
_setter(setter),
_getter(getter)
{
}
_nullable_property(Parameter value, const Setter& setter, const Getter& getter)
InternalNullableProperty(Parameter value, const Setter& setter, const Getter& getter)
:
_value(value),
_value(value),
_setter(setter),
_getter(getter)
{
_setter(*_value, value);
}
template<typename U, class S, class G>
_nullable_property(nullable_property<U, S, G> const& rhs, const Setter& setter, const Getter& getter)
InternalNullableProperty(nullable_property<U, S, G> const& rhs, const Setter& setter, const Getter& getter)
:
_setter(setter),
_setter(setter),
_getter(getter)
{
if (rhs.is_init())
......@@ -204,7 +202,8 @@ private:
_setter(*_value, rhs.get());
}
}
_nullable_property(const nullable__<Type>& value)
InternalNullableProperty(const nullable__<Type>& value)
{
if (value.is_init())
{
......@@ -213,12 +212,12 @@ private:
}
}
void operator =(Parameter value)
inline void operator =(Parameter value)
{
_value = value;
_setter(*_value, value);
}
template<typename U, class S, class G>
void operator =(const nullable_property<U, S, G>& rhs)
{
......@@ -232,7 +231,8 @@ private:
_value = nullable__<Type>();
}
}
void operator =(const nullable__<Type>& value)
inline void operator =(const nullable__<Type>& value)
{
if (value.is_init())
{
......@@ -245,30 +245,27 @@ private:
}
}
inline const Type get() const {return _getter(*_value);}
inline const nullable__<Type> get_nullable() const {return is_init() ? nullable__<Type>(get()) : nullable__<Type>();}
inline Type const* const get_ptr() const {return _value.get_ptr();}
inline Type* get_ptr() {return _value.get_ptr();}
const Type get() const {return _getter(*_value);}
const nullable__<Type> get_nullable() const {return is_init() ? nullable__<Type>(get()) : nullable__<Type>();}
Type const* const get_ptr() const {return _value.get_ptr();}
Type* get_ptr() {return _value.get_ptr();}
Type& operator*() {return *_value;}
inline Type& operator*() {return *_value;}
const bool is_init() const {return _value.is_init();}
void reset() {_value.reset();}
void init() {_value.init();}
inline const bool is_init() const {return _value.is_init();}
inline void reset() {_value.reset();}
inline void init() {_value.init();}
private:
nullable__<Type> _value;
Setter _setter;
Getter _getter;
Setter _setter;
Getter _getter;
};
private:
_nullable_property<Type, Setter, Getter,
boost::has_trivial_constructor<Setter>::value &&
boost::has_trivial_constructor<Getter>::value> _value;
};
InternalNullableProperty<Type, Setter, Getter, true> _value;
};
template<class T, class S, class G> const bool operator ==(const T x, nullable_property<T, S, G> const& y) {return y == x;}
template<class T, class S, class G> const bool operator !=(const T x, nullable_property<T, S, G> const& y) {return y != x;}
......@@ -284,14 +281,12 @@ template<typename V, class T, class S, class G> const bool operator > (const V x
template<typename V, class T, class S, class G> const bool operator <=(const V x, nullable_property<T, S, G> const& y) {return y <= x;}
template<typename V, class T, class S, class G> const bool operator >=(const V x, nullable_property<T, S, G> const& y) {return y >= x;}
template<typename T, class S, class G, typename U>
const nullable_property<T, S, G>& nullable_property_setter(nullable_property<T, S, G>& lhs, const U& rhs)
{
return lhs.nullable_property_setter(rhs);
}
template<typename T, typename U, class S, class G>
const nullable__<T>& nullable_setter(nullable__<T>& lhs, const nullable_property<U, S, G>& rhs)
{
......@@ -301,15 +296,12 @@ const nullable__<T>& nullable_setter(nullable__<T>& lhs, const nullable_property
return lhs;
}
template<typename T, class S, class G>
const std::string ToString(const nullable_property<T, S, G>& value)
{
return value.ToString();
}
template<typename T, class S, class G>
const nullable_property<T, S, G> merge(const nullable_property<T, S, G>& prev, const nullable_property<T, S, G>& current)
{
......
......@@ -4,31 +4,25 @@
#include "Setter.h"
#include "Getter.h"
#include <boost/call_traits.hpp>
#include <boost/type_traits.hpp>
#include <string>
#include "ToString.h"
#include "CallTraits.h"
template<typename Type, class Setter = setter::simple<Type>, class Getter = getter::simple<Type> >
class property
{
private:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
property() : _value() {}
property(const Setter& setter, const Getter& getter = Getter()) : _value(setter, getter) {}
property(Parameter value, const Setter& setter = Setter(), const Getter& getter = Getter())
: _value(value, setter, getter) {}
property(Parameter value, const Setter& setter = Setter(), const Getter& getter = Getter()) : _value(value, setter, getter) {}
template<typename U, class S, class G>
property(property<U, S, G> const& rhs, const Setter& setter = Setter(), const Getter& getter = Getter())
: _value(rhs, setter, getter) {}
property(property<U, S, G> const& rhs, const Setter& setter = Setter(), const Getter& getter = Getter()) : _value(rhs, setter, getter) {}
template<typename U>
const property& operator =(const U& value)
template<typename U> const property& operator =(const U& value)
{
return ::property_setter(*this, value);
}
......@@ -37,9 +31,7 @@ public:
return ::property_setter(*this, value);
}
template<typename U>
const property& property_setter(const U& value)
template<typename U> const property& property_setter(const U& value)
{
_value = static_cast<Type>(value);
return *this;
......@@ -49,8 +41,7 @@ public:
_value = value;
return *this;
}
template<typename U, class S, class G>
const property& operator =(const property<U, S, G>& value)
template<typename U, class S, class G> const property& operator =(const property<U, S, G>& value)
{
_value = value;
return *this;
......@@ -67,7 +58,6 @@ public:
Type const* const operator->() const {return _value.get_ptr();}
Type* operator->() {return _value.get_ptr();}
const std::string ToString() const {return ::ToString(get());}
const bool operator ==(property<Type, Setter, Getter> const& rhs) const {return get() == rhs.get();}
......@@ -106,39 +96,34 @@ public:
template<typename T, class S, class G> const Type operator *(const property<T, S, G>& rhs) const {return _value * rhs.get();}
template<typename T, class S, class G> const Type operator /(const property<T, S, G>& rhs) const {return _value / rhs.get();}
private:
template<typename Type, class Setter, class Getter, bool simple>
class _property
class InternalProperty
{
private:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
_property() {Setter()(_value, Type());}
_property(Parameter value, const Setter&, const Getter&)
: _value(value)
InternalProperty() {Setter()(_value, Type());}
InternalProperty(Parameter value, const Setter&, const Getter&) : _value(value)
{
Setter()(_value, value);
}
template<typename U, class S, class G>
_property(property<U, S, G> const& rhs, const Setter&, const Getter&)
: _value(rhs.get())
InternalProperty(property<U, S, G> const& rhs, const Setter&, const Getter&) : _value(rhs.get())
{
Setter()(_value, rhs.get());
}
void operator =(Parameter value) {Setter()(_value, value);}
const Type get() const {return Getter()(_value);}
Type& get() {return _value;}
Type const* const get_ptr() const {return &_value;}
Type* get_ptr() {return &_value;}
Type* get_ptr() {return &_value;}
template<typename T> void operator +=(const T value) {Setter()(_value, _value + value);}
template<typename T> void operator -=(const T value) {Setter()(_value, _value - value);}
......@@ -154,46 +139,33 @@ private:
Type _value;
};
template<typename Type, class Setter, class Getter>
class _property<Type, Setter, Getter, false>
class InternalProperty<Type, Setter, Getter, false>
{
private:
typedef typename boost::call_traits<Type>::param_type Parameter;
typedef typename NSCallTraits<Type>::param_type Parameter;
public:
_property() {_setter(_value, Type());}
InternalProperty() {_setter(_value, Type());}
_property(const Setter& setter, const Getter& getter)
:
_setter(setter),
_getter(getter)
InternalProperty(const Setter& setter, const Getter& getter) : _setter(setter), _getter(getter)
{
_setter(_value, Type());
}
_property(Parameter value, const Setter& setter, const Getter& getter)
:
_value(value),
_setter(setter),
_getter(getter)
InternalProperty(Parameter value, const Setter& setter, const Getter& getter) : _value(value), _setter(setter), _getter(getter)
{
_setter(_value, value);
}
template<typename U, class S, class G>
_property(property<U, S, G> const& rhs, const Setter& setter, const Getter& getter)
:
_value(rhs.get()),
_setter(setter),
_getter(getter)
InternalProperty(property<U, S, G> const& rhs, const Setter& setter, const Getter& getter) : _value(rhs.get()), _setter(setter), _getter(getter)
{
_setter(_value, rhs.get());
}
void operator =(Parameter value) {_setter(_value, value);}
void operator =(const _property& rhs)
inline void operator =(Parameter value) {_setter(_value, value);}
inline void operator =(const InternalProperty& rhs)
{
if(this != &rhs)
{
......@@ -201,17 +173,17 @@ private:
}
return *this;
}
template<typename U, class S, class G> void operator =(const property<U, S, G> & rhs)
{
_setter(_value, rhs.get());
}
const Type get() const {return _getter(_value);}
Type& get() {return _value;}
Type const* const get_ptr() const {return &_value;}
Type* get_ptr() {return &_value;}
Type* get_ptr() {return &_value;}
template<typename T> void operator +=(const T value) {_setter(_value, _value + value);}
template<typename T> void operator -=(const T value) {_setter(_value, _value - value);}
......@@ -224,19 +196,15 @@ private:
template<typename T> const Type operator /(const T value) const {return _value / value;}
private:
Type _value;
Type _value;
Setter _setter;
Getter _getter;
};
private:
_property<Type, Setter, Getter,
boost::has_trivial_constructor<Setter>::value &&
boost::has_trivial_constructor<Getter>::value> _value;
InternalProperty<Type, Setter, Getter, true> _value;
};
template<class T, class S, class G> const bool operator ==(const T x, property<T, S, G> const& y) {return y == x;}
template<class T, class S, class G> const bool operator !=(const T x, property<T, S, G> const& y) {return y != x;}
template<class T, class S, class G> const bool operator < (const T x, property<T, S, G> const& y) {return y >= x;}
......
......@@ -32,7 +32,7 @@ namespace XML
public:
nullable_property<XNamespace> Ns;
property<std::string> Name;
property<std::string> Name;
};
const XName operator +(const XNamespace& ns, const std::string& name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment