diff options
Diffstat (limited to 'shared')
106 files changed, 5744 insertions, 3587 deletions
diff --git a/shared/FindFilePlus/FindFilePlus.vcxproj b/shared/FindFilePlus/FindFilePlus.vcxproj new file mode 100644 index 00000000..a49e99ba --- /dev/null +++ b/shared/FindFilePlus/FindFilePlus.vcxproj @@ -0,0 +1,245 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{70394AEF-5897-4911-AFA1-82EAF0581EFA}</ProjectGuid> + <RootNamespace>ShadowDll</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">FindFilePlus_$(Platform)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">FindFilePlus_$(Platform)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">FindFilePlus_$(Platform)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">FindFilePlus_$(Platform)</TargetName> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">D:\Data\WinDDK\inc\ddk;D:\Data\WinDDK\inc\api;D:\Data\WinDDK\inc\crt;$(WindowsSdkDir)\include;$(VCInstallDir)include</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">D:\Data\WinDDK\inc\ddk;D:\Data\WinDDK\inc\api;D:\Data\WinDDK\inc\crt;$(WindowsSdkDir)\include;$(VCInstallDir)include</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">D:\Data\WinDDK\inc\ddk;D:\Data\WinDDK\inc\api;D:\Data\WinDDK\inc\crt;$(WindowsSdkDir)\include;$(VCInstallDir)include</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">D:\Data\WinDDK\inc\ddk;D:\Data\WinDDK\inc\api;D:\Data\WinDDK\inc\crt;$(WindowsSdkDir)\include;$(VCInstallDir)include</IncludePath> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_X86_;_DEBUG;_WINDOWS;_USRDLL;FIND_FILE_PLUS_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <AdditionalIncludeDirectories>C:\Program Files\C++\Projects\FreeFileSync\shared</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_AMD64_;_DEBUG;_WINDOWS;_USRDLL;FIND_FILE_PLUS_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <AdditionalIncludeDirectories>C:\Program Files\C++\Projects\FreeFileSync\shared</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>_X86_;NDEBUG;_WINDOWS;_USRDLL;FIND_FILE_PLUS_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>C:\Program Files\C++\Projects\FreeFileSync\shared</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FIND_FILE_PLUS_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + <AdditionalIncludeDirectories>C:\Program Files\C++\Projects\FreeFileSync\shared</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="dll_main.cpp"> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged> + </ClCompile> + <ClCompile Include="find_file_plus.cpp" /> + <ClCompile Include="load_dll.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="find_file_plus.h" /> + <ClInclude Include="load_dll.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/shared/FindFilePlus/dll_main.cpp b/shared/FindFilePlus/dll_main.cpp new file mode 100644 index 00000000..3805c99d --- /dev/null +++ b/shared/FindFilePlus/dll_main.cpp @@ -0,0 +1,25 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +//optional: add init/teardown logic here +BOOL APIENTRY DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + case DLL_PROCESS_DETACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + } + return TRUE; +} diff --git a/shared/FindFilePlus/find_file_plus.cpp b/shared/FindFilePlus/find_file_plus.cpp new file mode 100644 index 00000000..8b29efa2 --- /dev/null +++ b/shared/FindFilePlus/find_file_plus.cpp @@ -0,0 +1,305 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#include "find_file_plus.h" +//#include <windows.h> //these two don't play nice with each other + +#include "load_dll.h" +#include <loki/ScopeGuard.h> + +using namespace dll; +using namespace findplus; + + +namespace +{ +//-------------------------------------------------------------------------------------------------------------- +typedef NTSTATUS (NTAPI* NtOpenFileFunc)(PHANDLE fileHandle, + ACCESS_MASK desiredAccess, + POBJECT_ATTRIBUTES objectAttributes, + PIO_STATUS_BLOCK ioStatusBlock, + ULONG shareAccess, + ULONG openOptions); + +typedef NTSTATUS (NTAPI* NtCloseFunc)(HANDLE handle); + +typedef NTSTATUS (NTAPI* NtQueryDirectoryFileFunc)(HANDLE fileHandle, + HANDLE event, + PIO_APC_ROUTINE apcRoutine, + PVOID apcContext, + PIO_STATUS_BLOCK ioStatusBlock, + PVOID fileInformation, + ULONG length, + FILE_INFORMATION_CLASS fileInformationClass, + BOOLEAN ReturnSingleEntry, + PUNICODE_STRING fileMask, + BOOLEAN restartScan); + +typedef ULONG (NTAPI* RtlNtStatusToDosErrorFunc)(NTSTATUS /*__in status*/); + +typedef struct _RTL_RELATIVE_NAME_U +{ + UNICODE_STRING RelativeName; + HANDLE ContainingDirectory; + PVOID /*PRTLP_CURDIR_REF*/ CurDirRef; +} RTL_RELATIVE_NAME_U, *PRTL_RELATIVE_NAME_U; + +typedef BOOLEAN (NTAPI* RtlDosPathNameToNtPathName_UFunc)(PCWSTR, //__in dosFileName, + PUNICODE_STRING, //__out ntFileName, + PCWSTR*, //__out_optFilePart, + PRTL_RELATIVE_NAME_U); //__out_opt relativeName + +typedef BOOLEAN (NTAPI* RtlDosPathNameToRelativeNtPathName_UFunc)(PCWSTR, //__in dosFileName, + PUNICODE_STRING, //__out ntFileName, + PWSTR*, //__out_optFilePart, + PRTL_RELATIVE_NAME_U); //__out_opt relativeName + +typedef VOID (NTAPI* RtlFreeUnicodeStringFunc)(PUNICODE_STRING); //__inout unicodeString + +//-------------------------------------------------------------------------------------------------------------- + +//it seems we cannot use any of the ntoskrnl.lib files in WinDDK as they produce access violations +//fortunately dynamic binding works fine: +NtOpenFileFunc ntOpenFile; +NtCloseFunc ntClose; +NtQueryDirectoryFileFunc ntQueryDirectoryFile; +RtlNtStatusToDosErrorFunc rtlNtStatusToDosError; +RtlFreeUnicodeStringFunc rtlFreeUnicodeString; +RtlDosPathNameToNtPathName_UFunc rtlDosPathNameToNtPathName_U; + + +template <class FunType> inline +void initDllFun(FunType& fun, const char* functionName) //throw FileError +{ + if (!fun) + { + fun = getSystemDllFun<FunType>(L"ntdll.dll", functionName); + if (!fun) + throw FileError(182); //== ERROR_INVALID_ORDINAL, verified at compile time in "load_dll.cpp"; we better not use rtlNtStatusToDosError(STATUS_ORDINAL_NOT_FOUND) here ;) + } +} + + +struct FileError +{ + FileError(ULONG errorCode) : win32Error(errorCode) {} + ULONG win32Error; +}; +} + +class findplus::FileSearcher +{ +public: + FileSearcher(const wchar_t* dirname); //throw FileError + ~FileSearcher(); + + void readdir(FileInformation& output); //throw FileError + +private: + UNICODE_STRING ntPathName; //it seems hDir implicitly keeps a reference to this, at least ::FindFirstFile() does no cleanup before ::FindClose()! + HANDLE hDir; + + ULONG nextEntryOffset; //!= 0 if entry is waiting in buffer + //::FindNextFileW() uses 0x1000 = 4096 = sizeof(FILE_BOTH_DIR_INFORMATION) + sizeof(TCHAR) * 2000 + //=> let's use the same, even if our header is 16 byte larger; maybe there is some packet size advantage for networks? Note that larger buffers seem to degrade performance. + static const ULONG BUFFER_SIZE = 4096; + LONGLONG buffer[BUFFER_SIZE / sizeof(LONGLONG)]; //buffer needs to be aligned at LONGLONG boundary + + static_assert(BUFFER_SIZE % sizeof(LONGLONG) == 0, "ups, our buffer is trimmed!"); +}; + + +FileSearcher::FileSearcher(const wchar_t* dirname) : + hDir(NULL), + nextEntryOffset(0) +{ + UNICODE_STRING cleanDummy = {}; + ntPathName = cleanDummy; + + Loki::ScopeGuard guardConstructor = Loki::MakeGuard([&]() { this->~FileSearcher(); }); + + //NT/ZwXxx Routines + //http://msdn.microsoft.com/en-us/library/ff567122(v=VS.85).aspx + + //Run-Time Library (RTL) Routines + //http://msdn.microsoft.com/en-us/library/ff563638(v=VS.85).aspx + + //init static dll functions + initDllFun(ntOpenFile, "NtOpenFile"); //throw FileError + initDllFun(ntClose, "NtClose"); + initDllFun(ntQueryDirectoryFile, "NtQueryDirectoryFile"); + initDllFun(rtlNtStatusToDosError, "RtlNtStatusToDosError"); + initDllFun(rtlFreeUnicodeString, "RtlFreeUnicodeString"); + try + { + initDllFun(rtlDosPathNameToNtPathName_U, "RtlDosPathNameToRelativeNtPathName_U"); //use the newer version if available + } + catch (const FileError&) + { + initDllFun(rtlDosPathNameToNtPathName_U, "RtlDosPathNameToNtPathName_U"); //fallback for XP + } + //-------------------------------------------------------------------------------------------------------------- + + //convert dosFileName, e.g. C:\Users or \\?\C:\Users to ntFileName \??\C:\Users + //in contrast to ::FindFirstFile() we don't evaluate the relativeName, however tests indicate ntFileName is *always* filled with an absolute name, even if dosFileName is relative + + //NOTE: RtlDosPathNameToNtPathName_U may be used on all XP/Win7/Win8 for compatibility + // RtlDosPathNameToNtPathName_U: used by Windows XP available with OS version 3.51 (Windows NT) and higher + // RtlDosPathNameToRelativeNtPathName_U: used by Win7/Win8 available with OS version 5.2 (Windows Server 2003) and higher + if (!rtlDosPathNameToNtPathName_U(dirname, //__in dosFileName, + &ntPathName, //__out ntFileName, + NULL, //__out_optFilePart, + NULL)) //__out_opt relativeName - empty if dosFileName is absolute + throw FileError(rtlNtStatusToDosError(STATUS_OBJECT_PATH_NOT_FOUND)); //translates to ERROR_PATH_NOT_FOUND, same behavior like ::FindFirstFileEx() + + OBJECT_ATTRIBUTES objAttr = {}; + InitializeObjectAttributes(&objAttr, //[out] POBJECT_ATTRIBUTES initializedAttributes, + &ntPathName, //[in] PUNICODE_STRING objectName, + OBJ_CASE_INSENSITIVE, //[in] ULONG attributes, + NULL, //[in] HANDLE rootDirectory, + NULL); //[in, optional] PSECURITY_DESCRIPTOR securityDescriptor + + { + IO_STATUS_BLOCK status = {}; + NTSTATUS rv = ntOpenFile(&hDir, //__out PHANDLE FileHandle, + FILE_LIST_DIRECTORY | SYNCHRONIZE, //__in ACCESS_MASK desiredAccess, - 100001 used by ::FindFirstFile() on all XP/Win7/Win8 + &objAttr, //__in POBJECT_ATTRIBUTES objectAttributes, + &status, //__out PIO_STATUS_BLOCK ioStatusBlock, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //__in ULONG shareAccess, - 7 on Win7/Win8, 3 on XP + FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_BACKUP_INTENT); //__in ULONG openOptions - 4021 used on all XP/Win7/Win8 + if (!NT_SUCCESS(rv)) + throw FileError(rtlNtStatusToDosError(rv)); + } + + guardConstructor.Dismiss(); +} + + +FileSearcher::~FileSearcher() +{ + //cleanup in reverse order + if (hDir) + ntClose(hDir); + + if (ntPathName.Buffer) + rtlFreeUnicodeString(&ntPathName); //cleanup identical to ::FindFirstFile() + //note that most if this function seems inlined by the linker, so that its assembly looks equivalent to "RtlFreeHeap(GetProcessHeap(), 0, ntPathName.Buffer)" +} + + +void FileSearcher::readdir(FileInformation& output) +{ + //although FILE_ID_FULL_DIR_INFORMATION should suffice for our purposes, there are problems on Windows XP for certain directories, e.g. "\\Vboxsvr\build" + //making NtQueryDirectoryFile() return with STATUS_INVALID_PARAMETER while other directories, e.g. "C:\" work fine for some reason + //FILE_ID_BOTH_DIR_INFORMATION on the other hand works on XP/Win7/Win8 + //performance: there is no noticable difference between FILE_ID_BOTH_DIR_INFORMATION and FILE_ID_FULL_DIR_INFORMATION + + /* corresponding first access in ::FindFirstFileW() + + NTSTATUS rv = ntQueryDirectoryFile(hDir, //__in HANDLE fileHandle, + NULL, //__in_opt HANDLE event, + NULL, //__in_opt PIO_APC_ROUTINE apcRoutine, + NULL, //__in_opt PVOID apcContext, + &status, //__out PIO_STATUS_BLOCK ioStatusBlock, + &buffer, //__out_bcount(Length) PVOID fileInformation, + BUFFER_SIZE, //__in ULONG length, ::FindFirstFileW() on all XP/Win7/Win8 uses sizeof(FILE_BOTH_DIR_INFORMATION) + sizeof(TCHAR) * MAX_PATH == 0x268 + FileIdBothDirectoryInformation, //__in FILE_INFORMATION_CLASS fileInformationClass - all XP/Win7/Win8 use "FileBothDirectoryInformation" + true, //__in BOOLEAN returnSingleEntry, + NULL, //__in_opt PUNICODE_STRING mask, + false); //__in BOOLEAN restartScan + */ + + //analog to ::FindNextFileW() with performance optimized access (in contrast to first access in ::FindFirstFileW()) + if (nextEntryOffset == 0) + { + IO_STATUS_BLOCK status = {}; + NTSTATUS rv = ntQueryDirectoryFile(hDir, //__in HANDLE fileHandle, + NULL, //__in_opt HANDLE event, + NULL, //__in_opt PIO_APC_ROUTINE apcRoutine, + NULL, //__in_opt PVOID apcContext, + &status, //__out PIO_STATUS_BLOCK ioStatusBlock, + &buffer, //__out_bcount(Length) PVOID fileInformation, + BUFFER_SIZE, //__in ULONG length, ::FindNextFileW() on all XP/Win7/Win8 uses sizeof(FILE_BOTH_DIR_INFORMATION) + sizeof(TCHAR) * 2000 == 0x1000 + FileIdBothDirectoryInformation, //__in FILE_INFORMATION_CLASS fileInformationClass - all XP/Win7/Win8 use "FileBothDirectoryInformation" + false, //__in BOOLEAN returnSingleEntry, + NULL, //__in_opt PUNICODE_STRING mask, + false); //__in BOOLEAN restartScan + if (!NT_SUCCESS(rv)) + throw FileError(rtlNtStatusToDosError(rv)); //throws STATUS_NO_MORE_FILES when finished + + if (status.Information == 0) //except for the first call to call ::NtQueryDirectoryFile(): + throw FileError(rtlNtStatusToDosError(STATUS_BUFFER_OVERFLOW)); //if buffer size is too small, return value is STATUS_SUCCESS and Information == 0 -> we don't expect this! + } + + const FILE_ID_BOTH_DIR_INFORMATION& dirInfo = *reinterpret_cast<FILE_ID_BOTH_DIR_INFORMATION*>(reinterpret_cast<char*>(buffer) + nextEntryOffset); + + if (dirInfo.NextEntryOffset == 0) + nextEntryOffset = 0; //our offset is relative to the beginning of the buffer + else + nextEntryOffset += dirInfo.NextEntryOffset; + + + auto toFileTime = [](const LARGE_INTEGER & rawTime) -> FILETIME + { + FILETIME tmp = { rawTime.LowPart, rawTime.HighPart }; + return tmp; + }; + + output.creationTime = toFileTime(dirInfo.CreationTime); + output.lastWriteTime = toFileTime(dirInfo.LastWriteTime); + output.fileSize.QuadPart = dirInfo.EndOfFile.QuadPart; + output.fileId.QuadPart = dirInfo.FileId.QuadPart; + output.fileAttributes = dirInfo.FileAttributes; + output.shortNameLength = dirInfo.FileNameLength / sizeof(TCHAR); //FileNameLength is in bytes! + + if (dirInfo.FileNameLength + sizeof(TCHAR) > sizeof(output.shortName)) //this may actually happen if ::NtQueryDirectoryFile() decides to return a + throw FileError(rtlNtStatusToDosError(STATUS_BUFFER_OVERFLOW)); //short name of length MAX_PATH + 1, 0-termination is not required! + + ::memcpy(output.shortName, dirInfo.FileName, dirInfo.FileNameLength); + output.shortName[output.shortNameLength] = 0; //NOTE: FILE_ID_BOTH_DIR_INFORMATION::FileName in general is NOT 0-terminated! It is on XP/Win7, but NOT on Win8! + + static_assert(sizeof(output.creationTime) == sizeof(dirInfo.CreationTime), "dang!"); + static_assert(sizeof(output.lastWriteTime) == sizeof(dirInfo.LastWriteTime), "dang!"); + static_assert(sizeof(output.fileSize) == sizeof(dirInfo.EndOfFile), "dang!"); + static_assert(sizeof(output.fileId) == sizeof(dirInfo.FileId), "dang!"); + static_assert(sizeof(output.fileAttributes) == sizeof(dirInfo.FileAttributes), "dang!"); +} + + +FindHandle findplus::openDir(const wchar_t* dirname) +{ + try + { + return new FileSearcher(dirname); //throw FileError + } + catch (const FileError& err) + { + setWin32Error(err.win32Error); + return NULL; + } +} + + +bool findplus::readDir(FindHandle hnd, FileInformation& output) +{ + try + { + hnd->readdir(output); //throw FileError + return true; + } + catch (const FileError& err) + { + setWin32Error(err.win32Error); + return false; + } +} + + +void findplus::closeDir(FindHandle hnd) +{ + if (hnd) //play a little "nice" + delete static_cast<FileSearcher*>(hnd); +} diff --git a/shared/FindFilePlus/find_file_plus.h b/shared/FindFilePlus/find_file_plus.h new file mode 100644 index 00000000..88cb13af --- /dev/null +++ b/shared/FindFilePlus/find_file_plus.h @@ -0,0 +1,78 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef FIND_FIRST_FILE_PLUS_HEADER_087483434 +#define FIND_FIRST_FILE_PLUS_HEADER_087483434 + +#ifdef FIND_FILE_PLUS_DLL_EXPORTS +#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport) +#else +#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport) +#endif + + +#ifdef FIND_FILE_PLUS_DLL_EXPORTS +#include <Ntifs.h> //driver level headers must be included *before* windows api headers! +#endif +#include <windef.h> // +#undef min +#undef max + +#include "../build_info.h" + +namespace findplus +{ +/*-------------- + |declarations| + --------------*/ + +struct FileInformation +{ + FILETIME creationTime; + FILETIME lastWriteTime; + ULARGE_INTEGER fileSize; + ULARGE_INTEGER fileId; + DWORD fileAttributes; + DWORD shortNameLength; + WCHAR shortName[MAX_PATH + 1]; //shortName is 0-terminated +}; + +class FileSearcher; +typedef FileSearcher* FindHandle; + +DLL_FUNCTION_DECLARATION +FindHandle openDir(const wchar_t* dirname); //returns NULL on error, call ::GetLastError(); returns ERROR_INVALID_ORDINAL if ntdll-libraries could not be loaded +//note do NOT place an asterisk at end, e.g. C:\SomeDir\*, as one would do for ::FindFirstFile() + +DLL_FUNCTION_DECLARATION +bool readDir(FindHandle hnd, FileInformation& output); //returns false on error or if there are no more files; ::GetLastError() returns ERROR_NO_MORE_FILES + +DLL_FUNCTION_DECLARATION +void closeDir(FindHandle hnd); + +/*---------- + |typedefs| + ----------*/ +typedef FindHandle (*OpenDirFunc )(const wchar_t* dirname); +typedef bool (*ReadDirFunc )(FindHandle hnd, FileInformation& dirInfo); +typedef void (*CloseDirFunc)(FindHandle hnd); + +/*-------------- + |symbol names| + --------------*/ +//const pointers ensure internal linkage +const char openDirFuncName [] = "openDir"; +const char readDirFuncName [] = "readDir"; +const char closeDirFuncName[] = "closeDir"; + +/*--------------- + |library names| + ---------------*/ +inline const wchar_t* getDllName() { return util::is64BitBuild ? L"FindFilePlus_x64.dll" : L"FindFilePlus_Win32.dll"; } +} + + +#endif //FIND_FIRST_FILE_PLUS_HEADER_087483434 diff --git a/shared/FindFilePlus/load_dll.cpp b/shared/FindFilePlus/load_dll.cpp new file mode 100644 index 00000000..51ec1f0c --- /dev/null +++ b/shared/FindFilePlus/load_dll.cpp @@ -0,0 +1,25 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> // yes, this sequence is mad, but ddk and api headers contain plenty of redefinitions +#include "load_dll.h" // + +void* /*FARPROC*/ dll::loadSymbol(const wchar_t* libraryName, const char* functionName) +{ + return ::GetProcAddress(::GetModuleHandle(libraryName), functionName); + //cleanup neither required nor allowed (::FreeLibrary()) + +} +//note: void* and FARPROC function pointer have same binary size on Windows + + +void dll::setWin32Error(unsigned long lastError) +{ + ::SetLastError(lastError); +} + +static_assert(ERROR_INVALID_ORDINAL == 182, "dang!");
\ No newline at end of file diff --git a/shared/FindFilePlus/load_dll.h b/shared/FindFilePlus/load_dll.h new file mode 100644 index 00000000..f152dd74 --- /dev/null +++ b/shared/FindFilePlus/load_dll.h @@ -0,0 +1,39 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef LOAD_DLL_HEADER_0312463214872163832174 +#define LOAD_DLL_HEADER_0312463214872163832174 + +namespace dll +{ +template <typename FunctionType> +FunctionType getSystemDllFun(const wchar_t* libraryName, const char* functionName); //NOTE: uses ::GetModuleHandle => call for system DLLs only! + +void setWin32Error(unsigned long lastError); + + + + + + + + + + + + + +void* /*FARPROC*/ loadSymbol(const wchar_t* libraryName, const char* functionName); + +template <typename FunctionType> inline +FunctionType getSystemDllFun(const wchar_t* libraryName, const char* functionName) +{ + return reinterpret_cast<FunctionType>(loadSymbol(libraryName, functionName)); +} +} + +#endif //LOAD_DLL_HEADER_0312463214872163832174 + diff --git a/shared/IFileOperation/FileOperation_Vista.vcxproj b/shared/IFileOperation/FileOperation_Vista.vcxproj index 9f9a9c28..5de402f4 100644 --- a/shared/IFileOperation/FileOperation_Vista.vcxproj +++ b/shared/IFileOperation/FileOperation_Vista.vcxproj @@ -29,10 +29,12 @@ <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -63,10 +65,10 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir> diff --git a/shared/IFileOperation/file_op.cpp b/shared/IFileOperation/file_op.cpp index a2cf9413..8b632972 100644 --- a/shared/IFileOperation/file_op.cpp +++ b/shared/IFileOperation/file_op.cpp @@ -61,13 +61,15 @@ bool fileop::moveToRecycleBin(const wchar_t* fileNames[], return false; } + int operationCount = 0; + for (size_t i = 0; i < fileNo; ++i) { //create file/folder item object ComPtr<IShellItem> psiFile; - hr = SHCreateItemFromParsingName(fileNames[i], - NULL, - IID_PPV_ARGS(psiFile.init())); + hr = ::SHCreateItemFromParsingName(fileNames[i], + NULL, + IID_PPV_ARGS(psiFile.init())); if (FAILED(hr)) { if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) || //file not existing anymore @@ -87,8 +89,13 @@ bool fileop::moveToRecycleBin(const wchar_t* fileNames[], lastErrorMessage = generateErrorMsg(L"Error calling \"DeleteItem\".", hr); return false; } + + ++operationCount; } + if (operationCount == 0) //calling PerformOperations() without anything to do results in E_UNEXPECTED + return true; + //perform actual operations hr = fileOp->PerformOperations(); if (FAILED(hr)) diff --git a/shared/IFileOperation/file_op.h b/shared/IFileOperation/file_op.h index c1bb26a2..dbe00196 100644 --- a/shared/IFileOperation/file_op.h +++ b/shared/IFileOperation/file_op.h @@ -13,6 +13,8 @@ #define FILE_OP_DLL_API extern "C" __declspec(dllimport) #endif +#include "../build_info.h" + namespace fileop { @@ -48,6 +50,11 @@ typedef void (*GetLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen); const char moveToRecycleBinFctName[] = "moveToRecycleBin"; const char copyFileFctName[] = "copyFile"; const char getLastErrorFctName[] = "getLastError"; + +/*--------------- + |library names| + ---------------*/ +inline const wchar_t* getDllName() { return util::is64BitBuild ? L"FileOperation_x64.dll" : L"FileOperation_Win32.dll"; } } diff --git a/shared/ShadowCopy/Shadow_2003.vcxproj b/shared/ShadowCopy/Shadow_2003.vcxproj index 5351cc1d..710b65bf 100644 --- a/shared/ShadowCopy/Shadow_2003.vcxproj +++ b/shared/ShadowCopy/Shadow_2003.vcxproj @@ -30,10 +30,12 @@ <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> <UseOfAtl>false</UseOfAtl> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -64,10 +66,10 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir> diff --git a/shared/ShadowCopy/Shadow_XP.vcxproj b/shared/ShadowCopy/Shadow_XP.vcxproj index d096297a..6211afd5 100644 --- a/shared/ShadowCopy/Shadow_XP.vcxproj +++ b/shared/ShadowCopy/Shadow_XP.vcxproj @@ -29,10 +29,12 @@ <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -63,10 +65,10 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir> diff --git a/shared/ShadowCopy/shadow.h b/shared/ShadowCopy/shadow.h index b21395da..8721b906 100644 --- a/shared/ShadowCopy/shadow.h +++ b/shared/ShadowCopy/shadow.h @@ -13,6 +13,8 @@ #define SHADOWDLL_API extern "C" __declspec(dllimport) #endif +#include "../build_info.h" + namespace shadow { @@ -60,6 +62,43 @@ typedef void (*ReleaseShadowCopyFct)(ShadowHandle handle); //(use const pointers to ensure internal linkage) const char createShadowCopyFctName[] = "createShadowCopy"; const char releaseShadowCopyFctName[] = "releaseShadowCopy"; + +/*--------------- + |library names| + ---------------*/ +namespace impl +{ +bool newerThanXP() +{ + OSVERSIONINFO osvi = {}; + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + if (::GetVersionEx(&osvi)) + return osvi.dwMajorVersion > 5 || + (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion > 1) ; + //XP has majorVersion == 5, minorVersion == 1 + //Server 2003 has majorVersion == 5, minorVersion == 2 + //version overview: http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx + return false; +} +} + +inline +const wchar_t* getDllName() +{ + /* + distinguish a bunch of VSS builds: we use XP and Server 2003 implementations... + VSS version and compatibility overview: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx + */ + return impl::newerThanXP() ? + (util::is64BitBuild ? + L"Shadow_Server2003_x64.dll" : + L"Shadow_Server2003_Win32.dll") : + + (util::is64BitBuild ? + L"Shadow_XP_x64.dll" : + L"Shadow_XP_Win32.dll"); +} } diff --git a/shared/Taskbar_Seven/Taskbar_Seven.vcxproj b/shared/Taskbar_Seven/Taskbar_Seven.vcxproj index 5b04a98c..8437bc09 100644 --- a/shared/Taskbar_Seven/Taskbar_Seven.vcxproj +++ b/shared/Taskbar_Seven/Taskbar_Seven.vcxproj @@ -32,6 +32,7 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> @@ -62,10 +63,10 @@ <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</OutDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir> diff --git a/shared/Taskbar_Seven/taskbar.cpp b/shared/Taskbar_Seven/taskbar.cpp index bbbaaf7d..2a739e6c 100644 --- a/shared/Taskbar_Seven/taskbar.cpp +++ b/shared/Taskbar_Seven/taskbar.cpp @@ -30,10 +30,10 @@ ComPtr<ITaskbarList3> getInstance() static ComPtr<ITaskbarList3> taskbarlist; if (!taskbarlist) { - HRESULT hr = CoCreateInstance(CLSID_TaskbarList, - NULL, - CLSCTX_ALL, - IID_PPV_ARGS(taskbarlist.init())); + HRESULT hr = ::CoCreateInstance(CLSID_TaskbarList, + NULL, + CLSCTX_ALL, + IID_PPV_ARGS(taskbarlist.init())); if (FAILED(hr)) lastErrorMessage = generateErrorMsg(L"Error calling \"CoCreateInstance\".", hr); } diff --git a/shared/Taskbar_Seven/taskbar.h b/shared/Taskbar_Seven/taskbar.h index 3bae28a9..507920c7 100644 --- a/shared/Taskbar_Seven/taskbar.h +++ b/shared/Taskbar_Seven/taskbar.h @@ -13,6 +13,8 @@ #define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport) #endif +#include "../build_info.h" + namespace tbseven { @@ -60,6 +62,11 @@ typedef void (*GetLastErrorFct)(wchar_t* errorMessage, size_t errorBufferLen); const char setStatusFctName[] = "setStatus"; const char setProgressFctName[] = "setProgress"; const char getLastErrorFctName[] = "getLastError"; + +/*--------------- + |library names| + ---------------*/ +inline const wchar_t* getDllName() { return util::is64BitBuild ? L"Taskbar7_x64.dll" : L"Taskbar7_Win32.dll"; } } #endif //TASKBAR_SEVEN_DLL_H diff --git a/shared/Thumbnail/Thumbnail.vcxproj b/shared/Thumbnail/Thumbnail.vcxproj new file mode 100644 index 00000000..05196e0a --- /dev/null +++ b/shared/Thumbnail/Thumbnail.vcxproj @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{70394AEF-5897-4911-AFA1-82EAF0581EFA}</ProjectGuid> + <RootNamespace>ShadowDll</RootNamespace> + <Keyword>Win32Proj</Keyword> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <WholeProgramOptimization>true</WholeProgramOptimization> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>Windows7.1SDK</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Thumbnail_$(Platform)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Thumbnail_$(Platform)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Thumbnail_$(Platform)</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Thumbnail_$(Platform)</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX86</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <BuildLog> + <Path>$(IntDir)Build.html</Path> + </BuildLog> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + </Midl> + <ClCompile> + <Optimization>MaxSpeed</Optimization> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> + </ClCompile> + <Link> + <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <GenerateDebugInformation>false</GenerateDebugInformation> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> + <ProfileGuidedDatabase> + </ProfileGuidedDatabase> + <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="dll_main.cpp"> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + </PrecompiledHeader> + <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged> + </ClCompile> + <ClCompile Include="thumbnail.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="thumbnail.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/shared/Thumbnail/dll_main.cpp b/shared/Thumbnail/dll_main.cpp new file mode 100644 index 00000000..3805c99d --- /dev/null +++ b/shared/Thumbnail/dll_main.cpp @@ -0,0 +1,25 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +//optional: add init/teardown logic here +BOOL APIENTRY DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + case DLL_PROCESS_DETACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + } + return TRUE; +} diff --git a/shared/Thumbnail/thumbnail.cpp b/shared/Thumbnail/thumbnail.cpp new file mode 100644 index 00000000..51635ff9 --- /dev/null +++ b/shared/Thumbnail/thumbnail.cpp @@ -0,0 +1,167 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#include "thumbnail.h" + +#define WIN32_LEAN_AND_MEAN +#include "windows.h" + +#define STRICT_TYPED_ITEMIDS //better type safety for IDLists +#include <Shlobj.h> + +#include <Shellapi.h> +#include <CommonControls.h> +#include "../com_ptr.h" +#include "../string_tools.h" +#include "../loki/ScopeGuard.h" +//#include "../perf.h" + +using namespace zen; + + +thumb::HICON thumb::getThumbnail(const wchar_t* filename, int requestedSize) //return 0 on failure, caller takes ownership! +{ + const std::wstring filenameStr(filename); + + util::ComPtr<IShellFolder> shellFolder; + { + HRESULT hr = ::SHGetDesktopFolder(shellFolder.init()); + if (FAILED(hr) || !shellFolder) + return NULL; + } + + PIDLIST_RELATIVE pidlFolder = NULL; + { + const std::wstring pathName = beforeLast(filenameStr, '\\'); + HRESULT hr = shellFolder->ParseDisplayName(NULL, // [in] HWND hwnd, + NULL, // [in] IBindCtx *pbc, + const_cast<LPWSTR>(pathName.c_str()), // [in] LPWSTR pszDisplayName, + NULL, // [out] ULONG *pchEaten, + &pidlFolder, // [out] PIDLIST_RELATIVE* ppidl, + NULL); // [in, out] ULONG *pdwAttributes + if (FAILED(hr) || !pidlFolder) + return NULL; + } + LOKI_ON_BLOCK_EXIT2(::ILFree(pidlFolder)); //older version: ::CoTaskMemFree + + util::ComPtr<IShellFolder> imageFolder; + { + HRESULT hr = shellFolder->BindToObject(pidlFolder, // [in] PCUIDLIST_RELATIVE pidl, + NULL, + IID_PPV_ARGS(imageFolder.init())); + if (FAILED(hr) || !imageFolder) + return NULL; + } + + PIDLIST_RELATIVE pidImage = NULL; + { + const std::wstring shortName = afterLast(filenameStr, '\\'); + HRESULT hr = imageFolder->ParseDisplayName(NULL, // [in] HWND hwnd, + NULL, // [in] IBindCtx *pbc, + const_cast<LPWSTR>(shortName.c_str()), // [in] LPWSTR pszDisplayName, + NULL, // [out] ULONG *pchEaten, + &pidImage, // [out] PIDLIST_RELATIVE *ppidl, + NULL); // [in, out] ULONG *pdwAttributes + if (FAILED(hr) || !pidImage) + return NULL; + } + LOKI_ON_BLOCK_EXIT2(::ILFree(pidImage)); //older version: ::CoTaskMemFree + + util::ComPtr<IExtractImage> extractImage; + { + PCUITEMID_CHILD_ARRAY pidlIn = reinterpret_cast<PCUITEMID_CHILD_ARRAY>(&pidImage); + //this is where STRICT_TYPED_ITEMIDS gets us ;) + + HRESULT hr = imageFolder->GetUIObjectOf(NULL, // [in] HWND hwndOwner, + 1, // [in] UINT cidl, + pidlIn, // [in] PCUITEMID_CHILD_ARRAY apidl, + IID_IExtractImage, // [in] REFIID riid, + NULL, // [in, out] UINT *rgfReserved, + reinterpret_cast<void**>(extractImage.init())); // [out] void **ppv + if (FAILED(hr) || !extractImage) + return NULL; + } + + { + wchar_t pathBuffer[MAX_PATH]; + DWORD priority = 0; + const SIZE prgSize = { requestedSize, requestedSize }; //preferred size only! + DWORD clrDepth = 32; + DWORD flags = IEIFLAG_SCREEN | IEIFLAG_OFFLINE; + + HRESULT hr = extractImage->GetLocation(pathBuffer, // [out] LPWSTR pszPathBuffer, + MAX_PATH, // [in] DWORD cchMax, + &priority, // [out] DWORD *pdwPriority, + &prgSize, // [in] const SIZE *prgSize, + clrDepth, // [in] DWORD dwRecClrDepth, + &flags); // [in, out] DWORD *pdwFlags + if (FAILED(hr)) + return NULL; + } + + HBITMAP bitmap = NULL; + { + HRESULT hr = extractImage->Extract(&bitmap); + if (FAILED(hr) || !bitmap) + return NULL; + } + LOKI_ON_BLOCK_EXIT2(::DeleteObject(bitmap)); + + + BITMAP bmpInfo = {}; + if (::GetObject(bitmap, //__in HGDIOBJ hgdiobj, + sizeof(bmpInfo), //__in int cbBuffer, + &bmpInfo) == 0) //__out LPVOID lpvObject + return NULL; + + HBITMAP bitmapMask = ::CreateCompatibleBitmap(::GetDC(NULL), bmpInfo.bmWidth, bmpInfo.bmHeight); + if (bitmapMask == 0) + return NULL; + LOKI_ON_BLOCK_EXIT2(::DeleteObject(bitmapMask)); + + ICONINFO iconInfo = {}; + iconInfo.fIcon = true; + iconInfo.hbmColor = bitmap; + iconInfo.hbmMask = bitmapMask; + + return ::CreateIconIndirect(&iconInfo); +} + + +thumb::HICON thumb::getIconByIndex(int iconIndex, int shilIconType) //return 0 on failure, caller takes ownership! +{ + //Note: using IExtractIcon::Extract is *no* alternative, just as ::SHGetFileInfo(), it only supports small (16x16) and large (32x32) icons + + util::ComPtr<IImageList> imageList; //perf: 0,12 µs only to get the image list + { + HRESULT hr = ::SHGetImageList(shilIconType, //__in int iImageList, + IID_PPV_ARGS(imageList.init())); + if (FAILED(hr) || !imageList) + return NULL; + } + + bool hasAlpha = false; //perf: 0,14 µs + { + DWORD flags = 0; + HRESULT hr = imageList->GetItemFlags(iconIndex, //[in] int i, + &flags); //[out] DWORD *dwFlags + if (SUCCEEDED(hr)) + hasAlpha = flags & ILIF_ALPHA; + } + + ::HICON hIcon = NULL; //perf: 1,5 ms - the dominant block + { + HRESULT hr = imageList->GetIcon(iconIndex, // [in] int i, + hasAlpha ? ILD_IMAGE : ILD_NORMAL, // [in] UINT flags, + //ILD_IMAGE -> do not draw mask - fixes glitch with ILD_NORMAL where both mask *and* alpha channel are applied, e.g. for ffs_batch and folder icon + //other flags: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775230(v=vs.85).aspx + &hIcon); // [out] HICON *picon + if (FAILED(hr) || !hIcon) + return NULL; + } + + return hIcon; +}
\ No newline at end of file diff --git a/shared/Thumbnail/thumbnail.h b/shared/Thumbnail/thumbnail.h new file mode 100644 index 00000000..ae62cf5d --- /dev/null +++ b/shared/Thumbnail/thumbnail.h @@ -0,0 +1,68 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef TASKBAR_SEVEN_DLL_H +#define TASKBAR_SEVEN_DLL_H + +#ifdef THUMBNAIL_DLL_EXPORTS +#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport) +#else +#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport) +#endif + +#include "../build_info.h" +//#include <WinDef.h> + +namespace thumb +{ +/* +PREREQUISITES: + +1. COM must be initialized for the current thread via ::CoInitialize(NULL) or ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED), + but NOT ::CoInitializeEx(NULL, COINIT_MULTITHREADED) -> internal access violation crash! +2. call ::FileIconInit() on app start to remedy obscure errors like SHELL_E_WRONG_BITDEPTH (0x80270102) + for certain file types, e.g. lnk, mpg - required on Windows 7 see http://msdn.microsoft.com/en-us/library/ms683212(v=VS.85).aspx +*/ + +/*-------------- + |declarations| + --------------*/ +typedef void* HICON; + +DLL_FUNCTION_DECLARATION +HICON getThumbnail(const wchar_t* filename, int requestedSize); //return 0 on failure, caller takes ownership! +//Note: not all file types support thumbnails! make sure to implement fallback to file icon! + +DLL_FUNCTION_DECLARATION +HICON getIconByIndex(int iconIndex, int shilIconType); //return 0 on failure, caller takes ownership! +/* +"iconType" refers to parameter "iImageList" of ::SHGetImageList(); sample values: + SHIL_SMALL - 16x16, but the size can be customized by the user. + SHIL_EXTRALARGE - 48x48, but the size can be customized by the user. + SHIL_JUMBO - Vista and later; normally 256x256 pixels +"iconIndex" as returned by ::SHGetFileInfo() +*/ + +/*---------- + |typedefs| + ----------*/ +typedef HICON (*GetThumbnailFct )(const wchar_t* filename, int requestedSize); +typedef HICON (*GetIconByIndexFct)(int iconIndex, int shilIconType); + +/*-------------- + |symbol names| + --------------*/ +//(use const pointers to ensure internal linkage) +const char getThumbnailFctName [] = "getThumbnail"; +const char getIconByIndexFctName [] = "getIconByIndex"; + +/*--------------- + |library names| + ---------------*/ +inline const wchar_t* getDllName() { return util::is64BitBuild ? L"Thumbnail_x64.dll" : L"Thumbnail_Win32.dll"; } +} + +#endif //TASKBAR_SEVEN_DLL_H diff --git a/shared/check_exist.h b/shared/check_exist.h index 14a8a3f8..8078d388 100644 --- a/shared/check_exist.h +++ b/shared/check_exist.h @@ -48,7 +48,7 @@ boost::unique_future<bool> objExistsAsync(const Zstring& objname) { //thread safety: make it a pure value type for use in the thread! const Zstring objnameVal = objname; //atomic ref-count => binary value-type semantics! - boost::packaged_task<bool> pt([=] { return (*fun)(objnameVal); }); + boost::packaged_task<bool> pt([ = ] { return (*fun)(objnameVal); }); auto fut = pt.get_future(); boost::thread(std::move(pt)); return std::move(fut); diff --git a/shared/com_error.h b/shared/com_error.h index 39f26555..e3d51d4b 100644 --- a/shared/com_error.h +++ b/shared/com_error.h @@ -9,31 +9,22 @@ #include <string> #include <cstdio> -#include <comdef.h> +#include <windows.h> +#undef min +#undef max namespace util { std::wstring generateErrorMsg(const std::wstring& input, HRESULT hr); +std::wstring formatWin32Msg(DWORD dwMessageId); //return empty string on error + + + -class ComException -{ -public: - ComException(const std::wstring& message, HRESULT hr = NO_ERROR) - : message_(message), hr_(hr) {} - std::wstring show() const - { - return hr_ != NO_ERROR ? generateErrorMsg(message_, hr_) : message_; - } -private: - ComException(const ComException&); - ComException& operator=(const ComException&); - const std::wstring message_; - const HRESULT hr_; -}; @@ -56,6 +47,144 @@ private: //################# implementation ##################### +std::wstring formatWin32Msg(DWORD dwMessageId) //return empty string on error +{ + std::wstring output; + LPWSTR buffer = NULL; + if (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_MAX_WIDTH_MASK | + FORMAT_MESSAGE_IGNORE_INSERTS | //important: without this flag ::FormatMessage() will fail if message contains placeholders + FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwMessageId, 0, reinterpret_cast<LPWSTR>(&buffer), 0, NULL) != 0) + { + if (buffer) //just to be sure + { + output = buffer; + ::LocalFree(buffer); + } + } + return output; +} + +namespace +{ +std::wstring formatFacility(HRESULT hr) +{ + switch (HRESULT_FACILITY(hr)) + { + case FACILITY_XPS: + return L"XPS"; + case FACILITY_WINRM: + return L"Windows Resource Manager"; + case FACILITY_WINDOWSUPDATE: + return L"Windows Update"; + case FACILITY_WINDOWS_DEFENDER: + return L"Windows Defender Component"; + case FACILITY_WINDOWS_CE: + return L"Windows CE"; + case FACILITY_WINDOWS: + return L"Windows Subsystem"; + case FACILITY_USERMODE_VOLMGR: + return L"User Mode Volume Manager"; + case FACILITY_USERMODE_VIRTUALIZATION: + return L"User Mode Virtualization Subsystem"; + case FACILITY_USERMODE_VHD: + return L"User Mode Virtual Hard Disk Support"; + case FACILITY_URT: + return L".NET CLR"; + case FACILITY_UMI: + return L"Ubiquitous Memoryintrospection Service"; + case FACILITY_UI: + return L"UI"; + case FACILITY_TPM_SOFTWARE: + return L"Trusted Platform Module Applications"; + case FACILITY_TPM_SERVICES: + return L"Trusted Platform Module Services"; + case FACILITY_SXS: + return L"Side-by-side Servicing"; + case FACILITY_STORAGE: + return L"OLE Storage"; + case FACILITY_STATE_MANAGEMENT: + return L"State Management Services"; + case FACILITY_SCARD: + return L"Smart-card Subsystem"; + case FACILITY_SHELL: + return L"User Shell"; + case FACILITY_SETUPAPI: + return L"Setup API"; + case FACILITY_SECURITY: + return L"Security API Layer"; + case FACILITY_SDIAG: + return L"System Diagnostics"; + case FACILITY_RPC: + return L"RPC Subsystem"; + case FACILITY_RAS: + return L"RAS"; + case FACILITY_PLA: + return L"Performance Logs and Alerts"; + case FACILITY_OPC: + return L"Open Connectivity Service"; + case FACILITY_WIN32: + return L"Win32"; + case FACILITY_CONTROL: + return L"Control Mechanism"; + case FACILITY_WEBSERVICES: + return L"Web Services"; + case FACILITY_NDIS: + return L"Network Driver Interface"; + case FACILITY_METADIRECTORY: + return L"Microsoft Identity Server"; + case FACILITY_MSMQ: + return L"Microsoft Message Queue"; + case FACILITY_MEDIASERVER: + return L"Windows Media Server"; + case FACILITY_MBN: + return L"MBN"; + case FACILITY_INTERNET: + return L"Wininet"; + case FACILITY_ITF: + return L"COM/OLE Interface Management"; + case FACILITY_USERMODE_HYPERVISOR: + return L"Usermode Hypervisor Components"; + case FACILITY_HTTP: + return L"HTTP Support"; + case FACILITY_GRAPHICS: + return L"Graphics Drivers"; + case FACILITY_FWP: + return L"Firewall Platform"; + case FACILITY_FVE: + return L"Full volume encryption"; + case FACILITY_USERMODE_FILTER_MANAGER: + return L"User Mode Filter Manager"; + case FACILITY_DPLAY: + return L"Direct Play"; + case FACILITY_DISPATCH: + return L"COM Dispatch"; + case FACILITY_DIRECTORYSERVICE: + return L"Active Directory"; + case FACILITY_CONFIGURATION: + return L"Configuration Services"; + case FACILITY_COMPLUS: + return L"COM+"; + case FACILITY_USERMODE_COMMONLOG: + return L"Common Logging Support"; + case FACILITY_CMI: + return L"Configuration Management Infrastructure"; + case FACILITY_CERT: + return L"Certificate"; + case FACILITY_BCD: + return L"Boot Configuration Database"; + case FACILITY_BACKGROUNDCOPY: + return L"Background Copy Control"; + case FACILITY_ACS: + return L"Audit Collection Service"; + case FACILITY_AAF: + return L"Microsoft Agent"; + default: + return L"Unknown"; + } +} +} + inline std::wstring numberToHexString(long number) { @@ -69,11 +198,18 @@ inline std::wstring generateErrorMsg(const std::wstring& input, HRESULT hr) { std::wstring output(input); - output += L" ("; - output += numberToHexString(hr); - output += L": "; - output += _com_error(hr).ErrorMessage(); - output += L")"; + output += L"\n"; + output += L"HRESULT: " + numberToHexString(hr) + L",\n"; + + //don't use _com_error(hr).ErrorMessage(), this is nothing more than a call to ::FormatMessage() + std::wstring win32Msg = formatWin32Msg(hr); + if (!win32Msg.empty()) //empty string on error + output += win32Msg; + else + { + output += L"Facility: " + formatFacility(hr) + L",\n"; + output += L"Win32 Error: " + formatWin32Msg(HRESULT_CODE(hr)); //interpet hr as a Win32 code; this is often useful + } return output; } } diff --git a/shared/custom_button.cpp b/shared/custom_button.cpp index 0c4c3019..606db4f2 100644 --- a/shared/custom_button.cpp +++ b/shared/custom_button.cpp @@ -10,37 +10,9 @@ #include <algorithm> #include <limits> #include <cmath> +#include "image_tools.h" - -namespace -{ -bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs) -{ - if (lhs.IsOk() != rhs.IsOk()) - return false; - - if (!lhs.IsOk()) - return true; - - const int pixelCount = lhs.GetWidth() * lhs.GetHeight(); - if (pixelCount != rhs.GetWidth() * rhs.GetHeight()) - return false; - - wxImage imLhs = lhs.ConvertToImage(); - wxImage imRhs = rhs.ConvertToImage(); - - if (imLhs.HasAlpha() != imRhs.HasAlpha()) - return false; - - if (imLhs.HasAlpha()) - { - if (!std::equal(imLhs.GetAlpha(), imLhs.GetAlpha() + pixelCount, imRhs.GetAlpha())) - return false; - } - - return std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData()); -} -} +using namespace zen; void setBitmapLabel(wxBitmapButton& button, const wxBitmap& bmp) diff --git a/shared/custom_combo_box.cpp b/shared/custom_combo_box.cpp deleted file mode 100644 index fb16a303..00000000 --- a/shared/custom_combo_box.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** - -#include "custom_combo_box.h" - - -CustomComboBox::CustomComboBox(wxWindow* parent, - wxWindowID id, - const wxString& value, - const wxPoint& pos, - const wxSize& size, - int n, - const wxString choices[], - long style, - const wxValidator& validator, - const wxString& name) : - wxComboBox(parent, id, value, pos, size, n, choices, style, validator, name) -#if wxCHECK_VERSION(2, 9, 1) - , dropDownShown(false) -#endif -{ - //register key event to enable item deletion - this->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CustomComboBox::OnKeyEvent), NULL, this ); - -#if wxCHECK_VERSION(2, 9, 1) - this->Connect(wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEventHandler(CustomComboBox::OnShowDropDown), NULL, this ); - this->Connect(wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEventHandler(CustomComboBox::OnHideDropDown), NULL, this ); -#endif -} - - -#if wxCHECK_VERSION(2, 9, 1) -void CustomComboBox::OnShowDropDown(wxCommandEvent& event) -{ - dropDownShown = true; - event.Skip(); -} - - -void CustomComboBox::OnHideDropDown(wxCommandEvent& event) -{ - dropDownShown = false; - event.Skip(); -} -#endif - - -void CustomComboBox::OnKeyEvent(wxKeyEvent& event) -{ - const int keyCode = event.GetKeyCode(); - if (keyCode == WXK_DELETE || keyCode == WXK_NUMPAD_DELETE) - { - //try to delete the currently selected config history item - const int selectedItem = this->GetCurrentSelection(); - if (0 <= selectedItem && selectedItem < static_cast<int>(this->GetCount()) && -#if wxCHECK_VERSION(2, 9, 1) - dropDownShown) -#else - //what a mess...: - (GetValue() != GetString(selectedItem) || //avoid problems when a character shall be deleted instead of list item - GetValue() == wxEmptyString)) //exception: always allow removing empty entry -#endif - { - //save old (selected) value: deletion seems to have influence on this - const wxString currentVal = this->GetValue(); - this->SetSelection(wxNOT_FOUND); - - //delete selected row - this->Delete(selectedItem); - - //(re-)set value - this->SetValue(currentVal); - - //eat up key event - return; - } - } - event.Skip(); -} - - -void CustomComboBox::addPairToFolderHistory(const wxString& newFolder, unsigned int maxHistSize) -{ - //don't add empty directories - if (newFolder.empty()) - return; - - const wxString oldVal = this->GetValue(); - - //insert new folder or put it to the front if already existing -#ifdef FFS_WIN //don't respect case in windows build - const int pos = FindString(newFolder, false); -#elif defined FFS_LINUX - const int pos = FindString(newFolder, true); -#endif - if (pos != wxNOT_FOUND) - this->Delete(pos); - - this->Insert(newFolder, 0); - - //keep maximal size of history list - if (this->GetCount() > maxHistSize) - this->Delete(maxHistSize); - - this->SetSelection(wxNOT_FOUND); //don't select anything - this->SetValue(oldVal); //but preserve main text! -} - diff --git a/shared/custom_combo_box.h b/shared/custom_combo_box.h deleted file mode 100644 index 3ddd73b0..00000000 --- a/shared/custom_combo_box.h +++ /dev/null @@ -1,42 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** - -#ifndef CUSTOMCOMBOBOX_H_INCLUDED -#define CUSTOMCOMBOBOX_H_INCLUDED - -#include <wx/combobox.h> - -//combobox with history function + functionality to delete items (DEL) - -class CustomComboBox : public wxComboBox -{ -public: - CustomComboBox(wxWindow* parent, - wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, - const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - void addPairToFolderHistory(const wxString& newFolder, unsigned int maxHistSize); - -private: - void OnKeyEvent(wxKeyEvent& event); - -#if wxCHECK_VERSION(2, 9, 1) - void OnShowDropDown(wxCommandEvent& event); - void OnHideDropDown(wxCommandEvent& event); - - bool dropDownShown; -#endif -}; - - -#endif // CUSTOMCOMBOBOX_H_INCLUDED diff --git a/shared/custom_tooltip.cpp b/shared/custom_tooltip.cpp index 184c2716..0e1c5172 100644 --- a/shared/custom_tooltip.cpp +++ b/shared/custom_tooltip.cpp @@ -17,7 +17,7 @@ public: wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxSize( -1,-1 ), + const wxSize& size = wxSize( -1, -1 ), long style = wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP | wxSTATIC_BORDER); wxStaticText* m_staticTextMain; @@ -41,7 +41,7 @@ CustomTooltip::PopupFrameGenerated::PopupFrameGenerated( bSizer158 = new wxBoxSizer( wxHORIZONTAL ); m_bitmapLeft = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer158->Add( m_bitmapLeft, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizer158->Add( m_bitmapLeft, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); m_staticTextMain = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer158->Add( m_staticTextMain, 0, wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5 ); diff --git a/shared/debug_new.h b/shared/debug_new.h index b8911b4d..ba31e489 100644 --- a/shared/debug_new.h +++ b/shared/debug_new.h @@ -21,7 +21,7 @@ Usage: - Include everywhere before any other file: $(ProjectDir)\shared\debug_new.h For Minidumps: - Compile "debug_new.cpp" -- Compile in Debug build (need Symbols and less restrictive Optimization) +- Compile with debugging symbols and optimization deactivated */ namespace mem_check diff --git a/shared/dir_name.cpp b/shared/dir_name.cpp index f1b0c3c2..a14367c9 100644 --- a/shared/dir_name.cpp +++ b/shared/dir_name.cpp @@ -15,6 +15,7 @@ #include "check_exist.h" #include "util.h" #include "i18n.h" +#include "folder_history_box.h" using namespace zen; @@ -37,7 +38,7 @@ void setDirectoryNameImpl(const wxString& dirname, wxDirPickerCtrl* dirPicker, w staticBox->GetStaticBox()->SetLabel(dirNormalized == dirFormatted ? wxString(_("Drag && drop")) : dirFormatted); } - + if (dirPicker) { if (!dirFormatted.empty() && @@ -61,162 +62,113 @@ void setDirectoryName(const wxString& dirname, void setDirectoryName(const wxString& dirname, - wxComboBox* comboBox, + FolderHistoryBox* comboBox, wxDirPickerCtrl* dirPicker, wxWindow& tooltipWnd, - wxStaticBoxSizer& staticBox, + wxStaticBoxSizer* staticBox, size_t timeout = 200) //pointers are optional { if (comboBox) - { - comboBox->SetSelection(wxNOT_FOUND); - comboBox->SetValue(dirname); - } - setDirectoryNameImpl(dirname, dirPicker, tooltipWnd, &staticBox, timeout); + comboBox->setValue(dirname); + setDirectoryNameImpl(dirname, dirPicker, tooltipWnd, staticBox, timeout); } } - - //############################################################################################################## -using zen::DirectoryNameMainDlg; - -DirectoryNameMainDlg::DirectoryNameMainDlg(wxWindow& dropWindow1, - wxWindow& dropWindow2, - wxDirPickerCtrl& dirPicker, - wxComboBox& dirName, - wxStaticBoxSizer& staticBox) : - dropWindow1_(dropWindow1), + +template <class NameControl> +DirectoryName<NameControl>::DirectoryName(wxWindow& dropWindow, + wxDirPickerCtrl& dirPicker, + NameControl& dirName, + wxStaticBoxSizer* staticBox, + wxWindow* dropWindow2) : + dropWindow_(dropWindow), dropWindow2_(dropWindow2), dirPicker_(dirPicker), dirName_(dirName), staticBox_(staticBox) { //prepare drag & drop - setupFileDrop(dropWindow1); - setupFileDrop(dropWindow2); + setupFileDrop(dropWindow); + if (dropWindow2) + setupFileDrop(*dropWindow2); //redirect drag & drop event back to this class - dropWindow1.Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryNameMainDlg::OnFilesDropped), NULL, this); - dropWindow2.Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryNameMainDlg::OnFilesDropped), NULL, this); + dropWindow.Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryName::OnFilesDropped), NULL, this); + if (dropWindow2) + dropWindow2->Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryName::OnFilesDropped), NULL, this); //keep dirPicker and dirName synchronous - dirName .Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DirectoryNameMainDlg::OnWriteDirManually), NULL, this ); - dirPicker.Connect( wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(DirectoryNameMainDlg::OnDirSelected), NULL, this ); + dirName_ .Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DirectoryName::OnWriteDirManually), NULL, this); + dirPicker_.Connect(wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(DirectoryName::OnDirSelected ), NULL, this); +} + + +template <class NameControl> +DirectoryName<NameControl>::~DirectoryName() +{ + dirName_ .Disconnect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DirectoryName::OnWriteDirManually), NULL, this); + dirPicker_.Disconnect(wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler(DirectoryName::OnDirSelected ), NULL, this); } -void DirectoryNameMainDlg::OnFilesDropped(FFSFileDropEvent& event) +template <class NameControl> +void DirectoryName<NameControl>::OnFilesDropped(FFSFileDropEvent& event) { if (event.getFiles().empty()) return; - if (AcceptDrop(event.getFiles())) + if (acceptDrop(event.getFiles())) { - wxString fileName = event.getFiles()[0]; + const wxString fileName = event.getFiles()[0]; if (dirExists(toZ(fileName))) setDirectoryName(fileName, &dirName_, &dirPicker_, dirName_, staticBox_); else { - fileName = beforeLast(fileName, FILE_NAME_SEPARATOR); - if (dirExists(toZ(fileName))) + wxString parentName = beforeLast(fileName, FILE_NAME_SEPARATOR); //returns empty string if ch not found +#ifdef FFS_WIN + if (endsWith(parentName, L":")) //volume name + parentName += FILE_NAME_SEPARATOR; +#endif + if (dirExists(toZ(parentName))) + setDirectoryName(parentName, &dirName_, &dirPicker_, dirName_, staticBox_); + else //set original name unconditionally: usecase: inactive mapped network shares setDirectoryName(fileName, &dirName_, &dirPicker_, dirName_, staticBox_); } } } -void DirectoryNameMainDlg::OnWriteDirManually(wxCommandEvent& event) +template <class NameControl> +void DirectoryName<NameControl>::OnWriteDirManually(wxCommandEvent& event) { - setDirectoryName(event.GetString(), NULL, &dirPicker_, dirName_, staticBox_, 100); //potentially slow network access: wait 100 ms at most + setDirectoryName(event.GetString(), static_cast<NameControl*>(NULL), &dirPicker_, dirName_, staticBox_, 100); //potentially slow network access: wait 100 ms at most event.Skip(); } -void DirectoryNameMainDlg::OnDirSelected(wxFileDirPickerEvent& event) +template <class NameControl> +void DirectoryName<NameControl>::OnDirSelected(wxFileDirPickerEvent& event) { const wxString newPath = event.GetPath(); setDirectoryName(newPath, &dirName_, NULL, dirName_, staticBox_); - event.Skip(); } -wxString DirectoryNameMainDlg::getName() const +template <class NameControl> +wxString DirectoryName<NameControl>::getName() const { return dirName_.GetValue(); } -void DirectoryNameMainDlg::setName(const wxString& dirname) +template <class NameControl> +void DirectoryName<NameControl>::setName(const wxString& dirname) { setDirectoryName(dirname, &dirName_, &dirPicker_, dirName_, staticBox_); } -//############################################################################################################## -using zen::DirectoryName; - -DirectoryName::DirectoryName(wxWindow& dropWindow, - wxDirPickerCtrl& dirPicker, - wxTextCtrl& dirName, - wxStaticBoxSizer* staticBox) : - dropWindow_(dropWindow), - dirPicker_(dirPicker), - dirName_(dirName), - staticBox_(staticBox) -{ - //prepare drag & drop - setupFileDrop(dropWindow); - - //redirect drag & drop event back to this class - dropWindow.Connect(FFS_DROP_FILE_EVENT, FFSFileDropEventHandler(DirectoryName::OnFilesDropped), NULL, this); - - //keep dirPicker and dirName synchronous - dirName.Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DirectoryName::OnWriteDirManually ), NULL, this ); - dirPicker.Connect( wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEventHandler( DirectoryName::OnDirSelected ), NULL, this ); -} - - -void DirectoryName::OnFilesDropped(FFSFileDropEvent& event) -{ - if (event.getFiles().empty()) - return; - - wxString fileName = event.getFiles()[0]; - if (dirExists(toZ(fileName))) - setDirectoryName(fileName, &dirName_, &dirPicker_, dirName_, staticBox_); - else - { - fileName = beforeLast(fileName, FILE_NAME_SEPARATOR); - if (dirExists(toZ(fileName))) - setDirectoryName(fileName, &dirName_, &dirPicker_, dirName_, staticBox_); - } -} - - -void DirectoryName::OnWriteDirManually(wxCommandEvent& event) -{ - setDirectoryName(event.GetString(), NULL, &dirPicker_, dirName_, staticBox_, 100); //potentially slow network access: wait 100 ms at most - event.Skip(); -} - - -void DirectoryName::OnDirSelected(wxFileDirPickerEvent& event) -{ - const wxString newPath = event.GetPath(); - setDirectoryName(newPath, &dirName_, NULL, dirName_, staticBox_); - - event.Skip(); -} - - -wxString DirectoryName::getName() const -{ - return dirName_.GetValue(); -} - - -void DirectoryName::setName(const wxString& dirname) -{ - setDirectoryName(dirname, &dirName_, &dirPicker_, dirName_, staticBox_); -} +//explicit template instantiation +template class DirectoryName<wxTextCtrl>; +template class DirectoryName<FolderHistoryBox>; diff --git a/shared/dir_name.h b/shared/dir_name.h index 6e783d75..7c7b3bc4 100644 --- a/shared/dir_name.h +++ b/shared/dir_name.h @@ -11,64 +11,38 @@ #include <wx/event.h> #include <wx/sizer.h> #include <wx/filepicker.h> -#include <wx/combobox.h> #include "file_drop.h" - -class wxFileDirPickerEvent; - namespace zen { //handle drag and drop, tooltip, label and manual input, coordinating a wxWindow, wxDirPickerCtrl, and wxComboBox/wxTextCtrl -class DirectoryNameMainDlg : private wxEvtHandler +template <class NameControl> //NameControl may be wxTextCtrl, FolderHistoryBox +class DirectoryName: private wxEvtHandler { public: - DirectoryNameMainDlg(wxWindow& dropWindow1, - wxWindow& dropWindow2, - wxDirPickerCtrl& dirPicker, - wxComboBox& dirName, - wxStaticBoxSizer& staticBox); + DirectoryName(wxWindow& dropWindow, + wxDirPickerCtrl& dirPicker, + NameControl& dirName, + wxStaticBoxSizer* staticBox = NULL, + wxWindow* dropWindow2 = NULL); //optional - virtual ~DirectoryNameMainDlg() {} + ~DirectoryName(); wxString getName() const; void setName(const wxString& dirname); - virtual bool AcceptDrop(const std::vector<wxString>& droppedFiles) = 0; //return true if drop should be processed - private: - void OnFilesDropped(FFSFileDropEvent& event); - void OnWriteDirManually(wxCommandEvent& event); - void OnDirSelected(wxFileDirPickerEvent& event); - - const wxWindow& dropWindow1_; - const wxWindow& dropWindow2_; - wxDirPickerCtrl& dirPicker_; - wxComboBox& dirName_; - wxStaticBoxSizer& staticBox_; -}; + virtual bool acceptDrop(const std::vector<wxString>& droppedFiles) { return true; }; //return true if drop should be processed - -class DirectoryName: private wxEvtHandler -{ -public: - DirectoryName(wxWindow& dropWindow, - wxDirPickerCtrl& dirPicker, - wxTextCtrl& dirName, - wxStaticBoxSizer* staticBox = NULL); //optional - - wxString getName() const; - void setName(const wxString& dirname); - -private: void OnFilesDropped(FFSFileDropEvent& event); void OnWriteDirManually(wxCommandEvent& event); void OnDirSelected(wxFileDirPickerEvent& event); - const wxWindow& dropWindow_; - wxDirPickerCtrl& dirPicker_; - wxTextCtrl& dirName_; + const wxWindow& dropWindow_; + const wxWindow* dropWindow2_; + wxDirPickerCtrl& dirPicker_; + NameControl& dirName_; wxStaticBoxSizer* staticBox_; //optional }; } diff --git a/shared/dir_watcher.cpp b/shared/dir_watcher.cpp index 9c3a00c7..5d178734 100644 --- a/shared/dir_watcher.cpp +++ b/shared/dir_watcher.cpp @@ -28,77 +28,88 @@ using namespace zen; - #ifdef FFS_WIN namespace { -typedef Zbase<wchar_t> BasicWString; //thread safe string class for UI texts - - -struct SharedData +class SharedData { - boost::mutex lockAccess; - std::set<Zstring> changedFiles; //get rid of duplicate entries (actually occur!) - BasicWString errorMsg; //non-empty if errors occured in thread -}; - - -void addChanges(SharedData& shared, const char* buffer, DWORD bytesWritten, const Zstring& dirname) //throw () -{ - boost::lock_guard<boost::mutex> dummy(shared.lockAccess); +public: + //context of worker thread + void addChanges(const char* buffer, DWORD bytesWritten, const Zstring& dirname) //throw () + { + boost::lock_guard<boost::mutex> dummy(lockAccess); - std::set<Zstring>& output = shared.changedFiles; + std::set<Zstring>& output = changedFiles; - if (bytesWritten == 0) //according to docu this may happen in case of internal buffer overflow: report some "dummy" change - output.insert(L"Overflow!"); - else - { - const char* bufPos = &buffer[0]; - while (true) + if (bytesWritten == 0) //according to docu this may happen in case of internal buffer overflow: report some "dummy" change + output.insert(L"Overflow!"); + else { - const FILE_NOTIFY_INFORMATION& notifyInfo = reinterpret_cast<const FILE_NOTIFY_INFORMATION&>(*bufPos); + const char* bufPos = &buffer[0]; + while (true) + { + const FILE_NOTIFY_INFORMATION& notifyInfo = reinterpret_cast<const FILE_NOTIFY_INFORMATION&>(*bufPos); - const Zstring fullname = dirname + Zstring(notifyInfo.FileName, notifyInfo.FileNameLength / sizeof(WCHAR)); + const Zstring fullname = dirname + Zstring(notifyInfo.FileName, notifyInfo.FileNameLength / sizeof(WCHAR)); - //skip modifications sent by changed directories: reason for change, child element creation/deletion, will notify separately! - bool skip = false; - if (notifyInfo.Action == FILE_ACTION_MODIFIED) - { - //note: this check will not work if top watched directory has been renamed - const DWORD ret = ::GetFileAttributes(applyLongPathPrefix(fullname).c_str()); - bool isDir = ret != INVALID_FILE_ATTRIBUTES && (ret & FILE_ATTRIBUTE_DIRECTORY); //returns true for (dir-)symlinks also - skip = isDir; - } + //skip modifications sent by changed directories: reason for change, child element creation/deletion, will notify separately! + bool skip = false; + if (notifyInfo.Action == FILE_ACTION_RENAMED_OLD_NAME) //FILE_ACTION_RENAMED_NEW_NAME should suffice + skip = true; + else if (notifyInfo.Action == FILE_ACTION_MODIFIED) + { + //note: this check will not work if top watched directory has been renamed + const DWORD ret = ::GetFileAttributes(applyLongPathPrefix(fullname).c_str()); + bool isDir = ret != INVALID_FILE_ATTRIBUTES && (ret & FILE_ATTRIBUTE_DIRECTORY); //returns true for (dir-)symlinks also + skip = isDir; + } - if (!skip) - output.insert(fullname); + if (!skip) + output.insert(fullname); - if (notifyInfo.NextEntryOffset == 0) - break; - bufPos += notifyInfo.NextEntryOffset; + if (notifyInfo.NextEntryOffset == 0) + break; + bufPos += notifyInfo.NextEntryOffset; + } } } -} + //context of main thread + void addChange(const Zstring& dirname) //throw () + { + boost::lock_guard<boost::mutex> dummy(lockAccess); + changedFiles.insert(dirname); + } -void getChanges(SharedData& shared, std::vector<Zstring>& output) //throw FileError -{ - boost::lock_guard<boost::mutex> dummy(shared.lockAccess); - //first check whether errors occured in thread - if (!shared.errorMsg.empty()) - throw zen::FileError(shared.errorMsg.c_str()); + //context of main thread + void getChanges(std::vector<Zstring>& output) //throw FileError + { + boost::lock_guard<boost::mutex> dummy(lockAccess); - output.assign(shared.changedFiles.begin(), shared.changedFiles.end()); - shared.changedFiles.clear(); -} + //first check whether errors occured in thread + if (!errorMsg.empty()) + throw zen::FileError(errorMsg.c_str()); + output.assign(changedFiles.begin(), changedFiles.end()); + changedFiles.clear(); + } -void reportError(SharedData& shared, const BasicWString& errorMsg) //throw () -{ - boost::lock_guard<boost::mutex> dummy(shared.lockAccess); - shared.errorMsg = errorMsg; -} + + //context of worker thread + void reportError(const std::wstring& msg) //throw () + { + boost::lock_guard<boost::mutex> dummy(lockAccess); + errorMsg = cvrtString<BasicWString>(msg); + } + +private: + typedef Zbase<wchar_t> BasicWString; //thread safe string class for UI texts + + boost::mutex lockAccess; + std::set<Zstring> changedFiles; //get rid of duplicate entries (actually occur!) + BasicWString errorMsg; //non-empty if errors occured in thread +}; class ReadChangesAsync @@ -129,7 +140,7 @@ public: OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); - if(hDir == INVALID_HANDLE_VALUE ) + if (hDir == INVALID_HANDLE_VALUE ) throw FileError(_("Could not initialize directory monitoring:") + "\n\"" + utf8CvrtTo<std::wstring>(dirname) + "\"" + "\n\n" + zen::getLastErrorFormatted()); //Loki::ScopeGuard guardDir = Loki::MakeGuard(::CloseHandle, hDir); @@ -146,7 +157,7 @@ public: { try { - std::vector<char> buffer(64 * 1024); //maximum buffer size restricted by some networks protocols (according to docu) + std::vector<char> buffer(64 * 1024); //needs to be aligned on a DWORD boundary; maximum buffer size restricted by some networks protocols (according to docu) while (true) { @@ -159,7 +170,7 @@ public: false, //__in BOOL bInitialState, NULL); //__in_opt LPCTSTR lpName if (overlapped.hEvent == NULL) - return ::reportError(*shared_, BasicWString(_("Error when monitoring directories.") + "\n\n" + getLastErrorFormatted())); //throw () + quit thread + return shared_->reportError(_("Error when monitoring directories.") + " (CreateEvent)" + "\n\n" + getLastErrorFormatted()); //throw () + quit thread Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, overlapped.hEvent); (void)dummy; @@ -176,14 +187,13 @@ public: NULL, // __out_opt LPDWORD lpBytesReturned, &overlapped, // __inout_opt LPOVERLAPPED lpOverlapped, NULL)) // __in_opt LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine - return ::reportError(*shared_, BasicWString(_("Error when monitoring directories.") + "\n\n" + getLastErrorFormatted())); //throw () + quit thread + return shared_->reportError(_("Error when monitoring directories.") + " (ReadDirectoryChangesW)" + "\n\n" + getLastErrorFormatted()); //throw () + quit thread //async I/O is a resource that needs to be guarded since it will write to local variable "buffer"! Loki::ScopeGuard lockAio = Loki::MakeGuard([&]() { //http://msdn.microsoft.com/en-us/library/aa363789(v=vs.85).aspx - bool cancelSuccess = ::CancelIo(hDir) == TRUE; //cancel all async I/O related to this handle and thread - if (cancelSuccess) + if (::CancelIo(hDir) == TRUE) //cancel all async I/O related to this handle and thread { DWORD bytesWritten = 0; ::GetOverlappedResult(hDir, &overlapped, &bytesWritten, true); //wait until cancellation is complete @@ -199,7 +209,7 @@ public: false)) //__in BOOL bWait { if (::GetLastError() != ERROR_IO_INCOMPLETE) - return ::reportError(*shared_, BasicWString(_("Error when monitoring directories.") + "\n\n" + getLastErrorFormatted())); //throw () + quit thread + return shared_->reportError(_("Error when monitoring directories.") + " (GetOverlappedResult)" + "\n\n" + getLastErrorFormatted()); //throw () + quit thread //execute asynchronous procedure calls (APC) queued on this thread ::SleepEx(50, // __in DWORD dwMilliseconds, @@ -209,7 +219,7 @@ public: } lockAio.Dismiss(); - ::addChanges(*shared_, &buffer[0], bytesWritten, dirname); //throw () + shared_->addChanges(&buffer[0], bytesWritten, dirname); //throw () } } catch (boost::thread_interrupted&) @@ -222,7 +232,7 @@ public: } } - ReadChangesAsync(ReadChangesAsync&& other) : + ReadChangesAsync(ReadChangesAsync && other) : hDir(INVALID_HANDLE_VALUE) { shared_ = std::move(other.shared_); @@ -269,10 +279,7 @@ private: //now hDir should have been released //report removal as change to main directory - { - boost::lock_guard<boost::mutex> dummy(shared_->lockAccess); - shared_->changedFiles.insert(dirname_); - } + shared_->addChange(dirname_); removalRequested = true; } //don't throw! @@ -327,7 +334,7 @@ DirWatcher::~DirWatcher() std::vector<Zstring> DirWatcher::getChanges() //throw FileError { std::vector<Zstring> output; - ::getChanges(*pimpl_->shared, output); //throw FileError + pimpl_->shared->getChanges(output); //throw FileError return output; } diff --git a/shared/dll_loader.cpp b/shared/dll_loader.cpp deleted file mode 100644 index 4e2c0e65..00000000 --- a/shared/dll_loader.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** - -#include "dll_loader.h" -#include <map> - -namespace -{ -class DllHandler -{ -public: - static DllHandler& getInstance() - { - static DllHandler instance; - return instance; - } - - HMODULE getHandle(const std::wstring& libraryName) - { - if (libraryName.empty()) - return ::GetModuleHandle(NULL); //return handle to calling executable - - HandleMap::const_iterator iter = handles.find(libraryName); - if (iter != handles.end()) - return iter->second; - - HMODULE newHandle = ::LoadLibrary(libraryName.c_str()); - if (newHandle != NULL) - handles.insert(std::make_pair(libraryName, newHandle)); - - return newHandle; - } - -private: - DllHandler() {} - DllHandler(const DllHandler&); - DllHandler& operator=(const DllHandler&); - - ~DllHandler() - { - for (HandleMap::const_iterator i = handles.begin(); i != handles.end(); ++i) - ::FreeLibrary(i->second); - } - - typedef std::map<std::wstring, HMODULE> HandleMap; - HandleMap handles; //only valid handles here! -}; -} - - -FARPROC util::loadSymbol(const std::wstring& libraryName, const std::string& functionName) -{ - const HMODULE libHandle = DllHandler::getInstance().getHandle(libraryName); - return libHandle != NULL ? ::GetProcAddress(libHandle, functionName.c_str()) : NULL; -} - - -std::string util::getResourceStream(const std::wstring& libraryName, size_t resourceId) -{ - std::string output; - const HMODULE module = DllHandler::getInstance().getHandle(libraryName); - if (module) - { - const HRSRC res = ::FindResource(module, MAKEINTRESOURCE(resourceId), RT_RCDATA); - if (res != NULL) - { - const HGLOBAL resHandle = ::LoadResource(module, res); - if (resHandle != NULL) - { - const char* stream = static_cast<const char*>(::LockResource(resHandle)); - if (stream) - { - const DWORD streamSize = ::SizeofResource(module, res); - output.assign(stream, streamSize); - } - } - } - } - return output; -} diff --git a/shared/dll_loader.h b/shared/dll_loader.h index 252e7598..e34fc4a9 100644 --- a/shared/dll_loader.h +++ b/shared/dll_loader.h @@ -7,7 +7,9 @@ #ifndef DLLLOADER_H_INCLUDED #define DLLLOADER_H_INCLUDED +#include <memory> #include <string> +#include "loki\ScopeGuard.h" #ifdef __WXMSW__ //we have wxWidgets #include <wx/msw/wrapwin.h> //includes "windows.h" @@ -20,13 +22,35 @@ namespace util { - /* -load function from a DLL library, e.g. from kernel32.dll -NOTE: you're allowed to take a static reference to the return value! :) +Manage DLL function and library ownership + - thread safety: like built-in type + - full value semantics + + Usage: + typedef BOOL (WINAPI *IsWow64ProcessFun)(HANDLE hProcess, PBOOL Wow64Process); + const util::DllFun<IsWow64ProcessFun> isWow64Process(L"kernel32.dll", "IsWow64Process"); + if (isWow64Process) */ -template <typename FunctionType> -FunctionType getDllFun(const std::wstring& libraryName, const std::string& functionName); + +template <class Func> +class DllFun +{ +public: + DllFun() : fun(NULL) {} + + DllFun(const wchar_t* libraryName, const char* functionName) : + hLibRef(new HMODULE(::LoadLibrary(libraryName)), deleter), + fun(*hLibRef ? reinterpret_cast<Func>(::GetProcAddress(*hLibRef, functionName)) : NULL) {} + + operator Func() const { return fun; } + +private: + static void deleter(HMODULE* ptr) { if (*ptr) ::FreeLibrary(*ptr); delete ptr; } + + std::shared_ptr<HMODULE> hLibRef; + Func fun; +}; /* extract binary resources from .exe/.dll: @@ -48,13 +72,38 @@ std::string getResourceStream(const std::wstring& libraryName, size_t resourceId -//---------------Inline Implementation--------------------------------------------------- -FARPROC loadSymbol(const std::wstring& libraryName, const std::string& functionName); -template <typename FunctionType> inline -FunctionType getDllFun(const std::wstring& libraryName, const std::string& functionName) + + + + + +//---------------Inline Implementation--------------------------------------------------- +inline +std::string getResourceStream(const wchar_t* libraryName, size_t resourceId) { - return reinterpret_cast<FunctionType>(loadSymbol(libraryName, functionName)); + std::string output; + HMODULE module = ::LoadLibrary(libraryName); + if (module) + { + LOKI_ON_BLOCK_EXIT2(::FreeLibrary(module)); + + const HRSRC res = ::FindResource(module, MAKEINTRESOURCE(resourceId), RT_RCDATA); + if (res != NULL) + { + const HGLOBAL resHandle = ::LoadResource(module, res); + if (resHandle != NULL) + { + const char* stream = static_cast<const char*>(::LockResource(resHandle)); + if (stream) + { + const DWORD streamSize = ::SizeofResource(module, res); + output.assign(stream, streamSize); + } + } + } + } + return output; } } diff --git a/shared/dst_hack.cpp b/shared/dst_hack.cpp index d52a335f..aa7a0f3e 100644 --- a/shared/dst_hack.cpp +++ b/shared/dst_hack.cpp @@ -9,6 +9,7 @@ #include <limits> #include "int64.h" #include "file_error.h" +#include "dll_loader.h" using namespace zen; @@ -78,11 +79,64 @@ bool dst::isFatDrive(const Zstring& fileName) //throw() assert(false); //shouldn't happen return false; } - const Zstring fileSystem = fsName; + //DST hack seems to be working equally well for FAT and FAT32 (in particular creation time has 10^-2 s precision as advertised) + return fsName == Zstring(L"FAT") || + fsName == Zstring(L"FAT32"); +} + + +bool dst::vistaOrLater() +{ + OSVERSIONINFO osvi = {}; + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + //IFileOperation is supported with Vista and later + if (::GetVersionEx(&osvi)) + return osvi.dwMajorVersion > 5; + //XP has majorVersion == 5, minorVersion == 1 + //Vista has majorVersion == 6, minorVersion == 0 + //version overview: http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx + return false; +} + +bool dst::isFatDrive(HANDLE hFile) //throw() +{ + //dynamically load windows API function + typedef BOOL (WINAPI *GetVolumeInformationByHandleWFunc)(HANDLE hFile, + LPWSTR lpVolumeNameBuffer, + DWORD nVolumeNameSize, + LPDWORD lpVolumeSerialNumber, + LPDWORD lpMaximumComponentLength, + LPDWORD lpFileSystemFlags, + LPWSTR lpFileSystemNameBuffer, + DWORD nFileSystemNameSize); + + const util::DllFun<GetVolumeInformationByHandleWFunc> getVolumeInformationByHandle(L"kernel32.dll", "GetVolumeInformationByHandleW"); + if (!getVolumeInformationByHandle) + { + assert(false); + return false; + } + + const size_t BUFFER_SIZE = MAX_PATH + 1; + wchar_t fsName[BUFFER_SIZE]; + + if (!getVolumeInformationByHandle(hFile, //__in HANDLE hFile, + NULL, //__out LPTSTR lpVolumeNameBuffer, + 0, //__in DWORD nVolumeNameSize, + NULL, //__out_opt LPDWORD lpVolumeSerialNumber, + NULL, //__out_opt LPDWORD lpMaximumComponentLength, + NULL, //__out_opt LPDWORD lpFileSystemFlags, + fsName, //__out LPTSTR lpFileSystemNameBuffer, + BUFFER_SIZE)) //__in DWORD nFileSystemNameSize + { + assert(false); //shouldn't happen + return false; + } //DST hack seems to be working equally well for FAT and FAT32 (in particular creation time has 10^-2 s precision as advertised) - return fileSystem == Zstr("FAT") || - fileSystem == Zstr("FAT32"); + return fsName == Zstring(L"FAT") || + fsName == Zstring(L"FAT32"); } @@ -244,7 +298,7 @@ std::bitset<UTC_LOCAL_OFFSET_BITS> getUtcLocalShift() const int absValue = common::abs(timeShiftQuarter); //MSVC C++0x bug: std::bitset<>(unsigned long) is ambiguous - if (std::bitset<UTC_LOCAL_OFFSET_BITS - 1>(absValue).to_ulong() != static_cast<unsigned long>(absValue) || //time shifts that big shouldn't be possible! + if (std::bitset < UTC_LOCAL_OFFSET_BITS - 1 > (absValue).to_ulong() != static_cast<unsigned long>(absValue) || //time shifts that big shouldn't be possible! timeShiftSec % (60 * 15) != 0) //all known time shift have at least 15 minute granularity! { const std::wstring errorMessage = _("Conversion error:") + " Unexpected UTC <-> local time shift: " + diff --git a/shared/dst_hack.h b/shared/dst_hack.h index 550098a2..2e25cf81 100644 --- a/shared/dst_hack.h +++ b/shared/dst_hack.h @@ -19,6 +19,8 @@ Solve DST +-1h and time zone shift issues on FAT drives */ bool isFatDrive(const Zstring& fileName); //throw () +bool isFatDrive(HANDLE hFile); //throw() -> call ONLY if vistaOrLater() == true! +bool vistaOrLater(); //all subsequent functions may throw the std::runtime_error exception! diff --git a/shared/file_handling.cpp b/shared/file_handling.cpp index 8fa8568a..c9e85c15 100644 --- a/shared/file_handling.cpp +++ b/shared/file_handling.cpp @@ -17,6 +17,7 @@ #include "assert_static.h" #include <boost/thread/tss.hpp> #include <boost/thread/once.hpp> +#include "file_id_internal.h" #ifdef FFS_WIN #include "privilege.h" @@ -98,63 +99,99 @@ bool zen::somethingExists(const Zstring& objname) //throw() check whether } -#ifdef FFS_WIN namespace { -zen::UInt64 getFileSizeSymlink(const Zstring& linkName) //throw (FileError) -{ - //open handle to target of symbolic link - const HANDLE hFile = ::CreateFile(applyLongPathPrefix(linkName).c_str(), - 0, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - throw FileError(_("Error reading file attributes:") + "\n\"" + linkName + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hFile); - (void)dummy; //silence warning "unused variable" - - BY_HANDLE_FILE_INFORMATION fileInfo = {}; - if (!::GetFileInformationByHandle(hFile, &fileInfo)) - throw FileError(_("Error reading file attributes:") + "\n\"" + linkName + "\"" + "\n\n" + getLastErrorFormatted()); - - return UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); -} -} -#endif - - -UInt64 zen::getFilesize(const Zstring& filename) //throw (FileError) +void getFileAttrib(const Zstring& filename, FileAttrib& attr, ProcSymlink procSl) //throw FileError { #ifdef FFS_WIN WIN32_FIND_DATA fileInfo = {}; - const HANDLE searchHandle = ::FindFirstFile(applyLongPathPrefix(filename).c_str(), &fileInfo); - if (searchHandle == INVALID_HANDLE_VALUE) - throw FileError(_("Error reading file attributes:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); - - ::FindClose(searchHandle); + { + const HANDLE searchHandle = ::FindFirstFile(applyLongPathPrefix(filename).c_str(), &fileInfo); + if (searchHandle == INVALID_HANDLE_VALUE) + throw FileError(_("Error reading file attributes:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); + ::FindClose(searchHandle); + } + // WIN32_FILE_ATTRIBUTE_DATA sourceAttr = {}; + // if (!::GetFileAttributesEx(applyLongPathPrefix(sourceObj).c_str(), //__in LPCTSTR lpFileName, + // GetFileExInfoStandard, //__in GET_FILEEX_INFO_LEVELS fInfoLevelId, + // &sourceAttr)) //__out LPVOID lpFileInformation const bool isSymbolicLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; - if (isSymbolicLink) - return getFileSizeSymlink(filename); //throw (FileError) + if (!isSymbolicLink || procSl == SYMLINK_DIRECT) + { + //####################################### DST hack ########################################### + const bool isDirectory = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; + if (!isDirectory && dst::isFatDrive(filename)) //throw() + { + const dst::RawTime rawTime(fileInfo.ftCreationTime, fileInfo.ftLastWriteTime); + if (dst::fatHasUtcEncoded(rawTime)) //throw (std::runtime_error) + { + fileInfo.ftLastWriteTime = dst::fatDecodeUtcTime(rawTime); //return last write time in real UTC, throw (std::runtime_error) + ::GetSystemTimeAsFileTime(&fileInfo.ftCreationTime); //real creation time information is not available... + } + } + //####################################### DST hack ########################################### - return UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); + attr.fileSize = UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); + attr.modificationTime = toTimeT(fileInfo.ftLastWriteTime); + } + else + { + const HANDLE hFile = ::CreateFile(applyLongPathPrefix(filename).c_str(), //open handle to target of symbolic link + 0, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + 0, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL); + if (hFile == INVALID_HANDLE_VALUE) + throw FileError(_("Error reading file attributes:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hFile)); + + BY_HANDLE_FILE_INFORMATION fileInfoHnd = {}; + if (!::GetFileInformationByHandle(hFile, &fileInfoHnd)) + throw FileError(_("Error reading file attributes:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); + + attr.fileSize = UInt64(fileInfoHnd.nFileSizeLow, fileInfoHnd.nFileSizeHigh); + attr.modificationTime = toTimeT(fileInfoHnd.ftLastWriteTime); + } #elif defined FFS_LINUX struct stat fileInfo = {}; - if (::stat(filename.c_str(), &fileInfo) != 0) //follow symbolic links + + const int rv = procSl == SYMLINK_FOLLOW ? + :: stat(filename.c_str(), &fileInfo) : + ::lstat(filename.c_str(), &fileInfo); + if (rv != 0) //follow symbolic links throw FileError(_("Error reading file attributes:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); - return UInt64(fileInfo.st_size); + attr.fileSize = UInt64(fileInfo.st_size); + attr.modificationTime = fileInfo.st_mtime; #endif } +} + + +UInt64 zen::getFilesize(const Zstring& filename) //throw FileError +{ + FileAttrib attr; + getFileAttrib(filename, attr, SYMLINK_FOLLOW); //throw FileError + return attr.fileSize; +} + + +Int64 zen::getFileTime(const Zstring& filename, ProcSymlink procSl) //throw FileError +{ + FileAttrib attr; + getFileAttrib(filename, attr, procSl); //throw FileError + return attr.modificationTime; +} namespace { + + #ifdef FFS_WIN DWORD retrieveVolumeSerial(const Zstring& pathName) //return 0 on error! { @@ -218,7 +255,7 @@ zen::ResponseSame zen::onSameVolume(const Zstring& folderLeft, const Zstring& fo } -bool zen::removeFile(const Zstring& filename) //throw (FileError); +bool zen::removeFile(const Zstring& filename) //throw FileError; { #ifdef FFS_WIN //remove file, support for \\?\-prefix @@ -261,16 +298,15 @@ namespace { DEFINE_NEW_FILE_ERROR(ErrorDifferentVolume); -/* Usage overview: +/* Usage overview: (avoid circular pattern!) - renameFile() --> renameFileInternal() + renameFile() --> renameFile_sub() | /|\ \|/ | - fix8Dot3NameClash() + Fix8Dot3NameClash() */ //wrapper for file system rename function: -//throw (FileError); ErrorDifferentVolume if it is due to moving file to another volume -void renameFileInternal(const Zstring& oldName, const Zstring& newName) //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting) +void renameFile_sub(const Zstring& oldName, const Zstring& newName) //throw FileError, ErrorDifferentVolume, ErrorTargetExisting { #ifdef FFS_WIN const Zstring oldNameFmt = applyLongPathPrefix(oldName); @@ -361,12 +397,12 @@ Zstring getFilenameFmt(const Zstring& filename, Function fun) //throw(); returns } -Zstring createTemp8Dot3Name(const Zstring& fileName) //find a unique 8.3 short name +Zstring findUnused8Dot3Name(const Zstring& filename) //find a unique 8.3 short name { - const Zstring pathPrefix = fileName.find(FILE_NAME_SEPARATOR) != Zstring::npos ? - (fileName.BeforeLast(FILE_NAME_SEPARATOR) + FILE_NAME_SEPARATOR) : Zstring(); + const Zstring pathPrefix = filename.find(FILE_NAME_SEPARATOR) != Zstring::npos ? + (filename.BeforeLast(FILE_NAME_SEPARATOR) + FILE_NAME_SEPARATOR) : Zstring(); - Zstring extension = fileName.AfterLast(FILE_NAME_SEPARATOR).AfterLast(Zchar('.')); //extension needn't contain reasonable data + Zstring extension = filename.AfterLast(FILE_NAME_SEPARATOR).AfterLast(Zchar('.')); //extension needn't contain reasonable data if (extension.empty()) extension = Zstr("FFS"); extension.Truncate(3); @@ -382,63 +418,82 @@ Zstring createTemp8Dot3Name(const Zstring& fileName) //find a unique 8.3 short n } -//try to handle issues with already existing short 8.3 file names on Windows 7 -bool fix8Dot3NameClash(const Zstring& oldName, const Zstring& newName) //throw (FileError); return "true" if rename operation succeeded +bool have8dot3NameClash(const Zstring& filename) { - using namespace zen; - - if (newName.find(FILE_NAME_SEPARATOR) == Zstring::npos) + if (filename.find(FILE_NAME_SEPARATOR) == Zstring::npos) return false; - if (somethingExists(newName)) //name OR directory! + if (somethingExists(filename)) //name OR directory! { - const Zstring fileNameOrig = newName.AfterLast(FILE_NAME_SEPARATOR); //returns the whole string if ch not found - const Zstring fileNameShort = getFilenameFmt(newName, ::GetShortPathName).AfterLast(FILE_NAME_SEPARATOR); //throw() returns empty string on error - const Zstring fileNameLong = getFilenameFmt(newName, ::GetLongPathName) .AfterLast(FILE_NAME_SEPARATOR); //throw() returns empty string on error - - if (!fileNameShort.empty() && - !fileNameLong.empty() && - EqualFilename() (fileNameOrig, fileNameShort) && - !EqualFilename()(fileNameShort, fileNameLong)) + const Zstring origName = filename.AfterLast(FILE_NAME_SEPARATOR); //returns the whole string if ch not found + const Zstring shortName = getFilenameFmt(filename, ::GetShortPathName).AfterLast(FILE_NAME_SEPARATOR); //throw() returns empty string on error + const Zstring longName = getFilenameFmt(filename, ::GetLongPathName) .AfterLast(FILE_NAME_SEPARATOR); // + + if (!shortName.empty() && + !longName.empty() && + EqualFilename()(origName, shortName) && + !EqualFilename()(shortName, longName)) { - //we detected an event where newName is in shortname format (although it is intended to be a long name) and - //writing target file failed because another unrelated file happens to have the same short name + //for filename short and long file name are equal and another unrelated file happens to have the same short name + //e.g. filename == "TESTWE~1", but another file is existing named "TestWeb" with short name ""TESTWE~1" + return true; + } + } + return false; +} - const Zstring unrelatedPathLong = newName.BeforeLast(FILE_NAME_SEPARATOR) + FILE_NAME_SEPARATOR + fileNameLong; +class Fix8Dot3NameClash +{ +public: + Fix8Dot3NameClash(const Zstring& filename) + { + const Zstring longName = getFilenameFmt(filename, ::GetLongPathName).AfterLast(FILE_NAME_SEPARATOR); //throw() returns empty string on error - //find another name in short format: this ensures the actual short name WILL be renamed as well! - const Zstring parkedTarget = createTemp8Dot3Name(newName); + unrelatedFile = filename.BeforeLast(FILE_NAME_SEPARATOR) + FILE_NAME_SEPARATOR + longName; - //move already existing short name out of the way for now - renameFileInternal(unrelatedPathLong, parkedTarget); //throw (FileError: ErrorDifferentVolume); - //DON'T call renameFile() to avoid reentrance! + //find another name in short format: this ensures the actual short name WILL be renamed as well! + unrelatedFileParked = findUnused8Dot3Name(filename); - //schedule cleanup; the file system should assign this unrelated file a new (unique) short name - Loki::ScopeGuard guard = Loki::MakeGuard(renameFileInternal, parkedTarget, unrelatedPathLong);//equivalent to Boost.ScopeExit in this case - (void)guard; //silence warning "unused variable" + //move already existing short name out of the way for now + renameFile_sub(unrelatedFile, unrelatedFileParked); //throw FileError, ErrorDifferentVolume + //DON'T call renameFile() to avoid reentrance! + } - renameFileInternal(oldName, newName); //the short filename name clash is solved, this should work now - return true; + ~Fix8Dot3NameClash() + { + //the file system should assign this unrelated file a new (unique) short name + try + { + renameFile_sub(unrelatedFileParked, unrelatedFile); //throw FileError, ErrorDifferentVolume } + catch (...) {} } - return false; //issue not fixed -} +private: + Zstring unrelatedFile; + Zstring unrelatedFileParked; +}; #endif } //rename file: no copying!!! -void zen::renameFile(const Zstring& oldName, const Zstring& newName) //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting); +void zen::renameFile(const Zstring& oldName, const Zstring& newName) //throw FileError, ErrorDifferentVolume, ErrorTargetExisting { try { - renameFileInternal(oldName, newName); //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting) + renameFile_sub(oldName, newName); //throw FileError, ErrorDifferentVolume, ErrorTargetExisting } catch (const FileError&) { #ifdef FFS_WIN - if (fix8Dot3NameClash(oldName, newName)) //throw (FileError); try to handle issues with already existing short 8.3 file names on Windows 7 + //try to handle issues with already existing short 8.3 file names on Windows + if (have8dot3NameClash(newName)) + { + Fix8Dot3NameClash dummy(newName); //move clashing filename to the side + //now try again... + renameFile_sub(oldName, newName); //throw FileError return; + } #endif throw; } @@ -458,12 +513,15 @@ public: } private: + CopyCallbackImpl(const CopyCallbackImpl&); + CopyCallbackImpl& operator=(const CopyCallbackImpl&); + const Zstring sourceFile_; CallbackMoveFile& moveCallback; }; -void zen::moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); +void zen::moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback) //throw FileError; { //call back once per file (moveFile() is called by moveDirectory()) if (callback) @@ -480,24 +538,24 @@ void zen::moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ig //try to move the file directly without copying try { - renameFile(sourceFile, targetFile); //throw (FileError: ErrorDifferentVolume); + renameFile(sourceFile, targetFile); //throw FileError, ErrorDifferentVolume return; //great, we get away cheaply! } //if moving failed treat as error (except when it tried to move to a different volume: in this case we will copy the file) catch (const ErrorDifferentVolume&) {} //file is on a different volume: let's copy it - std::auto_ptr<CopyCallbackImpl> copyCallback(callback != NULL ? new CopyCallbackImpl(sourceFile, *callback) : NULL); + std::unique_ptr<CopyCallbackImpl> copyCallback(callback != NULL ? new CopyCallbackImpl(sourceFile, *callback) : NULL); if (symlinkExists(sourceFile)) - copySymlink(sourceFile, targetFile, SYMLINK_TYPE_FILE, false); //throw (FileError) dont copy filesystem permissions + copySymlink(sourceFile, targetFile, false); //throw FileError; don't copy filesystem permissions else - copyFile(sourceFile, targetFile, false, true, copyCallback.get()); //throw (FileError); + copyFile(sourceFile, targetFile, false, true, copyCallback.get()); //throw FileError; //attention: if copy-operation was cancelled an exception is thrown => sourcefile is not deleted, as we wish! } - removeFile(sourceFile); //throw (FileError) + removeFile(sourceFile); //throw FileError //note: copying file is NOT undone in case of exception: currently this function is called in context of user-defined deletion dir, where this behavior is fine } @@ -535,6 +593,9 @@ public: virtual HandleError onError(const std::wstring& errorText) { throw FileError(errorText); } private: + TraverseOneLevel(const TraverseOneLevel&); + TraverseOneLevel& operator=(const TraverseOneLevel&); + NameList& files_; NameList& dirs_; }; @@ -547,22 +608,21 @@ struct RemoveCallbackImpl : public CallbackRemoveDir sourceDir_(sourceDir), moveCallback_(moveCallback) {} - virtual void notifyDeletion(const Zstring& currentObject) - { - moveCallback_.requestUiRefresh(sourceDir_); - } + virtual void notifyFileDeletion(const Zstring& filename) { moveCallback_.requestUiRefresh(sourceDir_); } + virtual void notifyDirDeletion(const Zstring& dirname) { moveCallback_.requestUiRefresh(sourceDir_); } private: + RemoveCallbackImpl(const RemoveCallbackImpl&); + RemoveCallbackImpl& operator=(const RemoveCallbackImpl&); + const Zstring sourceDir_; CallbackMoveFile& moveCallback_; }; } -void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); +void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw FileError; { - using namespace zen; - //call back once per folder if (callback) callback->requestUiRefresh(sourceDir); @@ -580,7 +640,7 @@ void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool //first try to move the directory directly without copying try { - renameFile(sourceDir, targetDir); //throw (FileError: ErrorDifferentVolume, ErrorTargetExisting); + renameFile(sourceDir, targetDir); //throw FileError, ErrorDifferentVolume, ErrorTargetExisting return; //great, we get away cheaply! } //if moving failed treat as error (except when it tried to move to a different volume: in this case we will copy the directory) @@ -588,9 +648,9 @@ void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool //create target if (isSymlink) - copySymlink(sourceDir, targetDir, SYMLINK_TYPE_DIR, false); //throw (FileError) -> don't copy permissions + copySymlink(sourceDir, targetDir, false); //throw FileError -> don't copy permissions else - createDirectory(targetDir, sourceDir, false); //throw (FileError) + createDirectory(targetDir, sourceDir, false); //throw FileError } if (!isSymlink) //handle symbolic links @@ -609,7 +669,7 @@ void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool //move files for (TraverseOneLevel::NameList::const_iterator i = fileList.begin(); i != fileList.end(); ++i) - moveFile(i->second, targetDirFormatted + i->first, ignoreExisting, callback); //throw (FileError: ErrorTargetExisting); + moveFile(i->second, targetDirFormatted + i->first, ignoreExisting, callback); //throw FileError, ErrorTargetExisting //move directories for (TraverseOneLevel::NameList::const_iterator i = dirList.begin(); i != dirList.end(); ++i) @@ -619,12 +679,12 @@ void moveDirectoryImpl(const Zstring& sourceDir, const Zstring& targetDir, bool } //delete source - std::auto_ptr<RemoveCallbackImpl> removeCallback(callback != NULL ? new RemoveCallbackImpl(sourceDir, *callback) : NULL); - removeDirectory(sourceDir, removeCallback.get()); //throw (FileError); + std::unique_ptr<RemoveCallbackImpl> removeCallback(callback != NULL ? new RemoveCallbackImpl(sourceDir, *callback) : NULL); + removeDirectory(sourceDir, removeCallback.get()); //throw FileError; } -void zen::moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw (FileError); +void zen::moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback) //throw FileError; { #ifdef FFS_WIN const Zstring& sourceDirFormatted = sourceDir; @@ -671,6 +731,9 @@ public: virtual HandleError onError(const std::wstring& errorText) { throw FileError(errorText); } private: + FilesDirsOnlyTraverser(const FilesDirsOnlyTraverser&); + FilesDirsOnlyTraverser& operator=(const FilesDirsOnlyTraverser&); + std::vector<Zstring>& m_files; std::vector<Zstring>& m_dirs; }; @@ -699,7 +762,8 @@ void zen::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback) #endif throw FileError(_("Error deleting directory:") + "\n\"" + directory + "\"" + "\n\n" + getLastErrorFormatted()); - if (callback) callback->notifyDeletion(directory); //once per symlink + if (callback) + callback->notifyDirDeletion(directory); //once per symlink return; } @@ -714,7 +778,8 @@ void zen::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback) for (std::vector<Zstring>::const_iterator i = fileList.begin(); i != fileList.end(); ++i) { const bool workDone = removeFile(*i); - if (callback && workDone) callback->notifyDeletion(*i); //call once per file + if (callback && workDone) + callback->notifyFileDeletion(*i); //call once per file } //delete directories recursively @@ -730,76 +795,25 @@ void zen::removeDirectory(const Zstring& directory, CallbackRemoveDir* callback) { throw FileError(_("Error deleting directory:") + "\n\"" + directory + "\"" + "\n\n" + getLastErrorFormatted()); } - if (callback) callback->notifyDeletion(directory); //and once per folder + if (callback) + callback->notifyDirDeletion(directory); //and once per folder } -void zen::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, bool deRefSymlinks) //throw (FileError) +void zen::setFileTime(const Zstring& filename, const Int64& modificationTime, ProcSymlink procSl) //throw FileError { #ifdef FFS_WIN - FILETIME creationTime = {}; - FILETIME lastWriteTime = {}; + FILETIME creationTime = {}; + FILETIME lastWriteTime = tofiletime(modificationTime); + //####################################### DST hack ########################################### + if (dst::isFatDrive(filename)) //throw() { - WIN32_FILE_ATTRIBUTE_DATA sourceAttr = {}; - if (!::GetFileAttributesEx(applyLongPathPrefix(sourceObj).c_str(), //__in LPCTSTR lpFileName, - GetFileExInfoStandard, //__in GET_FILEEX_INFO_LEVELS fInfoLevelId, - &sourceAttr)) //__out LPVOID lpFileInformation - throw FileError(_("Error reading file attributes:") + "\n\"" + sourceObj + "\"" + "\n\n" + getLastErrorFormatted()); - - const bool isReparsePoint = (sourceAttr.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; - const bool isDirectory = (sourceAttr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; - - if (isReparsePoint && deRefSymlinks) //we have a symlink AND need to dereference... - { - HANDLE hSource = ::CreateFile(applyLongPathPrefix(sourceObj).c_str(), - FILE_READ_ATTRIBUTES, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, //needed to open a directory; no FILE_FLAG_OPEN_REPARSE_POINT => deref symlinks - NULL); - if (hSource == INVALID_HANDLE_VALUE) - throw FileError(_("Error reading file attributes:") + "\n\"" + sourceObj + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hSource); - (void)dummy; //silence warning "unused variable" - - if (!::GetFileTime(hSource, //__in HANDLE hFile, - &creationTime, //__out_opt LPFILETIME lpCreationTime, - NULL, //__out_opt LPFILETIME lpLastAccessTime, - &lastWriteTime)) //__out_opt LPFILETIME lpLastWriteTime - throw FileError(_("Error reading file attributes:") + "\n\"" + sourceObj + "\"" + "\n\n" + getLastErrorFormatted()); - } - else - { - creationTime = sourceAttr.ftCreationTime; - lastWriteTime = sourceAttr.ftLastWriteTime; - } - - //####################################### DST hack ########################################### - if (!isDirectory) //dst hack not (yet) required for directories (symlinks implicitly checked by isFatDrive()) - { - if (dst::isFatDrive(sourceObj)) //throw() - { - const dst::RawTime rawTime(creationTime, lastWriteTime); - if (dst::fatHasUtcEncoded(rawTime)) //throw (std::runtime_error) - { - lastWriteTime = dst::fatDecodeUtcTime(rawTime); //return last write time in real UTC, throw (std::runtime_error) - ::GetSystemTimeAsFileTime(&creationTime); //real creation time information is not available... - } - } - - if (dst::isFatDrive(targetObj)) //throw() - { - const dst::RawTime encodedTime = dst::fatEncodeUtcTime(lastWriteTime); //throw (std::runtime_error) - creationTime = encodedTime.createTimeRaw; - lastWriteTime = encodedTime.writeTimeRaw; - } - } - //####################################### DST hack ########################################### + const dst::RawTime encodedTime = dst::fatEncodeUtcTime(lastWriteTime); //throw (std::runtime_error) + creationTime = encodedTime.createTimeRaw; + lastWriteTime = encodedTime.writeTimeRaw; } - + //####################################### DST hack ########################################### //privilege SE_BACKUP_NAME doesn't seem to be required here for symbolic links //note: setting privileges requires admin rights! @@ -815,20 +829,20 @@ void zen::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, bool */ //may need to remove the readonly-attribute (e.g. FAT usb drives) - FileUpdateHandle targetHandle(targetObj, [=]() + FileUpdateHandle targetHandle(filename, [ = ]() { - return ::CreateFile(applyLongPathPrefix(targetObj).c_str(), - FILE_GENERIC_WRITE, //ATTENTION: although FILE_WRITE_ATTRIBUTES should(!) be sufficient, this may leads to access denied on NAS shares, unless we specify FILE_GENERIC_WRITE + return ::CreateFile(applyLongPathPrefix(filename).c_str(), + GENERIC_READ | GENERIC_WRITE, //use both when writing over network, see comment in file_io.cpp FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | //needed to open a directory - (deRefSymlinks ? 0 : FILE_FLAG_OPEN_REPARSE_POINT), //process symlinks + (procSl == SYMLINK_DIRECT ? FILE_FLAG_OPEN_REPARSE_POINT : 0), //process symlinks NULL); }); if (targetHandle.get() == INVALID_HANDLE_VALUE) - throw FileError(_("Error changing modification time:") + "\n\"" + targetObj + "\"" + "\n\n" + getLastErrorFormatted()); + throw FileError(_("Error changing modification time:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); /* if (hTarget == INVALID_HANDLE_VALUE && ::GetLastError() == ERROR_SHARING_VIOLATION) @@ -838,17 +852,19 @@ void zen::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, bool } */ + auto isNullTime = [](const FILETIME & ft) { return ft.dwLowDateTime == 0 && ft.dwHighDateTime == 0; }; + if (!::SetFileTime(targetHandle.get(), - &creationTime, + isNullTime(creationTime) ? NULL : &creationTime, NULL, &lastWriteTime)) - throw FileError(_("Error changing modification time:") + "\n\"" + targetObj + "\"" + "\n\n" + getLastErrorFormatted()); + throw FileError(_("Error changing modification time:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); #ifndef NDEBUG //dst hack: verify data written - if (dst::isFatDrive(targetObj) && !dirExists(targetObj)) //throw() + if (dst::isFatDrive(filename) && !dirExists(filename)) //throw() { WIN32_FILE_ATTRIBUTE_DATA debugeAttr = {}; - assert(::GetFileAttributesEx(applyLongPathPrefix(targetObj).c_str(), //__in LPCTSTR lpFileName, + assert(::GetFileAttributesEx(applyLongPathPrefix(filename).c_str(), //__in LPCTSTR lpFileName, GetFileExInfoStandard, //__in GET_FILEEX_INFO_LEVELS fInfoLevelId, &debugeAttr)); //__out LPVOID lpFileInformation @@ -858,35 +874,27 @@ void zen::copyFileTimes(const Zstring& sourceObj, const Zstring& targetObj, bool #endif #elif defined FFS_LINUX - if (deRefSymlinks) + if (procSl == SYMLINK_FOLLOW) { - struct stat objInfo = {}; - if (::stat(sourceObj.c_str(), &objInfo) != 0) //read file attributes from source directory - throw FileError(_("Error reading file attributes:") + "\n\"" + sourceObj + "\"" + "\n\n" + getLastErrorFormatted()); - struct utimbuf newTimes = {}; - newTimes.actime = objInfo.st_atime; - newTimes.modtime = objInfo.st_mtime; + newTimes.actime = ::time(NULL); + newTimes.modtime = to<time_t>(modificationTime); - //(try to) set new "last write time" - if (::utime(targetObj.c_str(), &newTimes) != 0) //return value not evaluated! - throw FileError(_("Error changing modification time:") + "\n\"" + targetObj + "\"" + "\n\n" + getLastErrorFormatted()); + // set new "last write time" + if (::utime(filename.c_str(), &newTimes) != 0) + throw FileError(_("Error changing modification time:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); } else { - struct stat objInfo = {}; - if (::lstat(sourceObj.c_str(), &objInfo) != 0) //read file attributes from source directory - throw FileError(_("Error reading file attributes:") + "\n\"" + sourceObj + "\"" + "\n\n" + getLastErrorFormatted()); - struct timeval newTimes[2] = {}; - newTimes[0].tv_sec = objInfo.st_atime; /* seconds */ - newTimes[0].tv_usec = 0; /* microseconds */ + newTimes[0].tv_sec = ::time(NULL); /* seconds */ + newTimes[0].tv_usec = 0; /* microseconds */ - newTimes[1].tv_sec = objInfo.st_mtime; /* seconds */ - newTimes[1].tv_usec = 0; /* microseconds */ + newTimes[1].tv_sec = to<time_t>(modificationTime); + newTimes[1].tv_usec = 0; - if (::lutimes(targetObj.c_str(), newTimes) != 0) //return value not evaluated! - throw FileError(_("Error changing modification time:") + "\n\"" + targetObj + "\"" + "\n\n" + getLastErrorFormatted()); + if (::lutimes(filename.c_str(), newTimes) != 0) + throw FileError(_("Error changing modification time:") + "\n\"" + filename + "\"" + "\n\n" + getLastErrorFormatted()); } #endif } @@ -901,56 +909,50 @@ Zstring resolveDirectorySymlink(const Zstring& dirLinkName) //get full target pa const HANDLE hDir = ::CreateFile(applyLongPathPrefix(dirLinkName).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, //needed to open a directory NULL); if (hDir == INVALID_HANDLE_VALUE) throw FileError(_("Error resolving symbolic link:") + "\n\"" + dirLinkName + "\"" + "\n\n" + getLastErrorFormatted()); + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hDir)); - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hDir); - (void)dummy; //silence warning "unused variable" - - const size_t BUFFER_SIZE = 10000; - TCHAR targetPath[BUFFER_SIZE]; + const DWORD BUFFER_SIZE = 10000; + std::vector<wchar_t> targetPath(BUFFER_SIZE); //dynamically load windows API function - typedef DWORD (WINAPI *GetFinalPathNameByHandleWFunc)( - HANDLE hFile, - LPTSTR lpszFilePath, - DWORD cchFilePath, - DWORD dwFlags); - const GetFinalPathNameByHandleWFunc getFinalPathNameByHandle = - util::getDllFun<GetFinalPathNameByHandleWFunc>(L"kernel32.dll", "GetFinalPathNameByHandleW"); - - if (getFinalPathNameByHandle == NULL) + typedef DWORD (WINAPI *GetFinalPathNameByHandleWFunc)(HANDLE hFile, + LPTSTR lpszFilePath, + DWORD cchFilePath, + DWORD dwFlags); + const util::DllFun<GetFinalPathNameByHandleWFunc> getFinalPathNameByHandle(L"kernel32.dll", "GetFinalPathNameByHandleW"); + if (!getFinalPathNameByHandle) throw FileError(_("Error loading library function:") + "\n\"" + "GetFinalPathNameByHandleW" + "\""); - const DWORD rv = getFinalPathNameByHandle( - hDir, //__in HANDLE hFile, - targetPath, //__out LPTSTR lpszFilePath, - BUFFER_SIZE,//__in DWORD cchFilePath, - 0); //__in DWORD dwFlags - if (rv >= BUFFER_SIZE || rv == 0) + const DWORD charsWritten = getFinalPathNameByHandle(hDir, //__in HANDLE hFile, + &targetPath[0], //__out LPTSTR lpszFilePath, + BUFFER_SIZE, //__in DWORD cchFilePath, + FILE_NAME_NORMALIZED); //__in DWORD dwFlags + if (charsWritten >= BUFFER_SIZE || charsWritten == 0) { std::wstring errorMessage = _("Error resolving symbolic link:") + "\n\"" + dirLinkName + "\""; - if (rv == 0) + if (charsWritten == 0) errorMessage += L"\n\n" + getLastErrorFormatted(); throw FileError(errorMessage); } - return targetPath; + return Zstring(&targetPath[0], charsWritten); } #endif #ifdef HAVE_SELINUX //copy SELinux security context -void copySecurityContext(const Zstring& source, const Zstring& target, bool derefSymlinks) //throw (FileError) +void copySecurityContext(const Zstring& source, const Zstring& target, ProcSymlink procSl) //throw FileError { security_context_t contextSource = NULL; - const int rv = derefSymlinks ? - ::getfilecon (source.c_str(), &contextSource) : + const int rv = procSl == SYMLINK_FOLLOW ? + ::getfilecon(source.c_str(), &contextSource) : ::lgetfilecon(source.c_str(), &contextSource); if (rv < 0) { @@ -960,13 +962,12 @@ void copySecurityContext(const Zstring& source, const Zstring& target, bool dere throw FileError(_("Error reading security context:") + "\n\"" + source + "\"" + "\n\n" + getLastErrorFormatted()); } - Loki::ScopeGuard dummy1 = Loki::MakeGuard(::freecon, contextSource); - (void)dummy1; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::freecon(contextSource)); { security_context_t contextTarget = NULL; - const int rv2 = derefSymlinks ? - ::getfilecon (target.c_str(), &contextTarget) : + const int rv2 = procSl == SYMLINK_FOLLOW ? + ::getfilecon(target.c_str(), &contextTarget) : ::lgetfilecon(target.c_str(), &contextTarget); if (rv2 < 0) { @@ -976,16 +977,15 @@ void copySecurityContext(const Zstring& source, const Zstring& target, bool dere } else { - Loki::ScopeGuard dummy2 = Loki::MakeGuard(::freecon, contextTarget); - (void)dummy2; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::freecon(contextTarget)); if (::strcmp(contextSource, contextTarget) == 0) //nothing to do return; } } - const int rv3 = derefSymlinks ? - ::setfilecon (target.c_str(), contextSource) : + const int rv3 = procSl == SYMLINK_FOLLOW ? + ::setfilecon(target.c_str(), contextSource) : ::lsetfilecon(target.c_str(), contextSource); if (rv3 < 0) throw FileError(_("Error writing security context:") + "\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted()); @@ -994,7 +994,7 @@ void copySecurityContext(const Zstring& source, const Zstring& target, bool dere //copy permissions for files, directories or symbolic links: requires admin rights -void copyObjectPermissions(const Zstring& source, const Zstring& target, bool derefSymlinks) //throw (FileError); +void copyObjectPermissions(const Zstring& source, const Zstring& target, ProcSymlink procSl) //throw FileError; { #ifdef FFS_WIN //setting privileges requires admin rights! @@ -1024,15 +1024,13 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de const HANDLE hSource = ::CreateFile(applyLongPathPrefix(source).c_str(), READ_CONTROL | ACCESS_SYSTEM_SECURITY, //ACCESS_SYSTEM_SECURITY required for SACL access FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | (derefSymlinks ? 0 : FILE_FLAG_OPEN_REPARSE_POINT), //FILE_FLAG_BACKUP_SEMANTICS needed to open a directory + FILE_FLAG_BACKUP_SEMANTICS | (procSl == SYMLINK_DIRECT ? FILE_FLAG_OPEN_REPARSE_POINT : 0), //FILE_FLAG_BACKUP_SEMANTICS needed to open a directory NULL); if (hSource == INVALID_HANDLE_VALUE) throw FileError(_("Error copying file permissions:") + "\n\"" + source + "\" ->\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted() + " (OR)"); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hSource); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hSource)); // DWORD rc = ::GetNamedSecurityInfo(const_cast<WCHAR*>(applyLongPathPrefix(source).c_str()), -> does NOT dereference symlinks! DWORD rc = ::GetSecurityInfo(hSource, //__in LPTSTR pObjectName, @@ -1045,20 +1043,17 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de &buffer); //__out_opt PSECURITY_DESCRIPTOR *ppSecurityDescriptor if (rc != ERROR_SUCCESS) throw FileError(_("Error copying file permissions:") + "\n\"" + source + "\" ->\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted(rc) + " (R)"); - - Loki::ScopeGuard dummy4 = Loki::MakeGuard(::LocalFree, buffer); - (void)dummy4; //silence warning "unused variable" - + LOKI_ON_BLOCK_EXIT2(::LocalFree(buffer)); //may need to remove the readonly-attribute (e.g. FAT usb drives) - FileUpdateHandle targetHandle(target, [=]() + FileUpdateHandle targetHandle(target, [ = ]() { - return ::CreateFile(applyLongPathPrefix(target).c_str(), // lpFileName - FILE_GENERIC_WRITE | WRITE_OWNER | WRITE_DAC | ACCESS_SYSTEM_SECURITY, // dwDesiredAccess: all four seem to be required!!! - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, // dwShareMode - NULL, // lpSecurityAttributes + return ::CreateFile(applyLongPathPrefix(target).c_str(), // lpFileName + GENERIC_WRITE | WRITE_OWNER | WRITE_DAC | ACCESS_SYSTEM_SECURITY, // dwDesiredAccess: all four seem to be required!!! + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, // dwShareMode + 0, // lpSecurityAttributes OPEN_EXISTING, // dwCreationDisposition - FILE_FLAG_BACKUP_SEMANTICS | (derefSymlinks ? 0 : FILE_FLAG_OPEN_REPARSE_POINT), // dwFlagsAndAttributes + FILE_FLAG_BACKUP_SEMANTICS | (procSl == SYMLINK_DIRECT ? FILE_FLAG_OPEN_REPARSE_POINT : 0), // dwFlagsAndAttributes NULL); // hTemplateFile }); @@ -1066,14 +1061,13 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de throw FileError(_("Error copying file permissions:") + "\n\"" + source + "\" ->\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted() + " (OW)"); // rc = ::SetNamedSecurityInfo(const_cast<WCHAR*>(applyLongPathPrefix(target).c_str()), //__in LPTSTR pObjectName, -> does NOT dereference symlinks! - rc = ::SetSecurityInfo( - targetHandle.get(), //__in LPTSTR pObjectName, - SE_FILE_OBJECT, //__in SE_OBJECT_TYPE ObjectType, - OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, //__in SECURITY_INFORMATION SecurityInfo, - owner, //__in_opt PSID psidOwner, - group, //__in_opt PSID psidGroup, - dacl, //__in_opt PACL pDacl, - sacl); //__in_opt PACL pSacl + rc = ::SetSecurityInfo(targetHandle.get(), //__in LPTSTR pObjectName, + SE_FILE_OBJECT, //__in SE_OBJECT_TYPE ObjectType, + OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, //__in SECURITY_INFORMATION SecurityInfo, + owner, //__in_opt PSID psidOwner, + group, //__in_opt PSID psidGroup, + dacl, //__in_opt PACL pDacl, + sacl); //__in_opt PACL pSacl if (rc != ERROR_SUCCESS) throw FileError(_("Error copying file permissions:") + "\n\"" + source + "\" ->\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted(rc) + " (W)"); @@ -1081,21 +1075,20 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de #elif defined FFS_LINUX #ifdef HAVE_SELINUX //copy SELinux security context - copySecurityContext(source, target, derefSymlinks); //throw (FileError) + copySecurityContext(source, target, procSl); //throw FileError #endif - if (derefSymlinks) + struct stat fileInfo = {}; + if (procSl == SYMLINK_FOLLOW) { - struct stat fileInfo = {}; - if (::stat (source.c_str(), &fileInfo) != 0 || + if (::stat(source.c_str(), &fileInfo) != 0 || ::chown(target.c_str(), fileInfo.st_uid, fileInfo.st_gid) != 0 || // may require admin rights! ::chmod(target.c_str(), fileInfo.st_mode) != 0) throw FileError(_("Error copying file permissions:") + "\n\"" + source + "\" ->\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted() + " (R)"); } else { - struct stat fileInfo = {}; - if (::lstat (source.c_str(), &fileInfo) != 0 || + if (::lstat(source.c_str(), &fileInfo) != 0 || ::lchown(target.c_str(), fileInfo.st_uid, fileInfo.st_gid) != 0 || // may require admin rights! (!symlinkExists(target) && ::chmod(target.c_str(), fileInfo.st_mode) != 0)) //setting access permissions doesn't make sense for symlinks on Linux: there is no lchmod() throw FileError(_("Error copying file permissions:") + "\n\"" + source + "\" ->\n\"" + target + "\"" + "\n\n" + getLastErrorFormatted() + " (W)"); @@ -1104,35 +1097,8 @@ void copyObjectPermissions(const Zstring& source, const Zstring& target, bool de } -namespace -{ -//provide uniform binary interface: -void removeDirSimple(const Zstring& directory) { removeDirectory(directory); } //throw (FileError) -void removeFileSimple(const Zstring& filename) { removeFile(filename); } //throw (FileError) -} - - -void createDirectoryRecursively(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions, int level) +void createDirectory_straight(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions, int level) { - using namespace zen; - - if (dirExists(directory)) - return; - - if (level == 100) //catch endless recursion - return; - - //try to create parent folders first - const Zstring dirParent = directory.BeforeLast(FILE_NAME_SEPARATOR); - if (!dirParent.empty() && !dirExists(dirParent)) - { - //call function recursively - const Zstring templateParent = templateDir.BeforeLast(FILE_NAME_SEPARATOR); - createDirectoryRecursively(dirParent, templateParent, copyFilePermissions, level + 1); - } - - //now creation should be possible - //default directory creation #ifdef FFS_WIN //don't use ::CreateDirectoryEx: @@ -1159,11 +1125,11 @@ void createDirectoryRecursively(const Zstring& directory, const Zstring& templat try { //get target directory of symbolic link - sourcePath = resolveDirectorySymlink(templateDir); //throw (FileError) + sourcePath = resolveDirectorySymlink(templateDir); //throw FileError } catch (FileError&) {} //dereferencing a symbolic link usually fails if it is located on network drive or client is XP: NOT really an error... } - else //no symbolic link + else //no symbolic link sourcePath = templateDir; //try to copy file attributes @@ -1185,14 +1151,13 @@ void createDirectoryRecursively(const Zstring& directory, const Zstring& templat HANDLE hDir = ::CreateFile(applyLongPathPrefix(directory).c_str(), GENERIC_READ | GENERIC_WRITE, //read access required for FSCTL_SET_COMPRESSION FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (hDir != INVALID_HANDLE_VALUE) { - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hDir); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hDir)); USHORT cmpState = COMPRESSION_FORMAT_DEFAULT; @@ -1210,23 +1175,51 @@ void createDirectoryRecursively(const Zstring& directory, const Zstring& templat } } #endif - - //try to copy file times: NOT mission critical for a directory, since modification time is changed on each added, deleted file, however creation time will stay - try - { - copyFileTimes(templateDir, directory, true); //throw (FileError) - } - catch (FileError&) {} - - Loki::ScopeGuard guardNewDir = Loki::MakeGuard(&removeDirSimple, directory); //ensure cleanup: + Loki::ScopeGuard guardNewDir = Loki::MakeGuard([&]() { removeDirectory(directory); }); //ensure cleanup: //enforce copying file permissions: it's advertized on GUI... if (copyFilePermissions) - copyObjectPermissions(templateDir, directory, true); //throw (FileError) + copyObjectPermissions(templateDir, directory, SYMLINK_FOLLOW); //throw FileError guardNewDir.Dismiss(); //target has been created successfully! } } + + +void createDirectoryRecursively(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions, int level) +{ + if (level == 100) //catch endless recursion + return; + +#ifdef FFS_WIN + std::unique_ptr<Fix8Dot3NameClash> fnc; + if (somethingExists(directory)) + { + //handle issues with already existing short 8.3 file names on Windows + if (have8dot3NameClash(directory)) + fnc.reset(new Fix8Dot3NameClash(directory)); //move clashing object to the side + else if (dirExists(directory)) + return; + } +#elif defined FFS_LINUX + if (dirExists(directory)) + return; +#endif + else //if "somethingExists" we needn't create the parent directory + { + //try to create parent folders first + const Zstring dirParent = directory.BeforeLast(FILE_NAME_SEPARATOR); + if (!dirParent.empty() && !dirExists(dirParent)) + { + //call function recursively + const Zstring templateParent = templateDir.BeforeLast(FILE_NAME_SEPARATOR); //returns empty string if ch not found + createDirectoryRecursively(dirParent, templateParent, copyFilePermissions, level + 1); + } + } + + //now creation should be possible + createDirectory_straight(directory, templateDir, copyFilePermissions, level); //throw FileError +} } @@ -1251,38 +1244,51 @@ void zen::createDirectory(const Zstring& directory) } -void zen::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, zen::SymlinkType type, bool copyFilePermissions) //throw (FileError) +void zen::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, bool copyFilePermissions) //throw FileError { - const Zstring linkPath = getSymlinkRawTargetString(sourceLink); //accept broken symlinks; throw (FileError) + const Zstring linkPath = getSymlinkRawTargetString(sourceLink); //accept broken symlinks; throw FileError #ifdef FFS_WIN + const bool isDirLink = [&]() -> bool + { + const DWORD ret = ::GetFileAttributes(applyLongPathPrefix(sourceLink).c_str()); + return ret != INVALID_FILE_ATTRIBUTES && (ret& FILE_ATTRIBUTE_DIRECTORY); + }(); + //dynamically load windows API function typedef BOOLEAN (WINAPI *CreateSymbolicLinkFunc)(LPCTSTR lpSymlinkFileName, LPCTSTR lpTargetFileName, DWORD dwFlags); - const CreateSymbolicLinkFunc createSymbolicLink = util::getDllFun<CreateSymbolicLinkFunc>(L"kernel32.dll", "CreateSymbolicLinkW"); - if (createSymbolicLink == NULL) - throw FileError(_("Error loading library function:") + "\n\"" + "CreateSymbolicLinkW" + "\""); - if (!createSymbolicLink( //seems no long path prefix is required... - targetLink.c_str(), //__in LPTSTR lpSymlinkFileName, - linkPath.c_str(), //__in LPTSTR lpTargetFileName, - (type == SYMLINK_TYPE_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0))) //__in DWORD dwFlags - throw FileError(_("Error copying symbolic link:") + "\n\"" + sourceLink + "\" ->\n\"" + targetLink + "\"" + "\n\n" + getLastErrorFormatted()); + const util::DllFun<CreateSymbolicLinkFunc> createSymbolicLink(L"kernel32.dll", "CreateSymbolicLinkW"); + if (!createSymbolicLink) + throw FileError(_("Error loading library function:") + "\n\"" + "CreateSymbolicLinkW" + "\""); + if (!createSymbolicLink(targetLink.c_str(), //__in LPTSTR lpSymlinkFileName, - seems no long path prefix is required... + linkPath.c_str(), //__in LPTSTR lpTargetFileName, + (isDirLink ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0))) //__in DWORD dwFlags #elif defined FFS_LINUX if (::symlink(linkPath.c_str(), targetLink.c_str()) != 0) - throw FileError(_("Error copying symbolic link:") + "\n\"" + sourceLink + "\" ->\n\"" + targetLink + "\"" + "\n\n" + getLastErrorFormatted()); #endif + throw FileError(_("Error copying symbolic link:") + "\n\"" + sourceLink + "\" ->\n\"" + targetLink + "\"" + "\n\n" + getLastErrorFormatted()); //allow only consistent objects to be created -> don't place before ::symlink, targetLink may already exist - Loki::ScopeGuard guardNewDir = type == SYMLINK_TYPE_DIR ? - Loki::MakeGuard(&removeDirSimple, targetLink) : - Loki::MakeGuard(&removeFileSimple, targetLink); + Loki::ScopeGuard guardNewDir = Loki::MakeGuard([&]() + { +#ifdef FFS_WIN + if (isDirLink) + removeDirectory(targetLink); + else +#endif + removeFile(targetLink); + }); //file times: essential for a symlink: enforce this! (don't just try!) - copyFileTimes(sourceLink, targetLink, false); //throw (FileError) + { + const Int64 modTime = getFileTime(sourceLink, SYMLINK_DIRECT); //throw FileError + setFileTime(targetLink, modTime, SYMLINK_DIRECT); //throw FileError + } if (copyFilePermissions) - copyObjectPermissions(sourceLink, targetLink, false); //throw (FileError) + copyObjectPermissions(sourceLink, targetLink, SYMLINK_DIRECT); //throw FileError guardNewDir.Dismiss(); //target has been created successfully! } @@ -1302,16 +1308,57 @@ Zstring createTempName(const Zstring& filename) } #ifdef FFS_WIN -struct CallbackData +class CallbackData { - CallbackData(CallbackCopyFile& cb) : - callback(cb), - callNr(0), - exceptionCaught(false) {} - - CallbackCopyFile& callback; - size_t callNr; - bool exceptionCaught; +public: + CallbackData(CallbackCopyFile* cb, //may be NULL + const Zstring& sourceFile, + const Zstring& targetFile, + bool osIsvistaOrLater) : + userCallback(cb), + sourceFile_(sourceFile), + targetFile_(targetFile), + osIsvistaOrLater_(osIsvistaOrLater), + exceptionInUserCallback(false) {} + + CallbackCopyFile* userCallback; //optional! + const Zstring& sourceFile_; + const Zstring& targetFile_; + const bool osIsvistaOrLater_; + + //there is some mixed responsibility in this class, pure read-only data and abstraction for error reporting + //however we need to keep it at one place as ::CopyFileEx() requires! + + void reportUserException(const UInt64& bytesTransferred) + { + exceptionInUserCallback = true; + bytesTransferredOnException = bytesTransferred; + } + + void reportError(const std::wstring& message) { errorMsg = message; } + + void evaluateErrors() //throw + { + if (exceptionInUserCallback) + { + assert(userCallback); + if (userCallback) + userCallback->updateCopyStatus(bytesTransferredOnException); //rethrow (hopefully!) + } + if (!errorMsg.empty()) + throw FileError(errorMsg); + } + + void setSrcAttr(const FileAttrib& attr) { sourceAttr = attr; } + FileAttrib getSrcAttr() const { assert(sourceAttr.modificationTime != 0); return sourceAttr; } + +private: + CallbackData(const CallbackData&); + CallbackData& operator=(const CallbackData&); + + FileAttrib sourceAttr; + std::wstring errorMsg; // + bool exceptionInUserCallback; //these two are exclusive! UInt64 bytesTransferredOnException; }; @@ -1327,36 +1374,81 @@ DWORD CALLBACK copyCallbackInternal( HANDLE hDestinationFile, LPVOID lpData) { - if (lpData) + //this callback is invoked for block sizes managed by Windows, these may vary from e.g. 64 kB up to 1MB. It seems this is dependent from file size amongst others. + + //symlink handling: + //if source is a symlink and COPY_FILE_COPY_SYMLINK is specified, this callback is NOT invoked! + //if source is a symlink and COPY_FILE_COPY_SYMLINK is NOT specified, this callback is called and hSourceFile is a handle to the *target* of the link! + + //file time handling: + //::CopyFileEx() will copy file modification time (only) over from source file AFTER the last inocation of this callback + //=> it is possible to adapt file creation time of target in here, but NOT file modification time! + + CallbackData& cbd = *static_cast<CallbackData*>(lpData); + + //#################### return source file attributes ################################ + if (dwCallbackReason == CALLBACK_STREAM_SWITCH) //called up front for every file (even if 0-sized) { - CallbackData& cbd = *static_cast<CallbackData*>(lpData); + BY_HANDLE_FILE_INFORMATION fileInfo = {}; + if (!::GetFileInformationByHandle(hSourceFile, &fileInfo)) + { + cbd.reportError(_("Error reading file attributes:") + "\n\"" + cbd.sourceFile_ + "\"" + "\n\n" + getLastErrorFormatted()); + return PROGRESS_CANCEL; + } + + const FileAttrib attr = { UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh), + toTimeT(fileInfo.ftLastWriteTime) + }; + //extractFileID(fileInfo)); + + cbd.setSrcAttr(attr); + + //#################### copy file creation time ################################ + FILETIME creationTime = {}; + + if (!::GetFileTime(hSourceFile, //__in HANDLE hFile, + &creationTime, //__out_opt LPFILETIME lpCreationTime, + NULL, //__out_opt LPFILETIME lpLastAccessTime, + NULL)) //__out_opt LPFILETIME lpLastWriteTime + { + cbd.reportError(_("Error reading file attributes:") + "\n\"" + cbd.sourceFile_ + "\"" + "\n\n" + getLastErrorFormatted()); + return PROGRESS_CANCEL; + } - //small performance optimization: it seems this callback function is called for every 64 kB (depending on cluster size). - if (++cbd.callNr % 4 == 0) //executing callback every 256 kB should suffice + if (!::SetFileTime(hDestinationFile, + &creationTime, + NULL, + NULL)) { - //some odd check for some possible(?) error condition - if (totalBytesTransferred.QuadPart < 0) //let's see if someone answers the call... - ::MessageBox(NULL, L"You've just discovered a bug in WIN32 API function \"CopyFileEx\"! \n\n\ + cbd.reportError(_("Error changing modification time:") + "\n\"" + cbd.targetFile_ + "\"" + "\n\n" + getLastErrorFormatted()); + return PROGRESS_CANCEL; + } + //############################################################################## + } + + //if (totalFileSize.QuadPart == totalBytesTransferred.QuadPart) {} //called after copy operation is finished - note: for 0-sized files this callback is invoked just ONCE! + + if (cbd.userCallback) + { + //some odd check for some possible(?) error condition + if (totalBytesTransferred.QuadPart < 0) //let's see if someone answers the call... + ::MessageBox(NULL, L"You've just discovered a bug in WIN32 API function \"CopyFileEx\"! \n\n\ Please write a mail to the author of FreeFileSync at zhnmju123@gmx.de and simply state that\n\ \"totalBytesTransferred.HighPart can be below zero\"!\n\n\ This will then be handled in future versions of FreeFileSync.\n\nThanks -ZenJu", - NULL, 0); - try - { - cbd.callback.updateCopyStatus(UInt64(totalBytesTransferred.QuadPart)); - } - catch (...) - { -#ifndef _MSC_VER -#warning migrate to std::exception_ptr when available -#endif - cbd.exceptionCaught = true; - cbd.bytesTransferredOnException = UInt64(totalBytesTransferred.QuadPart); - return PROGRESS_CANCEL; - } + NULL, 0); + try + { + cbd.userCallback->updateCopyStatus(UInt64(totalBytesTransferred.QuadPart)); } - } + catch (...) + { +//#warning migrate to std::exception_ptr when available + cbd.reportUserException(UInt64(totalBytesTransferred.QuadPart)); + return PROGRESS_CANCEL; + } + } return PROGRESS_CONTINUE; } @@ -1379,36 +1471,43 @@ bool supportForNonEncryptedDestination() } -void rawCopyWinApi(const Zstring& sourceFile, - const Zstring& targetFile, - CallbackCopyFile* callback) //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked) +void rawCopyWinApi_sub(const Zstring& sourceFile, + const Zstring& targetFile, + CallbackCopyFile* callback, + FileAttrib* sourceAttr) //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked { - Loki::ScopeGuard guardTarget = Loki::MakeGuard(&removeFile, targetFile); //transactional behavior: guard just before starting copy! + Loki::ScopeGuard guardTarget = Loki::MakeGuard(&removeFile, targetFile); //transactional behavior: guard just before starting copy, we don't trust ::CopyFileEx(), do we ;) DWORD copyFlags = COPY_FILE_FAIL_IF_EXISTS; //allow copying from encrypted to non-encrytped location - static bool nonEncSupported = false; - static boost::once_flag once = BOOST_ONCE_INIT; //caveat: function scope static initialization is not thread-safe in VS 2010! - boost::call_once(once, []() { nonEncSupported = supportForNonEncryptedDestination(); }); - + { + static boost::once_flag initNonEncOnce = BOOST_ONCE_INIT; //caveat: function scope static initialization is not thread-safe in VS 2010! + boost::call_once(initNonEncOnce, []() { nonEncSupported = supportForNonEncryptedDestination(); }); + } if (nonEncSupported) copyFlags |= COPY_FILE_ALLOW_DECRYPTED_DESTINATION; - std::unique_ptr<CallbackData> cbd(callback ? new CallbackData(*callback) : NULL); - - if (!::CopyFileEx( //same performance like CopyFile() - applyLongPathPrefix(sourceFile).c_str(), - applyLongPathPrefix(targetFile).c_str(), - callback ? copyCallbackInternal : NULL, - cbd.get(), - NULL, - copyFlags)) + static bool osIsvistaOrLater = false; { - if (cbd.get() && cbd->exceptionCaught) - callback->updateCopyStatus(cbd->bytesTransferredOnException); //rethrow (hopefully!) + static boost::once_flag initVistaLaterOnce = BOOST_ONCE_INIT; //caveat: function scope static initialization is not thread-safe in VS 2010! + boost::call_once(initVistaLaterOnce, []() { osIsvistaOrLater = dst::vistaOrLater(); }); + } + + CallbackData cbd(callback, sourceFile, targetFile, osIsvistaOrLater); + const bool success = ::CopyFileEx( //same performance like CopyFile() + applyLongPathPrefix(sourceFile).c_str(), + applyLongPathPrefix(targetFile).c_str(), + copyCallbackInternal, + &cbd, + NULL, + copyFlags) == TRUE; //silence x64 perf warning + + cbd.evaluateErrors(); //throw ?, process errors in callback first! + if (!success) + { const DWORD lastError = ::GetLastError(); //don't suppress "lastError == ERROR_REQUEST_ABORTED": a user aborted operation IS an error condition! @@ -1439,38 +1538,56 @@ void rawCopyWinApi(const Zstring& sourceFile, //trying to copy > 4GB file to FAT/FAT32 volume gives obscure ERROR_INVALID_PARAMETER (FAT can indeed handle files up to 4 Gig, tested!) if (lastError == ERROR_INVALID_PARAMETER && dst::isFatDrive(targetFile) && - getFilesize(sourceFile) >= 4U * UInt64(1024U * 1024 * 1024)) //throw (FileError) + getFilesize(sourceFile) >= 4U * UInt64(1024U * 1024 * 1024)) //throw FileError errorMessage += L"\nFAT volume cannot store files larger than 4 gigabyte!"; //note: ERROR_INVALID_PARAMETER can also occur when copying to a SharePoint server or MS SkyDrive and the target filename is of a restricted type. } - catch(...) {} + catch (...) {} throw FileError(errorMessage); } - try //adapt file modification time - { - //this is optional, since ::CopyFileEx already copies modification time (but not creation time) - //chances are good this also avoids a number of unnecessary access-denied errors on NAS shares! - //(one is: missing permission to change file attributes, remove read-only in particular) - copyFileTimes(sourceFile, targetFile, true); //throw FileError - } - catch (FileError&) + if (sourceAttr) + *sourceAttr = cbd.getSrcAttr(); + { - //CAVEAT: in case one of the drives is FAT, we still(!) need copyFileTimes to apply the DST hack! - if (dst::isFatDrive(sourceFile) || dst::isFatDrive(targetFile)) //throw() - throw; - assert(false); //maybe this catches some test-case left-overs? + const Int64 modTime = getFileTime(sourceFile, SYMLINK_FOLLOW); //throw FileError + setFileTime(targetFile, modTime, SYMLINK_FOLLOW); //throw FileError + //note: this sequence leads to a loss of precision of up to 1 sec! + //perf-loss on USB sticks with many small files of about 30%! damn! } guardTarget.Dismiss(); //target has been created successfully! } +inline +void rawCopyWinApi(const Zstring& sourceFile, + const Zstring& targetFile, + CallbackCopyFile* callback, + FileAttrib* sourceAttr) //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked +{ + try + { + rawCopyWinApi_sub(sourceFile, targetFile, callback, sourceAttr); // throw ... + } + catch (ErrorTargetExisting&) + { + //try to handle issues with already existing short 8.3 file names on Windows + if (have8dot3NameClash(targetFile)) + { + Fix8Dot3NameClash dummy(targetFile); //move clashing filename to the side + rawCopyWinApi_sub(sourceFile, targetFile, callback, sourceAttr); //throw FileError; the short filename name clash is solved, this should work now + return; + } + throw; + } +} + //void rawCopyWinOptimized(const Zstring& sourceFile, // const Zstring& targetFile, -// CallbackCopyFile* callback) //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked) +// CallbackCopyFile* callback) //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked //{ // /* // BackupRead() FileRead() CopyFileEx() @@ -1491,7 +1608,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // HANDLE hFileIn = ::CreateFile(applyLongPathPrefix(sourceFile).c_str(), // GENERIC_READ, // FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //all shared modes are required to read files that are open in other applications -// NULL, +// 0, // OPEN_EXISTING, // FILE_FLAG_SEQUENTIAL_SCAN, // NULL); @@ -1507,8 +1624,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // // throw FileError(errorMessage); // } -// Loki::ScopeGuard dummy1 = Loki::MakeGuard(::CloseHandle, hFileIn); -// (void)dummy1; //silence warning "unused variable" +// LOKI_ON_BLOCK_EXIT2(::CloseHandle, hFileIn); // // // BY_HANDLE_FILE_INFORMATION infoFileIn = {}; @@ -1545,7 +1661,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // HANDLE hFileOut = ::CreateFile(applyLongPathPrefix(targetFile).c_str(), // GENERIC_READ | GENERIC_WRITE, //read access required for FSCTL_SET_COMPRESSION // FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, -// NULL, +// 0, // CREATE_NEW, // (infoFileIn.dwFileAttributes & validAttribs) | FILE_FLAG_SEQUENTIAL_SCAN, // NULL); @@ -1565,8 +1681,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // } // Loki::ScopeGuard guardTarget = Loki::MakeGuard(&removeFile, targetFile); //transactional behavior: guard just after opening target and before managing hFileOut // -// Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hFileOut); -// (void)dummy; //silence warning "unused variable" +// LOKI_ON_BLOCK_EXIT2(::CloseHandle, hFileOut); // // //#ifndef _MSC_VER @@ -1773,7 +1888,7 @@ void rawCopyWinApi(const Zstring& sourceFile, // HANDLE hSparse = ::CreateFile(L"C:\\sparse.file", // GENERIC_READ | GENERIC_WRITE, //read access required for FSCTL_SET_COMPRESSION // FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, -// NULL, +// 0, // CREATE_NEW, // FILE_FLAG_SEQUENTIAL_SCAN, // NULL); @@ -1800,19 +1915,20 @@ void rawCopyWinApi(const Zstring& sourceFile, //} #endif - +#ifdef FFS_LINUX void rawCopyStream(const Zstring& sourceFile, const Zstring& targetFile, - CallbackCopyFile* callback) //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting) + CallbackCopyFile* callback, + FileAttrib* sourceAttr) //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting { Loki::ScopeGuard guardTarget = Loki::MakeGuard(&removeFile, targetFile); //transactional behavior: place guard before lifetime of FileOutput try { //open sourceFile for reading - FileInput fileIn(sourceFile); //throw (FileError) + FileInput fileIn(sourceFile); //throw FileError //create targetFile and open it for writing - FileOutput fileOut(targetFile, FileOutput::ACC_CREATE_NEW); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting) + FileOutput fileOut(targetFile, FileOutput::ACC_CREATE_NEW); //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting static boost::thread_specific_ptr<std::vector<char>> cpyBuf; if (!cpyBuf.get()) @@ -1823,35 +1939,55 @@ void rawCopyStream(const Zstring& sourceFile, UInt64 totalBytesTransferred; do { - const size_t bytesRead = fileIn.read(&buffer[0], buffer.size()); //throw (FileError) + const size_t bytesRead = fileIn.read(&buffer[0], buffer.size()); //throw FileError - fileOut.write(&buffer[0], bytesRead); //throw (FileError) + fileOut.write(&buffer[0], bytesRead); //throw FileError totalBytesTransferred += bytesRead; //invoke callback method to update progress indicators - if (callback != NULL) + if (callback) callback->updateCopyStatus(totalBytesTransferred); } while (!fileIn.eof()); } - catch(ErrorTargetExisting&) + catch (ErrorTargetExisting&) { guardTarget.Dismiss(); //don't delete file that existed previously! throw; } //adapt file modification time: - copyFileTimes(sourceFile, targetFile, true); //throw (FileError) + { + struct stat srcInfo = {}; + if (::stat(sourceFile.c_str(), &srcInfo) != 0) //read file attributes from source directory + throw FileError(_("Error reading file attributes:") + "\n\"" + sourceFile + "\"" + "\n\n" + getLastErrorFormatted()); + + if (sourceAttr) + { + sourceAttr->fileSize = UInt64(srcInfo.st_size); + sourceAttr->modificationTime = srcInfo.st_mtime; + } + + struct utimbuf newTimes = {}; + newTimes.actime = srcInfo.st_atime; + newTimes.modtime = srcInfo.st_mtime; + + //set new "last write time" + if (::utime(targetFile.c_str(), &newTimes) != 0) + throw FileError(_("Error changing modification time:") + "\n\"" + targetFile + "\"" + "\n\n" + getLastErrorFormatted()); + } guardTarget.Dismiss(); //target has been created successfully! } +#endif inline void copyFileImpl(const Zstring& sourceFile, const Zstring& targetFile, - CallbackCopyFile* callback) //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked) + CallbackCopyFile* callback, + FileAttrib* sourceAttr) //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked { #ifdef FFS_WIN /* @@ -1867,21 +2003,22 @@ void copyFileImpl(const Zstring& sourceFile, SAMBA, ect. YES UNKNOWN! -> issues writing ADS to Samba, issues reading from NAS, error copying files having "blocked" state... ect. damn! */ - rawCopyWinApi(sourceFile, targetFile, callback); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked) - //rawCopyWinOptimized(sourceFile, targetFile, callback); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked) ->about 8% faster + rawCopyWinApi(sourceFile, targetFile, callback, sourceAttr); //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked + //rawCopyWinOptimized(sourceFile, targetFile, callback); //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked ->about 8% faster #elif defined FFS_LINUX - rawCopyStream(sourceFile, targetFile, callback); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting) + rawCopyStream(sourceFile, targetFile, callback, sourceAttr); //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting #endif } } -void zen::copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPathMissing, ErrorFileLocked); +void zen::copyFile(const Zstring& sourceFile, //throw FileError, ErrorTargetPathMissing, ErrorFileLocked const Zstring& targetFile, bool copyFilePermissions, bool transactionalCopy, - CallbackCopyFile* callback) + CallbackCopyFile* callback, + FileAttrib* sourceAttr) { if (transactionalCopy) { @@ -1891,7 +2028,7 @@ void zen::copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPat //raw file copy try { - copyFileImpl(sourceFile, temporary, callback); //throw FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked + copyFileImpl(sourceFile, temporary, callback, sourceAttr); //throw FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked } catch (ErrorTargetExisting&) { @@ -1900,40 +2037,39 @@ void zen::copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPat temporary = createTempName(targetFile); //retry - copyFileImpl(sourceFile, temporary, callback); //throw FileError + copyFileImpl(sourceFile, temporary, callback, sourceAttr); //throw FileError } //have target file deleted (after read access on source and target has been confirmed) => allow for almost transactional overwrite - if (callback) callback->deleteTargetFile(targetFile); + if (callback) + callback->deleteTargetFile(targetFile); //rename temporary file: //perf: this call is REALLY expensive on unbuffered volumes! ~40% performance decrease on FAT USB stick! - renameFile(temporary, targetFile); //throw (FileError) + renameFile(temporary, targetFile); //throw FileError guardTempFile.Dismiss(); - - //perf: interestingly it is much faster to apply file times BEFORE renaming temporary! } else { //have target file deleted if (callback) callback->deleteTargetFile(targetFile); - copyFileImpl(sourceFile, targetFile, callback); //throw FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked + copyFileImpl(sourceFile, targetFile, callback, sourceAttr); //throw FileError: ErrorTargetPathMissing, ErrorTargetExisting, ErrorFileLocked } -/* - Note: non-transactional file copy solves at least four problems: - -> skydrive - doesn't allow for .ffs_tmp extension and returns ERROR_INVALID_PARAMETER - -> network renaming issues - -> allow for true delete before copy to handle low disk space problems - -> higher performance on non-buffered drives (e.g. usb sticks) -*/ + /* + Note: non-transactional file copy solves at least four problems: + -> skydrive - doesn't allow for .ffs_tmp extension and returns ERROR_INVALID_PARAMETER + -> network renaming issues + -> allow for true delete before copy to handle low disk space problems + -> higher performance on non-buffered drives (e.g. usb sticks) + */ //set file permissions if (copyFilePermissions) { Loki::ScopeGuard guardTargetFile = Loki::MakeGuard(&removeFile, targetFile); - copyObjectPermissions(sourceFile, targetFile, true); //throw (FileError) + copyObjectPermissions(sourceFile, targetFile, SYMLINK_FOLLOW); //throw FileError guardTargetFile.Dismiss(); //target has been created successfully! } } diff --git a/shared/file_handling.h b/shared/file_handling.h index bdd73bea..f1ed2d98 100644 --- a/shared/file_handling.h +++ b/shared/file_handling.h @@ -33,52 +33,55 @@ enum ResponseSame }; ResponseSame onSameVolume(const Zstring& folderLeft, const Zstring& folderRight); //throw() -void checkthis(const Zstring& folderLeft); //throw() +enum ProcSymlink +{ + SYMLINK_DIRECT, + SYMLINK_FOLLOW +}; -//copy file or directory create/last change date, -void copyFileTimes(const Zstring& sourceDir, const Zstring& targetDir, bool derefSymlinks); //throw (FileError) +Int64 getFileTime(const Zstring& filename, ProcSymlink procSl); //throw FileError +void setFileTime(const Zstring& filename, const Int64& modificationTime, ProcSymlink procSl); //throw FileError //symlink handling: always evaluate target -UInt64 getFilesize(const Zstring& filename); //throw (FileError) - +UInt64 getFilesize(const Zstring& filename); //throw FileError //file handling bool removeFile(const Zstring& filename); //return "true" if file was actually deleted; throw (FileError) -void removeDirectory(const Zstring& directory, CallbackRemoveDir* callback = NULL); //throw (FileError) +void removeDirectory(const Zstring& directory, CallbackRemoveDir* callback = NULL); //throw FileError //rename file or directory: no copying!!! -void renameFile(const Zstring& oldName, const Zstring& newName); //throw (FileError); +void renameFile(const Zstring& oldName, const Zstring& newName); //throw FileError; //move source to target; expectations: all super-directories of target exist //"ignoreExisting": if target already exists, source is deleted -void moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback); //throw (FileError); +void moveFile(const Zstring& sourceFile, const Zstring& targetFile, bool ignoreExisting, CallbackMoveFile* callback); //throw FileError; //move source to target including subdirectories //"ignoreExisting": existing directories and files will be enriched -void moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback); //throw (FileError); +void moveDirectory(const Zstring& sourceDir, const Zstring& targetDir, bool ignoreExisting, CallbackMoveFile* callback); //throw FileError; //creates superdirectories automatically: -void createDirectory(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions); //throw (FileError); -void createDirectory(const Zstring& directory); //throw (FileError); -> function overload avoids default parameter ambiguity issues! +void createDirectory(const Zstring& directory, const Zstring& templateDir, bool copyFilePermissions); //throw FileError; +void createDirectory(const Zstring& directory); //throw FileError; -> function overload avoids default parameter ambiguity issues! +struct FileAttrib +{ + UInt64 fileSize; + Int64 modificationTime; //size_t UTC compatible +}; -void copyFile(const Zstring& sourceFile, //throw (FileError: ErrorTargetPathMissing, ErrorFileLocked (Windows-only)); - const Zstring& targetFile, +void copyFile(const Zstring& sourceFile, //throw FileError, ErrorTargetPathMissing, ErrorFileLocked (Windows-only) + const Zstring& targetFile, //symlink handling: dereference source bool copyFilePermissions, bool transactionalCopy, - CallbackCopyFile* callback); //may be NULL + CallbackCopyFile* callback, //may be NULL + FileAttrib* sourceAttr = NULL); //return current attributes at the time of copy //Note: it MAY happen that copyFile() leaves temp files behind, e.g. temporary network drop. // => clean them up at an appropriate time (automatically set sync directions to delete them). They have the following ending: const Zstring TEMP_FILE_ENDING = Zstr(".ffs_tmp"); -enum SymlinkType -{ - SYMLINK_TYPE_FILE, - SYMLINK_TYPE_DIR -}; -void copySymlink(const Zstring& sourceLink, const Zstring& targetLink, SymlinkType type, bool copyFilePermissions); //throw (FileError) - +void copySymlink(const Zstring& sourceLink, const Zstring& targetLink, bool copyFilePermissions); //throw FileError @@ -87,7 +90,8 @@ void copySymlink(const Zstring& sourceLink, const Zstring& targetLink, SymlinkTy struct CallbackRemoveDir { virtual ~CallbackRemoveDir() {} - virtual void notifyDeletion(const Zstring& currentObject) = 0; + virtual void notifyFileDeletion(const Zstring& filename) = 0; + virtual void notifyDirDeletion(const Zstring& dirname) = 0; }; @@ -101,7 +105,7 @@ struct CallbackCopyFile //callback functionality //may throw: //Linux: unconditionally - //Windows: first exception is swallowed, requestUiRefresh() is then called again where it may throw again and exception will propagate as expected + //Windows: first exception is swallowed, requestUiRefresh() is then called again where it should throw again and exception will propagate as expected virtual void updateCopyStatus(UInt64 totalBytesTransferred) = 0; }; diff --git a/shared/file_id.cpp b/shared/file_id.cpp index e6c016e7..198598b4 100644 --- a/shared/file_id.cpp +++ b/shared/file_id.cpp @@ -5,6 +5,7 @@ // ************************************************************************** #include "file_id.h" +#include "file_id_internal.h" #ifdef FFS_WIN #include <wx/msw/wrapwin.h> //includes "windows.h" @@ -16,21 +17,8 @@ #endif -namespace -{ -template <class T> inline -std::string numberToBytes(T number) -{ - const char* rawBegin = reinterpret_cast<const char*>(&number); - return std::string(rawBegin, rawBegin + sizeof(number)); -} -} - - std::string util::retrieveFileID(const Zstring& filename) { - std::string fileID; - #ifdef FFS_WIN //WARNING: CreateFile() is SLOW, while GetFileInformationByHandle() is cheap! //http://msdn.microsoft.com/en-us/library/aa363788(VS.85).aspx @@ -40,34 +28,27 @@ std::string util::retrieveFileID(const Zstring& filename) const HANDLE hFile = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, //FILE_FLAG_BACKUP_SEMANTICS needed to open a directory NULL); if (hFile != INVALID_HANDLE_VALUE) { - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hFile); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hFile)); BY_HANDLE_FILE_INFORMATION fileInfo = {}; if (::GetFileInformationByHandle(hFile, &fileInfo)) - { - fileID += numberToBytes(fileInfo.dwVolumeSerialNumber); - fileID += numberToBytes(fileInfo.nFileIndexHigh); - fileID += numberToBytes(fileInfo.nFileIndexLow); - } + return extractFileID(fileInfo); } #elif defined FFS_LINUX struct stat fileInfo = {}; if (::lstat(filename.c_str(), &fileInfo) == 0) //lstat() does not follow symlinks - { - fileID += numberToBytes(fileInfo.st_dev); - fileID += numberToBytes(fileInfo.st_ino); - } + return extractFileID(fileInfo); #endif - assert(!fileID.empty()); - return fileID; + + assert(false); + return std::string(); } diff --git a/shared/file_id_internal.h b/shared/file_id_internal.h new file mode 100644 index 00000000..a8a7042d --- /dev/null +++ b/shared/file_id_internal.h @@ -0,0 +1,48 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef FILE_ID_INTERNAL_HEADER_013287632486321493 +#define FILE_ID_INTERNAL_HEADER_013287632486321493 + +#include <string> + +#ifdef FFS_WIN +#include <wx/msw/wrapwin.h> //includes "windows.h" + +#elif defined FFS_LINUX +#include <sys/stat.h> +#endif + +namespace +{ +template <class T> inline +std::string numberToBytes(T number) +{ + const char* rawBegin = reinterpret_cast<const char*>(&number); + return std::string(rawBegin, rawBegin + sizeof(number)); +} + +#ifdef FFS_WIN +inline +std::string extractFileID(const BY_HANDLE_FILE_INFORMATION& fileInfo) +{ + return numberToBytes(fileInfo.dwVolumeSerialNumber) + + numberToBytes(fileInfo.nFileIndexHigh) + + numberToBytes(fileInfo.nFileIndexLow); +} +#elif defined FFS_LINUX +inline +std::string extractFileID(const struct stat& fileInfo) +{ + return numberToBytes(fileInfo.st_dev) + + numberToBytes(fileInfo.st_ino); +} +#endif + +} + + +#endif //FILE_ID_INTERNAL_HEADER_013287632486321493 diff --git a/shared/file_io.cpp b/shared/file_io.cpp index 2614ac06..59b78044 100644 --- a/shared/file_io.cpp +++ b/shared/file_io.cpp @@ -23,7 +23,7 @@ FileInput::FileInput(FileHandle handle, const Zstring& filename) : filename_(filename) {} -FileInput::FileInput(const Zstring& filename) : //throw (FileError, ErrorNotExisting) +FileInput::FileInput(const Zstring& filename) : //throw FileError, ErrorNotExisting eofReached(false), filename_(filename) { @@ -31,7 +31,7 @@ FileInput::FileInput(const Zstring& filename) : //throw (FileError, ErrorNotExi fileHandle = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //all shared modes are required to read open files that are shared by other applications - NULL, + 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, /* possible values: (Reference http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx#caching_behavior) @@ -112,7 +112,7 @@ size_t FileInput::read(void* buffer, size_t bytesToRead) //returns actual number const size_t bytesRead = ::fread(buffer, 1, bytesToRead, fileHandle); if (::ferror(fileHandle) != 0) #endif - throw FileError(_("Error reading file:") + "\n\"" + filename_ + "\"" + "\n\n" + zen::getLastErrorFormatted()); + throw FileError(_("Error reading file:") + "\n\"" + filename_ + "\"" + "\n\n" + zen::getLastErrorFormatted() + " (r)"); #ifdef FFS_WIN if (bytesRead < bytesToRead) //falsify only! @@ -137,14 +137,19 @@ bool FileInput::eof() //end of file reached FileOutput::FileOutput(FileHandle handle, const Zstring& filename) : fileHandle(handle), filename_(filename) {} -FileOutput::FileOutput(const Zstring& filename, AccessFlag access) : //throw (FileError, ErrorTargetPathMissing, ErrorTargetExisting) +FileOutput::FileOutput(const Zstring& filename, AccessFlag access) : //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting filename_(filename) { #ifdef FFS_WIN fileHandle = ::CreateFile(zen::applyLongPathPrefix(filename).c_str(), - GENERIC_WRITE, + GENERIC_READ | GENERIC_WRITE, + /* http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx + quote: When an application creates a file across a network, it is better + to use GENERIC_READ | GENERIC_WRITE for dwDesiredAccess than to use GENERIC_WRITE alone. + The resulting code is faster, because the redirector can use the cache manager and send fewer SMBs with more data. + This combination also avoids an issue where writing to a file across a network can occasionally return ERROR_ACCESS_DENIED. */ FILE_SHARE_READ | FILE_SHARE_DELETE, //note: FILE_SHARE_DELETE is required to rename file while handle is open! - NULL, + 0, access == ACC_OVERWRITE ? CREATE_ALWAYS : CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); @@ -192,7 +197,7 @@ FileOutput::~FileOutput() } -void FileOutput::write(const void* buffer, size_t bytesToWrite) //throw (FileError) +void FileOutput::write(const void* buffer, size_t bytesToWrite) //throw FileError { #ifdef FFS_WIN DWORD bytesWritten = 0; diff --git a/shared/file_io.h b/shared/file_io.h index 6f87845b..76713e5b 100644 --- a/shared/file_io.h +++ b/shared/file_io.h @@ -29,11 +29,11 @@ typedef FILE* FileHandle; class FileInput { public: - FileInput(const Zstring& filename); //throw (FileError: ErrorNotExisting) + FileInput(const Zstring& filename); //throw FileError, ErrorNotExisting FileInput(FileHandle handle, const Zstring& filename); //takes ownership! ~FileInput(); - size_t read(void* buffer, size_t bytesToRead); //throw (FileError); returns actual number of bytes read + size_t read(void* buffer, size_t bytesToRead); //throw FileError; returns actual number of bytes read bool eof(); //end of file reached private: @@ -54,11 +54,11 @@ public: ACC_OVERWRITE, ACC_CREATE_NEW }; - FileOutput(const Zstring& filename, AccessFlag access); //throw (FileError: ErrorTargetPathMissing, ErrorTargetExisting) + FileOutput(const Zstring& filename, AccessFlag access); //throw FileError, ErrorTargetPathMissing, ErrorTargetExisting FileOutput(FileHandle handle, const Zstring& filename); //takes ownership! ~FileOutput(); - void write(const void* buffer, size_t bytesToWrite); //throw (FileError) + void write(const void* buffer, size_t bytesToWrite); //throw FileError private: FileOutput(const FileOutput&); diff --git a/shared/file_traverser.cpp b/shared/file_traverser.cpp index 595b2768..eb79b0e7 100644 --- a/shared/file_traverser.cpp +++ b/shared/file_traverser.cpp @@ -15,6 +15,8 @@ #include "long_path_prefix.h" #include "dst_hack.h" #include "file_update_handle.h" +#include "dll_loader.h" +#include "FindFilePlus/find_file_plus.h" #elif defined FFS_LINUX #include <sys/stat.h> @@ -55,41 +57,36 @@ bool tryReportingError(Command cmd, zen::TraverseCallback& callback) #ifdef FFS_WIN inline -zen::Int64 filetimeToTimeT(const FILETIME& lastWriteTime) -{ - //convert UTC FILETIME to ANSI C format (number of seconds since Jan. 1st 1970 UTC) - zen::Int64 writeTimeLong = to<zen::Int64>(zen::UInt64(lastWriteTime.dwLowDateTime, lastWriteTime.dwHighDateTime) / 10000000U); //reduce precision to 1 second (FILETIME has unit 10^-7 s) - writeTimeLong -= zen::Int64(3054539008UL, 2); //timeshift between ansi C time and FILETIME in seconds == 11644473600s - return writeTimeLong; -} - - -inline bool setWin32FileInformationFromSymlink(const Zstring& linkName, zen::TraverseCallback::FileInfo& output) { //open handle to target of symbolic link HANDLE hFile = ::CreateFile(zen::applyLongPathPrefix(linkName).c_str(), 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); if (hFile == INVALID_HANDLE_VALUE) return false; - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hFile); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hFile)); BY_HANDLE_FILE_INFORMATION fileInfoByHandle = {}; if (!::GetFileInformationByHandle(hFile, &fileInfoByHandle)) return false; //write output - output.lastWriteTimeRaw = filetimeToTimeT(fileInfoByHandle.ftLastWriteTime); + output.lastWriteTimeRaw = toTimeT(fileInfoByHandle.ftLastWriteTime); output.fileSize = zen::UInt64(fileInfoByHandle.nFileSizeLow, fileInfoByHandle.nFileSizeHigh); return true; } + +/* +warn_static("finish") + util::DllFun<findplus::OpenDirFunc> openDir (findplus::getDllName(), findplus::openDirFuncName); + util::DllFun<findplus::ReadDirFunc> readDir (findplus::getDllName(), findplus::readDirFuncName); + util::DllFun<findplus::CloseDirFunc> closeDir(findplus::getDllName(), findplus::closeDirFuncName); +*/ #endif } @@ -102,8 +99,8 @@ public: : isFatFileSystem(dst::isFatDrive(baseDirectory)) #endif { - //format base directory name #ifdef FFS_WIN + //format base directory name const Zstring& directoryFormatted = baseDirectory; #elif defined FFS_LINUX @@ -143,57 +140,75 @@ private: return true; }, sink); - #ifdef FFS_WIN +/* //ensure directoryPf ends with backslash const Zstring& directoryPf = directory.EndsWith(FILE_NAME_SEPARATOR) ? directory : directory + FILE_NAME_SEPARATOR; - WIN32_FIND_DATA fileInfo = {}; - HANDLE searchHandle = INVALID_HANDLE_VALUE; + FindHandle searchHandle = NULL; tryReportingError([&](std::wstring& errorMsg) -> bool { - searchHandle = ::FindFirstFile(applyLongPathPrefix(directoryPf + L'*').c_str(), &fileInfo); + searchHandle = this->openDir(applyLongPathPrefix(directoryPf).c_str()); //no noticable performance difference compared to FindFirstFileEx with FindExInfoBasic, FIND_FIRST_EX_CASE_SENSITIVE and/or FIND_FIRST_EX_LARGE_FETCH - if (searchHandle == INVALID_HANDLE_VALUE) + if (searchHandle == NULL) { - const DWORD lastError = ::GetLastError(); - if (lastError == ERROR_FILE_NOT_FOUND) - return true; //fine: empty directory + //const DWORD lastError = ::GetLastError(); + //if (lastError == ERROR_FILE_NOT_FOUND) -> actually NOT okay, even for an empty directory this should not occur (., ..) + //return true; //fine: empty directory //else: we have a problem... report it: - errorMsg = _("Error traversing directory:") + "\n\"" + directory + "\"" + "\n\n" + zen::getLastErrorFormatted(lastError); + errorMsg = _("Error traversing directory:") + "\n\"" + directory + "\"" + "\n\n" + zen::getLastErrorFormatted(); return false; } return true; }, sink); - if (searchHandle == INVALID_HANDLE_VALUE) + if (searchHandle == NULL) return; //empty dir or ignore error + LOKI_ON_BLOCK_EXIT2(this->closeDir(searchHandle)); - Loki::ScopeGuard dummy = Loki::MakeGuard(::FindClose, searchHandle); - (void)dummy; //silence warning "unused variable" - - do + FileInformation fileInfo = {}; + for (;;) { + bool moreData = false; + tryReportingError([&](std::wstring& errorMsg) -> bool + { + if (!this->readDir(searchHandle, fileInfo)) + { + if (::GetLastError() == ERROR_NO_MORE_FILES) //this is fine + return true; + + //else we have a problem... report it: + errorMsg = _("Error traversing directory:") + "\n\"" + directory + "\"" + "\n\n" + zen::getLastErrorFormatted(); + return false; + } + + moreData = true; + return true; + }, sink); + if (!moreData) //no more items or ignore error + return; + + //don't return "." and ".." - const Zchar* const shortName = fileInfo.cFileName; + const Zchar* const shortName = fileInfo.shortName; if (shortName[0] == L'.' && (shortName[1] == L'\0' || (shortName[1] == L'.' && shortName[2] == L'\0'))) continue; const Zstring& fullName = directoryPf + shortName; - const bool isSymbolicLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + const bool isSymbolicLink = (fileInfo.fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; if (isSymbolicLink && !followSymlinks) //evaluate symlink directly { TraverseCallback::SymlinkInfo details; try { - details.targetPath = getSymlinkRawTargetString(fullName); //throw (FileError) + details.targetPath = getSymlinkRawTargetString(fullName); //throw FileError } catch (FileError& e) { @@ -203,11 +218,11 @@ private: #endif } - details.lastWriteTimeRaw = filetimeToTimeT(fileInfo.ftLastWriteTime); - details.dirLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; //directory symlinks have this flag on Windows + details.lastWriteTimeRaw = toTimeT(fileInfo.lastWriteTime); + details.dirLink = (fileInfo.fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; //directory symlinks have this flag on Windows sink.onSymlink(shortName, fullName, details); } - else if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //a directory... or symlink that needs to be followed (for directory symlinks this flag is set too!) + else if (fileInfo.fileAttributes & FILE_ATTRIBUTE_DIRECTORY) //a directory... or symlink that needs to be followed (for directory symlinks this flag is set too!) { const TraverseCallback::ReturnValDir rv = sink.onDir(shortName, fullName); switch (rv.returnCode) @@ -238,45 +253,155 @@ private: //####################################### DST hack ########################################### if (isFatFileSystem) { - const dst::RawTime rawTime(fileInfo.ftCreationTime, fileInfo.ftLastWriteTime); + const dst::RawTime rawTime(fileInfo.creationTime, fileInfo.lastWriteTime); if (dst::fatHasUtcEncoded(rawTime)) //throw (std::runtime_error) - fileInfo.ftLastWriteTime = dst::fatDecodeUtcTime(rawTime); //return real UTC time; throw (std::runtime_error) + fileInfo.lastWriteTime = dst::fatDecodeUtcTime(rawTime); //return real UTC time; throw (std::runtime_error) else - markForDstHack.push_back(std::make_pair(fullName, fileInfo.ftLastWriteTime)); + markForDstHack.push_back(std::make_pair(fullName, fileInfo.lastWriteTime)); } //####################################### DST hack ########################################### - details.lastWriteTimeRaw = filetimeToTimeT(fileInfo.ftLastWriteTime); - details.fileSize = zen::UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); + + details.lastWriteTimeRaw = toTimeT(fileInfo.lastWriteTime); + details.fileSize = fileInfo.fileSize.QuadPart; } sink.onFile(shortName, fullName, details); } } - while ([&]() -> bool - { - bool moreData = false; +*/ - tryReportingError([&](std::wstring& errorMsg) -> bool - { - if (!::FindNextFile(searchHandle, // handle to search - &fileInfo)) // pointer to structure for data on found file + + + //ensure directoryPf ends with backslash + const Zstring& directoryPf = directory.EndsWith(FILE_NAME_SEPARATOR) ? + directory : + directory + FILE_NAME_SEPARATOR; + WIN32_FIND_DATA fileInfo = {}; + + HANDLE searchHandle = INVALID_HANDLE_VALUE; + tryReportingError([&](std::wstring& errorMsg) -> bool { - if (::GetLastError() == ERROR_NO_MORE_FILES) //this is fine - return true; + searchHandle = ::FindFirstFile(applyLongPathPrefix(directoryPf + L'*').c_str(), &fileInfo); + //no noticable performance difference compared to FindFirstFileEx with FindExInfoBasic, FIND_FIRST_EX_CASE_SENSITIVE and/or FIND_FIRST_EX_LARGE_FETCH - //else we have a problem... report it: - errorMsg = _("Error traversing directory:") + "\n\"" + directory + "\"" + "\n\n" + zen::getLastErrorFormatted(); - return false; - } + if (searchHandle == INVALID_HANDLE_VALUE) + { + //const DWORD lastError = ::GetLastError(); + //if (lastError == ERROR_FILE_NOT_FOUND) -> actually NOT okay, even for an empty directory this should not occur (., ..) + //return true; //fine: empty directory - moreData = true; - return true; - }, sink); + //else: we have a problem... report it: + errorMsg = _("Error traversing directory:") + "\n\"" + directory + "\"" + "\n\n" + zen::getLastErrorFormatted(); + return false; + } + return true; + }, sink); + + if (searchHandle == INVALID_HANDLE_VALUE) + return; //empty dir or ignore error + LOKI_ON_BLOCK_EXIT2(::FindClose(searchHandle)); - return moreData; - }()); + do + { + //don't return "." and ".." + const Zchar* const shortName = fileInfo.cFileName; + if (shortName[0] == L'.' && + (shortName[1] == L'\0' || (shortName[1] == L'.' && shortName[2] == L'\0'))) + continue; + const Zstring& fullName = directoryPf + shortName; + + const bool isSymbolicLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0; + + if (isSymbolicLink && !followSymlinks) //evaluate symlink directly + { + TraverseCallback::SymlinkInfo details; + try + { + details.targetPath = getSymlinkRawTargetString(fullName); //throw FileError + } + catch (FileError& e) + { + (void)e; + #ifndef NDEBUG //show broken symlink / access errors in debug build! + sink.onError(e.msg()); + #endif + } + + details.lastWriteTimeRaw = toTimeT(fileInfo.ftLastWriteTime); + details.dirLink = (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; //directory symlinks have this flag on Windows + sink.onSymlink(shortName, fullName, details); + } + else if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //a directory... or symlink that needs to be followed (for directory symlinks this flag is set too!) + { + const TraverseCallback::ReturnValDir rv = sink.onDir(shortName, fullName); + switch (rv.returnCode) + { + case TraverseCallback::ReturnValDir::TRAVERSING_DIR_IGNORE: + break; + + case TraverseCallback::ReturnValDir::TRAVERSING_DIR_CONTINUE: + traverse<followSymlinks>(fullName, *rv.subDirCb, level + 1); + break; + } + } + else //a file or symlink that is followed... + { + TraverseCallback::FileInfo details; + + if (isSymbolicLink) //dereference symlinks! + { + if (!setWin32FileInformationFromSymlink(fullName, details)) + { + //broken symlink... + details.lastWriteTimeRaw = 0; //we are not interested in the modification time of the link + details.fileSize = 0U; + } + } + else + { + //####################################### DST hack ########################################### + if (isFatFileSystem) + { + const dst::RawTime rawTime(fileInfo.ftCreationTime, fileInfo.ftLastWriteTime); + + if (dst::fatHasUtcEncoded(rawTime)) //throw (std::runtime_error) + fileInfo.ftLastWriteTime = dst::fatDecodeUtcTime(rawTime); //return real UTC time; throw (std::runtime_error) + else + markForDstHack.push_back(std::make_pair(fullName, fileInfo.ftLastWriteTime)); + } + //####################################### DST hack ########################################### + details.lastWriteTimeRaw = toTimeT(fileInfo.ftLastWriteTime); + details.fileSize = zen::UInt64(fileInfo.nFileSizeLow, fileInfo.nFileSizeHigh); + } + + sink.onFile(shortName, fullName, details); + } + } + while ([&]() -> bool + { + bool moreData = false; + + tryReportingError([&](std::wstring& errorMsg) -> bool + { + if (!::FindNextFile(searchHandle, // handle to search + &fileInfo)) // pointer to structure for data on found file + { + if (::GetLastError() == ERROR_NO_MORE_FILES) //this is fine + return true; + + //else we have a problem... report it: + errorMsg = _("Error traversing directory:") + "\n\"" + directory + "\"" + "\n\n" + zen::getLastErrorFormatted(); + return false; + } + + moreData = true; + return true; + }, sink); + + return moreData; + }()); #elif defined FFS_LINUX DIR* dirObj = NULL; @@ -291,9 +416,7 @@ private: return true; }, sink)) return; - - Loki::ScopeGuard dummy = Loki::MakeGuard(::closedir, dirObj); //never close NULL handles! -> crash - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::closedir(dirObj)); //never close NULL handles! -> crash while (true) { @@ -357,7 +480,7 @@ private: TraverseCallback::SymlinkInfo details; try { - details.targetPath = getSymlinkRawTargetString(fullName); //throw (FileError) + details.targetPath = getSymlinkRawTargetString(fullName); //throw FileError } catch (FileError& e) { @@ -418,12 +541,12 @@ private: const dst::RawTime encodedTime = dst::fatEncodeUtcTime(i->second); //throw (std::runtime_error) { //may need to remove the readonly-attribute (e.g. FAT usb drives) - FileUpdateHandle updateHandle(i->first, [=]() + FileUpdateHandle updateHandle(i->first, [ = ]() { return ::CreateFile(zen::applyLongPathPrefix(i->first).c_str(), - GENERIC_WRITE, //just FILE_WRITE_ATTRIBUTES may not be enough for some NAS shares! + GENERIC_READ | GENERIC_WRITE, //use both when writing over network, see comment in file_io.cpp FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); diff --git a/shared/file_traverser.h b/shared/file_traverser.h index aa9dffad..7da86c3a 100644 --- a/shared/file_traverser.h +++ b/shared/file_traverser.h @@ -44,7 +44,7 @@ public: ReturnValDir(Loki::Int2Type<TRAVERSING_DIR_IGNORE>) : returnCode(TRAVERSING_DIR_IGNORE), subDirCb(NULL) {} ReturnValDir(Loki::Int2Type<TRAVERSING_DIR_CONTINUE>, TraverseCallback& subDirCallback) : returnCode(TRAVERSING_DIR_CONTINUE), subDirCb(&subDirCallback) {} - const ReturnValueEnh returnCode; + ReturnValueEnh returnCode; TraverseCallback* subDirCb; }; diff --git a/shared/fixed_list.h b/shared/fixed_list.h new file mode 100644 index 00000000..97976149 --- /dev/null +++ b/shared/fixed_list.h @@ -0,0 +1,142 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef PTR_WRAP_012384670856841394535 +#define PTR_WRAP_012384670856841394535 + +#include <iterator> + +namespace zen +{ +//std::list(C++11) compatible class supporting inplace element construction for non-copyable/movable types +//may be replaced by C++11 std::list when available +template <class T> +class FixedList +{ + struct Node + { + Node() : next(NULL) {} + template <class A> Node(A && a) : next(NULL), val(a) {} + template <class A, class B> Node(A && a, B && b) : next(NULL), val(a, b) {} + template <class A, class B, class C> Node(A && a, B && b, C && c) : next(NULL), val(a, b, c) {} + template <class A, class B, class C, class D> Node(A && a, B && b, C && c, D && d) : next(NULL), val(a, b, c, d) {} + template <class A, class B, class C, class D, class E> Node(A && a, B && b, C && c, D && d, E && e) : next(NULL), val(a, b, c, d, e) {} + template <class A, class B, class C, class D, class E, class F> Node(A && a, B && b, C && c, D && d, E && e, F && f) : next(NULL), val(a, b, c, d, e, f) {} + + Node* next; //singly linked list is sufficient + T val; + }; + +public: + FixedList() : + first(NULL), + lastInsert(NULL), + sz(0) {} + + ~FixedList() { clear(); } + + template <class NodeT, class U> + class ListIterator : public std::iterator<std::forward_iterator_tag, U> + { + public: + ListIterator(NodeT* it = NULL) : iter(it) {} + ListIterator& operator++() { iter = iter->next; return *this; } + inline friend bool operator==(const ListIterator& lhs, const ListIterator& rhs) { return lhs.iter == rhs.iter; } + inline friend bool operator!=(const ListIterator& lhs, const ListIterator& rhs) { return !(lhs == rhs); } + U& operator* () { return iter->val; } + U* operator->() { return &iter->val; } + private: + NodeT* iter; + }; + + typedef T value_type; + typedef ListIterator<Node, T> iterator; + typedef ListIterator<const Node, const T> const_iterator; + typedef T& reference; + typedef const T& const_reference; + + iterator begin() { return first; } + iterator end() { return iterator(); } + + const_iterator begin() const { return first; } + const_iterator end () const { return const_iterator(); } + + reference front() { return first->val; } + const_reference front() const { return first->val; } + + reference& back() { return lastInsert->val; } + const_reference& back() const { return lastInsert->val; } + + void emplace_back() { pushNode(new Node); } + template <class A> void emplace_back(A && a) { pushNode(new Node(std::forward<A>(a))); } + template <class A, class B> void emplace_back(A && a, B && b) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b))); } + template <class A, class B, class C> void emplace_back(A && a, B && b, C && c) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c))); } + template <class A, class B, class C, class D> void emplace_back(A && a, B && b, C && c, D && d) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d))); } + template <class A, class B, class C, class D, class E> void emplace_back(A && a, B && b, C && c, D && d, E && e) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e))); } + template <class A, class B, class C, class D, class E, class F> void emplace_back(A && a, B && b, C && c, D && d, E && e, F && f) { pushNode(new Node(std::forward<A>(a), std::forward<B>(b), std::forward<C>(c), std::forward<D>(d), std::forward<E>(e), std::forward<F>(f))); } + + template <class Predicate> + void remove_if(Predicate pred) + { + Node* prev = NULL; + for (auto ptr = first; ptr;) + if (pred(ptr->val)) + { + Node* tmp = ptr->next; + deleteNode(ptr); + if (prev) + prev->next = ptr = tmp; + else + first = ptr = tmp; + if (tmp == NULL) + lastInsert = prev; + } + else + { + prev = ptr; + ptr = ptr->next; + } + } + + void clear() { remove_if([](T&) { return true; }); } + bool empty() const { return first == NULL; } + size_t size() const { return sz; } + +private: + FixedList(const FixedList&); + FixedList& operator=(const FixedList&); + + void pushNode(Node* newNode) + { + ++sz; + if (lastInsert == NULL) + { + assert(first == NULL); + first = lastInsert = newNode; + } + else + { + assert(lastInsert->next == NULL); + lastInsert->next = newNode; + lastInsert = newNode; + } + } + + void deleteNode(Node* oldNode) + { + assert(sz > 0); + --sz; + delete oldNode; + } + + Node* first; + Node* lastInsert; //point to last insertion; required by emplace_back() + size_t sz; +}; +} + + +#endif //PTR_WRAP_012384670856841394535 diff --git a/shared/folder_history_box.cpp b/shared/folder_history_box.cpp new file mode 100644 index 00000000..f787e2cb --- /dev/null +++ b/shared/folder_history_box.cpp @@ -0,0 +1,139 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#include "folder_history_box.h" +#include "resolve_path.h" +#include <list> + +using namespace zen; + +FolderHistoryBox::FolderHistoryBox(wxWindow* parent, + wxWindowID id, + const wxString& value, + const wxPoint& pos, + const wxSize& size, + int n, + const wxString choices[], + long style, + const wxValidator& validator, + const wxString& name) : + wxComboBox(parent, id, value, pos, size, n, choices, style, validator, name) +#if wxCHECK_VERSION(2, 9, 1) + , dropDownShown(false) +#endif +{ + //##################################### + /*##*/ SetMinSize(wxSize(150, -1)); //## workaround yet another wxWidgets bug: default minimum size is much too large for a wxComboBox + //##################################### + + //register key event to enable item deletion + Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(FolderHistoryBox::OnKeyEvent), NULL, this); + + //refresh history list on mouse click + Connect(wxEVT_LEFT_DOWN, wxEventHandler(FolderHistoryBox::OnUpdateList), NULL, this); + + Connect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(FolderHistoryBox::OnSelection), NULL, this); + +#if wxCHECK_VERSION(2, 9, 1) + Connect(wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEventHandler(FolderHistoryBox::OnShowDropDown), NULL, this); + Connect(wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEventHandler(FolderHistoryBox::OnHideDropDown), NULL, this); +#endif +} + + +#if wxCHECK_VERSION(2, 9, 1) +void FolderHistoryBox::OnShowDropDown(wxCommandEvent& event) +{ + dropDownShown = true; + event.Skip(); +} + + +void FolderHistoryBox::OnHideDropDown(wxCommandEvent& event) +{ + dropDownShown = false; + event.Skip(); +} +#endif + + +void FolderHistoryBox::update() +{ + std::list<Zstring> dirList; + + //add some aliases to allow user changing to volume name and back, if possible +#ifdef FFS_WIN + const Zstring activePath = toZ(GetValue()); + std::vector<Zstring> aliases = getDirectoryAliases(activePath); + dirList.insert(dirList.end(), aliases.begin(), aliases.end()); +#endif + + if (sharedHistory_.get()) + { + auto tmp = sharedHistory_->getList(); + //std::sort(tmp.begin(), tmp.end(), LessFilename()); + + if (!dirList.empty() && !tmp.empty()) + dirList.push_back(FolderHistory::lineSeparator()); + + dirList.insert(dirList.end(), tmp.begin(), tmp.end()); + } + //########################################################################################### + + + //it may be a little lame to update the list on each mouse-button click, but it should be working and we dont't have to manipulate wxComboBox internals + const wxString oldVal = this->GetValue(); + + Clear(); + std::for_each(dirList.begin(), dirList.end(), + [&](const Zstring& dir) { this->Append(toWx(dir)); }); + + this->SetSelection(wxNOT_FOUND); //don't select anything + this->SetValue(oldVal); //but preserve main text! +} + + +void FolderHistoryBox::OnSelection(wxCommandEvent& event) +{ + event.Skip(); +} + + +void FolderHistoryBox::OnKeyEvent(wxKeyEvent& event) +{ + const int keyCode = event.GetKeyCode(); + if (keyCode == WXK_DELETE || keyCode == WXK_NUMPAD_DELETE) + { + //try to delete the currently selected config history item + int pos = this->GetCurrentSelection(); + if (0 <= pos && pos < static_cast<int>(this->GetCount()) && +#if wxCHECK_VERSION(2, 9, 1) + dropDownShown) +#else + //what a mess...: + (GetValue() != GetString(pos) || //avoid problems when a character shall be deleted instead of list item + GetValue() == wxEmptyString)) //exception: always allow removing empty entry +#endif + { + //save old (selected) value: deletion seems to have influence on this + const wxString currentVal = this->GetValue(); + //this->SetSelection(wxNOT_FOUND); + + //delete selected row + if (sharedHistory_.get()) + sharedHistory_->delItem(toZ(GetString(pos))); + SetString(pos, wxString()); //in contrast to Delete(), this one does not kill the drop-down list and gives a nice visual feedback! + //Delete(pos); + + //(re-)set value + this->SetValue(currentVal); + + //eat up key event + return; + } + } + event.Skip(); +} diff --git a/shared/folder_history_box.h b/shared/folder_history_box.h new file mode 100644 index 00000000..3b4fd57e --- /dev/null +++ b/shared/folder_history_box.h @@ -0,0 +1,109 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef CUSTOMCOMBOBOX_H_INCLUDED +#define CUSTOMCOMBOBOX_H_INCLUDED + +#include <wx/combobox.h> +#include <memory> +#include "zstring.h" +#include "string_conv.h" +#include "stl_tools.h" + +//combobox with history function + functionality to delete items (DEL) +using namespace zen; + + +class FolderHistory +{ +public: + FolderHistory() : maxSize_(0) {} + + FolderHistory(const std::vector<Zstring>& dirnames, size_t maxSize) : + maxSize_(maxSize), + dirnames_(dirnames) + { + if (dirnames_.size() > maxSize_) //keep maximal size of history list + dirnames_.resize(maxSize_); + } + + const std::vector<Zstring>& getList() const { return dirnames_; } + + static const Zstring lineSeparator() { return Zstr("---------------------------------------------------------------------------------------------------------------"); } + + void addItem(const Zstring& dirname) + { + if (dirname.empty() || dirname == lineSeparator()) + return; + + Zstring nameTmp = dirname; + zen::trim(nameTmp); + + //insert new folder or put it to the front if already existing + auto iter = std::find_if(dirnames_.begin(), dirnames_.end(), + [&](const Zstring& entry) { return ::EqualFilename()(entry, nameTmp); }); + + if (iter != dirnames_.end()) + dirnames_.erase(iter); + dirnames_.insert(dirnames_.begin(), nameTmp); + + if (dirnames_.size() > maxSize_) //keep maximal size of history list + dirnames_.resize(maxSize_); + } + + void delItem(const Zstring& dirname) { vector_remove_if(dirnames_, [&](const Zstring& entry) { return ::EqualFilename()(entry, dirname); }); } + +private: + + size_t maxSize_; + std::vector<Zstring> dirnames_; +}; + + +class FolderHistoryBox : public wxComboBox +{ +public: + FolderHistoryBox(wxWindow* parent, + wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, + const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxComboBoxNameStr); + + void init(const std::shared_ptr<FolderHistory>& sharedHistory) { sharedHistory_ = sharedHistory; } + + void setValue(const wxString& dirname) + { + SetSelection(wxNOT_FOUND); + SetValue(dirname); + update(); //required for Linux to ensure the dropdown is shown as being populated + } + + // GetValue + +private: + void OnKeyEvent(wxKeyEvent& event); + void OnSelection(wxCommandEvent& event); + void OnUpdateList(wxEvent& event) { update(); event.Skip(); } + + void update(); + +#if wxCHECK_VERSION(2, 9, 1) + void OnShowDropDown(wxCommandEvent& event); + void OnHideDropDown(wxCommandEvent& event); + + bool dropDownShown; +#endif + + std::shared_ptr<FolderHistory> sharedHistory_; +}; + + +#endif // CUSTOMCOMBOBOX_H_INCLUDED diff --git a/shared/global_func.h b/shared/global_func.h index 861e2081..b3c13a24 100644 --- a/shared/global_func.h +++ b/shared/global_func.h @@ -7,106 +7,21 @@ #ifndef GLOBALFUNCTIONS_H_INCLUDED #define GLOBALFUNCTIONS_H_INCLUDED -#include <string> -#include <algorithm> -#include <vector> -#include <set> -#include <wx/string.h> +#include <cmath> namespace common { //little rounding function -inline int round(double d) { return static_cast<int>(d < 0 ? d - 0.5 : d + 0.5); } - -//absolute value -template <class T> inline T abs(const T& d) { return d < 0 ? -d : d; } - -size_t getDigitCount(size_t number); //count number of digits - -//Note: the following lines are a performance optimization for deleting elements from a vector: linear runtime at most! -template <class T> -void removeRowsFromVector(const std::set<size_t>& rowsToRemove, std::vector<T>& grid); - -//enhanced binary search template: returns an iterator -template <class ForwardIterator, class T, typename Compare> -ForwardIterator custom_binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp = std::less<T>()); -} - - -//############################################################################ - - - - - - - - - - - - - - - - - - - - - -//---------------Inline Implementation--------------------------------------------------- inline -size_t common::getDigitCount(size_t number) //count number of digits -{ - return number == 0 ? 1 : static_cast<size_t>(::log10(static_cast<double>(number))) + 1; -} - - -//Note: the following lines are a performance optimization for deleting elements from a vector: linear runtime at most! -template <class T> -void common::removeRowsFromVector(const std::set<size_t>& rowsToRemove, std::vector<T>& grid) -{ - if (rowsToRemove.empty()) - return; - - std::set<size_t>::const_iterator rowToSkipIndex = rowsToRemove.begin(); - size_t rowToSkip = *rowToSkipIndex; - - if (rowToSkip >= grid.size()) - return; - - typename std::vector<T>::iterator insertPos = grid.begin() + rowToSkip; - - for (size_t i = rowToSkip; i < grid.size(); ++i) - { - if (i != rowToSkip) - { - *insertPos = grid[i]; - ++insertPos; - } - else - { - ++rowToSkipIndex; - if (rowToSkipIndex != rowsToRemove.end()) - rowToSkip = *rowToSkipIndex; - } - } - grid.erase(insertPos, grid.end()); -} +int round(double d) { return static_cast<int>(d < 0 ? d - 0.5 : d + 0.5); } +//absolute value +template <class T> inline +T abs(const T& d) { return d < 0 ? -d : d; } -//enhanced binary search template: returns an iterator -template <class ForwardIterator, class T, typename Compare> inline -ForwardIterator common::custom_binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) -{ - first = std::lower_bound(first, last, value, comp); - if (first != last && !comp(value, *first)) - return first; - else - return last; +size_t getDigitCount(size_t number) { return number == 0 ? 1 : static_cast<size_t>(std::log10(static_cast<double>(number))) + 1; } //count number of digits } -#endif // GLOBALFUNCTIONS_H_INCLUDED +#endif //GLOBALFUNCTIONS_H_INCLUDED diff --git a/shared/help_provider.cpp b/shared/help_provider.cpp index 7eb043cd..666482eb 100644 --- a/shared/help_provider.cpp +++ b/shared/help_provider.cpp @@ -18,9 +18,9 @@ public: { controller.Initialize(zen::getResourceDir() + #ifdef FFS_WIN - wxT("FreeFileSync.chm")); + L"FreeFileSync.chm"); #elif defined FFS_LINUX - wxT("Help/FreeFileSync.hhp")); + L"Help/FreeFileSync.hhp"); #endif } diff --git a/shared/i18n.cpp b/shared/i18n.cpp index f22dca56..a5fb32dd 100644 --- a/shared/i18n.cpp +++ b/shared/i18n.cpp @@ -3,6 +3,7 @@ using namespace zen; + namespace { std::unique_ptr<TranslationHandler> globalHandler; diff --git a/shared/image_tools.h b/shared/image_tools.h new file mode 100644 index 00000000..e78e7ced --- /dev/null +++ b/shared/image_tools.h @@ -0,0 +1,157 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef IMAGE_TOOLS_HEADER_45782456427634254 +#define IMAGE_TOOLS_HEADER_45782456427634254 + +#include <numeric> +#include <wx/bitmap.h> +#include <wx/dcmemory.h> + + +namespace zen +{ +wxBitmap greyScale(const wxBitmap& bmp); //greyscale + brightness adaption +wxBitmap layOver(const wxBitmap& foreground, const wxBitmap& background); //merge + +void move(wxImage& img, int up, int left = 0); +void adjustBrightness(wxImage& img, int targetLevel); +double getAvgBrightness(const wxImage& img); //in [0, 255] +void brighten(wxImage& img, int level); //level: delta per channel in points + +bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs); //pixel-wise equality (respecting alpha channel) + + + + + + + + + + + + + + + + + +//################################### implementation ################################### +inline +void move(wxImage& img, int up, int left) +{ + img = img.GetSubImage(wxRect(std::max(0, left), std::max(0, up), img.GetWidth() - abs(left), img.GetHeight() - abs(up))); + img.Resize(wxSize(img.GetWidth() + abs(left), img.GetHeight() + abs(up)), wxPoint(-std::min(0, left), -std::min(0, up))); +} + + +inline +wxBitmap greyScale(const wxBitmap& bmp) +{ + wxImage output = bmp.ConvertToImage().ConvertToGreyscale(1.0/3, 1.0/3, 1.0/3); //treat all channels equally! + //wxImage output = bmp.ConvertToImage().ConvertToGreyscale(); + adjustBrightness(output, 170); + return output; +} + + +inline +double getAvgBrightness(const wxImage& img) +{ + const int pixelCount = img.GetWidth() * img.GetHeight(); + auto pixBegin = img.GetData(); + if (pixBegin) + { + auto pixEnd = pixBegin + 3 * pixelCount; //RGB + + if (img.HasAlpha()) + { + const unsigned char* alphaFirst = img.GetAlpha(); + + //calculate average weighted by alpha channel + double dividend = 0; + for (auto iter = pixBegin; iter != pixEnd; ++iter) + dividend += *iter * static_cast<double>(alphaFirst[(iter - pixBegin) / 3]); + + const int divisor = 3.0 * std::accumulate(alphaFirst, alphaFirst + pixelCount, 0.0); + + return dividend / divisor; + } + else + return std::accumulate(pixBegin, pixEnd, 0.0) / (3.0 * pixelCount); + } + return 0; +} + + +inline +void brighten(wxImage& img, int level) +{ + const int pixelCount = img.GetWidth() * img.GetHeight(); + auto pixBegin = img.GetData(); + if (pixBegin) + { + auto pixEnd = pixBegin + 3 * pixelCount; //RGB + if (level > 0) + std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = std::min(255, c + level); }); + else + std::for_each(pixBegin, pixEnd, [&](unsigned char& c) { c = std::max(0, c + level); }); + } +} + + +inline +void adjustBrightness(wxImage& img, int targetLevel) +{ + brighten(img, targetLevel - getAvgBrightness(img)); +} + + +inline +wxBitmap layOver(const wxBitmap& foreground, const wxBitmap& background) +{ + wxBitmap output = background; + { + wxMemoryDC dc; + dc.SelectObject(output); + dc.DrawBitmap(foreground, 0, 0, true); + dc.SelectObject(wxNullBitmap); + } + return output; +} + + +inline +bool isEqual(const wxBitmap& lhs, const wxBitmap& rhs) +{ + if (lhs.IsOk() != rhs.IsOk()) + return false; + if (!lhs.IsOk()) + return true; + + const int pixelCount = lhs.GetWidth() * lhs.GetHeight(); + if (pixelCount != rhs.GetWidth() * rhs.GetHeight()) + return false; + + wxImage imLhs = lhs.ConvertToImage(); + wxImage imRhs = rhs.ConvertToImage(); + + if (imLhs.HasAlpha() != imRhs.HasAlpha()) + return false; + + if (imLhs.HasAlpha()) + { + if (!std::equal(imLhs.GetAlpha(), imLhs.GetAlpha() + pixelCount, imRhs.GetAlpha())) + return false; + } + + return std::equal(imLhs.GetData(), imLhs.GetData() + pixelCount * 3, imRhs.GetData()); +} +} + + +#endif //IMAGE_TOOLS_HEADER_45782456427634254 diff --git a/shared/int64.h b/shared/int64.h index 61ef1716..cfd3e3d1 100644 --- a/shared/int64.h +++ b/shared/int64.h @@ -120,7 +120,6 @@ inline Int64 operator<<(const Int64& lhs, int rhs) { return Int64(lhs) <<= rhs; inline Int64 operator>>(const Int64& lhs, int rhs) { return Int64(lhs) >>= rhs; } - class UInt64 { struct DummyClass { operator size_t() { return 0U; } }; @@ -201,6 +200,28 @@ inline UInt64 operator>>(const UInt64& lhs, int rhs) { return UInt64(lhs) >>= rh template <> inline UInt64 to(Int64 number) { checkRange<boost::uint64_t>(number.value); return UInt64(number.value); } template <> inline Int64 to(UInt64 number) { checkRange<boost:: int64_t>(number.value); return Int64(number.value); } + + +#ifdef FFS_WIN +//convert FILETIME (number of 100-nanosecond intervals since January 1, 1601 UTC) +// to time_t (number of seconds since Jan. 1st 1970 UTC) +// +//FAT32 time is preserved exactly: FAT32 -> toTimeT -> tofiletime -> FAT32 +inline +Int64 toTimeT(const FILETIME& ft) +{ + return to<Int64>(UInt64(ft.dwLowDateTime, ft.dwHighDateTime) / 10000000U) - Int64(3054539008UL, 2); + //timeshift between ansi C time and FILETIME in seconds == 11644473600s +} + +inline +FILETIME tofiletime(const Int64& utcTime) +{ + const UInt64 fileTimeLong = to<UInt64>(utcTime + Int64(3054539008UL, 2)) * 10000000U; + const FILETIME output = { fileTimeLong.getLo(), fileTimeLong.getHi() }; + return output; +} +#endif } diff --git a/shared/localization.cpp b/shared/localization.cpp index 66b2d97b..73aa5b72 100644 --- a/shared/localization.cpp +++ b/shared/localization.cpp @@ -69,7 +69,7 @@ private: Translation transMapping; //map original text |-> translation TranslationPlural transMappingPl; - std::auto_ptr<PluralForm> pluralParser; + std::unique_ptr<PluralForm> pluralParser; wxLanguage langId_; }; @@ -385,7 +385,7 @@ void zen::setLanguage(int language) //handle RTL swapping: we need wxWidgets to do this - static std::auto_ptr<CustomLocale> dummy; + static std::unique_ptr<CustomLocale> dummy; dummy.reset(); //avoid global locale lifetime overlap! wxWidgets cannot handle this and will crash! dummy.reset(new CustomLocale(languageFile.empty() ? wxLANGUAGE_ENGLISH : language)); diff --git a/shared/loki/AbstractFactory.h b/shared/loki/AbstractFactory.h index 9a30583b..615652bd 100644 --- a/shared/loki/AbstractFactory.h +++ b/shared/loki/AbstractFactory.h @@ -170,8 +170,8 @@ class AbstractFact, class TList = typename AbstractFact::ProductList > class ConcreteFactory - : public GenLinearHierarchy< - typename TL::Reverse<TList>::Result, Creator, AbstractFact> + : public GenLinearHierarchy < + typename TL::Reverse<TList>::Result, Creator, AbstractFact > { public: typedef typename AbstractFact::ProductList ProductList; diff --git a/shared/loki/AssocVector.h b/shared/loki/AssocVector.h index ad43d152..7f259281 100644 --- a/shared/loki/AssocVector.h +++ b/shared/loki/AssocVector.h @@ -182,8 +182,8 @@ public: //http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/libstdc++/23_containers/howto.html#4 iterator insert(iterator pos, const value_type& val) { - if( (pos == begin() || this->operator()(*(pos-1),val)) && - (pos == end() || this->operator()(val, *pos)) ) + if ( (pos == begin() || this->operator()(*(pos - 1), val)) && + (pos == end() || this->operator()(val, *pos)) ) { return Base::insert(pos, val); } diff --git a/shared/loki/CachedFactory.h b/shared/loki/CachedFactory.h index 567b035c..dc5a76ae 100644 --- a/shared/loki/CachedFactory.h +++ b/shared/loki/CachedFactory.h @@ -81,7 +81,7 @@ protected: AbstractProduct* release(ProductReturn& pProduct) { AbstractProduct* pPointer(pProduct); - pProduct=NULL; + pProduct = NULL; return pPointer; } const char* name() {return "pointer";} @@ -172,9 +172,9 @@ private: { using namespace std; clock_t currentTime = clock(); - D( cout << "currentTime = " << currentTime<< endl; ) - D( cout << "currentTime - lastUpdate = " << currentTime - lastUpdate<< endl; ) - if(currentTime - lastUpdate > timeValidity) + D( cout << "currentTime = " << currentTime << endl; ) + D( cout << "currentTime - lastUpdate = " << currentTime - lastUpdate << endl; ) + if (currentTime - lastUpdate > timeValidity) { m_vTimes.clear(); D( cout << " is less than time validity " << timeValidity; ) @@ -213,7 +213,7 @@ protected: bool canCreate() { cleanVector(); - if(m_vTimes.size()>maxCreation) + if (m_vTimes.size() > maxCreation) throw Exception(); else return true; @@ -233,10 +233,10 @@ public: // No more than maxCreation within byTime milliseconds void setRate(unsigned maxCreation, unsigned byTime) { - assert(byTime>0); + assert(byTime > 0); this->maxCreation = maxCreation; this->timeValidity = static_cast<clock_t>(byTime * CLOCKS_PER_SEC / 1000); - D( std::cout << "Setting no more than "<< maxCreation <<" creation within " << this->timeValidity <<" ms"<< std::endl; ) + D( std::cout << "Setting no more than " << maxCreation << " creation within " << this->timeValidity << " ms" << std::endl; ) } }; @@ -262,7 +262,7 @@ protected: bool canCreate() { - return !(created>=maxCreation); + return !(created >= maxCreation); } void onCreate() @@ -279,9 +279,9 @@ public: // set the creation max amount void setMaxCreation(unsigned maxCreation) { - assert(maxCreation>0); + assert(maxCreation > 0); this->maxCreation = maxCreation; - D( std::cout << "Setting no more than " << maxCreation <<" creation" << std::endl; ) + D( std::cout << "Setting no more than " << maxCreation << " creation" << std::endl; ) } }; @@ -324,9 +324,9 @@ protected: assert(!m_mHitCount.empty()); // inserting the swapped pair into a multimap SwappedHitMap copyMap; - for(HitMapItr itr = m_mHitCount.begin(); itr != m_mHitCount.end(); ++itr) + for (HitMapItr itr = m_mHitCount.begin(); itr != m_mHitCount.end(); ++itr) copyMap.insert(SwappedPair((*itr).second, (*itr).first)); - if((*copyMap.rbegin()).first == 0) // the higher score is 0 ... + if ((*copyMap.rbegin()).first == 0) // the higher score is 0 ... throw EvictionException(); // there is no key evict return (*copyMap.begin()).second; } @@ -381,7 +381,7 @@ protected: // this function is implemented in Cache and redirected // to the Storage Policy - virtual void remove(DT const key)=0; + virtual void remove(DT const key) = 0; // LRU Eviction policy void evict() @@ -422,7 +422,7 @@ private: updateCounter(const DT& key): key_(key) {} void operator()(T x) { - x.second = (x.first == key_ ? (x.second >> 1) | ( 1 << ((sizeof(ST)-1)*8) ) : x.second >> 1); + x.second = (x.first == key_ ? (x.second >> 1) | ( 1 << ((sizeof(ST) - 1) * 8) ) : x.second >> 1); D( std::cout << x.second << std::endl; ) } const DT& key_; @@ -461,7 +461,7 @@ protected: // this function is implemented in Cache and redirected // to the Storage Policy - virtual void remove(DT const key)=0; + virtual void remove(DT const key) = 0; // LRU with Aging Eviction policy void evict() @@ -515,15 +515,15 @@ protected: } // Implemented in Cache and redirected to the Storage Policy - virtual void remove(DT const key)=0; + virtual void remove(DT const key) = 0; // Random Eviction policy void evict() { - if(m_vKeys.empty()) + if (m_vKeys.empty()) throw EvictionException(); - size_type random = static_cast<size_type>((m_vKeys.size()*rand())/(static_cast<size_type>(RAND_MAX) + 1)); - remove(*(m_vKeys.begin()+random)); + size_type random = static_cast<size_type>((m_vKeys.size() * rand()) / (static_cast<size_type>(RAND_MAX) + 1)); + remove(*(m_vKeys.begin() + random)); } const char* name() {return "random";} }; @@ -592,9 +592,9 @@ protected: cout << "## + Currently allocated : " << allocated << endl; cout << "## + Currently out : " << out << endl; cout << "############################" << endl; - if(fetched!=0) + if (fetched != 0) { - cout << "## Overall efficiency " << 100*double(hit)/fetched <<"%"<< endl; + cout << "## Overall efficiency " << 100 * double(hit) / fetched << "%" << endl; cout << "############################" << endl; } cout << endl; @@ -629,7 +629,7 @@ public: unsigned getMissed() {return fetched - hit;} unsigned getAllocated() {return allocated;} unsigned getOut() {return out;} - unsigned getDestroyed() {return created-allocated;} + unsigned getDestroyed() {return created - allocated;} }; /////////////////////////////////////////////////////////////////////////// @@ -712,7 +712,7 @@ private: AbstractProduct* const getPointerToObjectInContainer(ObjVector& entry) { - if(entry.empty()) // No object available + if (entry.empty()) // No object available { // the object will be created in the calling function. // It has to be created in the calling function because of @@ -723,7 +723,7 @@ private: { // returning the found object AbstractProduct* pObject(entry.back()); - assert(pObject!=NULL); + assert(pObject != NULL); entry.pop_back(); return pObject; } @@ -731,9 +731,9 @@ private: bool shouldCreateObject(AbstractProduct* const pProduct) { - if(pProduct!=NULL) // object already exists + if (pProduct != NULL) // object already exists return false; - if(CP::canCreate()==false) // Are we allowed to Create ? + if (CP::canCreate() == false) // Are we allowed to Create ? EP::evict(); // calling Eviction Policy to clean up return true; } @@ -797,16 +797,16 @@ protected: virtual void remove(AbstractProduct* const pProduct) { typename FetchedObjToKeyMap::iterator fetchedItr = providedObjects.find(pProduct); - if(fetchedItr!=providedObjects.end()) // object is unreleased. + if (fetchedItr != providedObjects.end()) // object is unreleased. throw CacheException(); bool productRemoved = false; typename KeyToObjVectorMap::iterator objVectorItr; typename ObjVector::iterator objItr; - for(objVectorItr=fromKeyToObjVector.begin(); objVectorItr!=fromKeyToObjVector.end(); ++objVectorItr) + for (objVectorItr = fromKeyToObjVector.begin(); objVectorItr != fromKeyToObjVector.end(); ++objVectorItr) { ObjVector& v((*objVectorItr).second); objItr = remove_if(v.begin(), v.end(), std::bind2nd(std::equal_to<AbstractProduct*>(), pProduct)); - if(objItr != v.end()) // we found the vector containing pProduct and removed it + if (objItr != v.end()) // we found the vector containing pProduct and removed it { onDestroy(pProduct); // warning policies we are about to destroy an object v.erase(objItr, v.end()); // real removing @@ -814,7 +814,7 @@ protected: break; } } - if(productRemoved==false) + if (productRemoved == false) throw CacheException(); // the product is not in the cache ?! delete pProduct; // deleting it } @@ -833,14 +833,14 @@ public: for_each(fromKeyToObjVector.begin(), fromKeyToObjVector.end(), deleteVectorObjects< typename KeyToObjVectorMap::value_type >() ); - if(!providedObjects.empty()) + if (!providedObjects.empty()) { // The factory is responsible for the creation and destruction of objects. // If objects are out during the destruction of the Factory : deleting anyway. // This might not be a good idea. But throwing an exception in a destructor is // considered as a bad pratice and asserting might be too much. // What to do ? Leaking memory or corrupting in use pointers ? hmm... - D( cout << "====>> Cache destructor : deleting "<< providedObjects.size()<<" in use objects <<====" << endl << endl; ) + D( cout << "====>> Cache destructor : deleting " << providedObjects.size() << " in use objects <<====" << endl << endl; ) for_each(providedObjects.begin(), providedObjects.end(), deleteMapKeys< typename FetchedObjToKeyMap::value_type >() ); @@ -878,7 +878,7 @@ public: { MyKey key(id); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { pProduct = factory.CreateObject(key.id); onCreate(pProduct); @@ -891,11 +891,11 @@ public: ProductReturn CreateObject(const IdentifierType& id, Parm1 p1) { - MyKey key(id,p1); + MyKey key(id, p1); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1); + pProduct = factory.CreateObject(key.id, key.p1); onCreate(pProduct); } onFetch(pProduct); @@ -906,11 +906,11 @@ public: ProductReturn CreateObject(const IdentifierType& id, Parm1 p1, Parm2 p2) { - MyKey key(id,p1,p2); + MyKey key(id, p1, p2); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2); + pProduct = factory.CreateObject(key.id, key.p1, key.p2); onCreate(pProduct); } onFetch(pProduct); @@ -921,11 +921,11 @@ public: ProductReturn CreateObject(const IdentifierType& id, Parm1 p1, Parm2 p2, Parm3 p3) { - MyKey key(id,p1,p2,p3); + MyKey key(id, p1, p2, p3); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3); onCreate(pProduct); } onFetch(pProduct); @@ -936,12 +936,12 @@ public: ProductReturn CreateObject(const IdentifierType& id, Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) { - MyKey key(id,p1,p2,p3,p4); + MyKey key(id, p1, p2, p3, p4); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4); onCreate(pProduct); } onFetch(pProduct); @@ -952,12 +952,12 @@ public: ProductReturn CreateObject(const IdentifierType& id, Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) { - MyKey key(id,p1,p2,p3,p4,p5); + MyKey key(id, p1, p2, p3, p4, p5); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5); onCreate(pProduct); } onFetch(pProduct); @@ -969,12 +969,12 @@ public: Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5, Parm6 p6) { - MyKey key(id,p1,p2,p3,p4,p5,p6); + MyKey key(id, p1, p2, p3, p4, p5, p6); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6); onCreate(pProduct); } onFetch(pProduct); @@ -986,12 +986,12 @@ public: Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5, Parm6 p6, Parm7 p7 ) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7); onCreate(pProduct); } onFetch(pProduct); @@ -1003,12 +1003,12 @@ public: Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5, Parm6 p6, Parm7 p7, Parm8 p8) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8); onCreate(pProduct); } onFetch(pProduct); @@ -1020,12 +1020,12 @@ public: Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5, Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9); onCreate(pProduct); } onFetch(pProduct); @@ -1035,14 +1035,14 @@ public: ProductReturn CreateObject(const IdentifierType& id, Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5, - Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9,Parm10 p10) + Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9, key.p10); onCreate(pProduct); } onFetch(pProduct); @@ -1055,12 +1055,12 @@ public: Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9, key.p10, key.p11); onCreate(pProduct); } onFetch(pProduct); @@ -1073,12 +1073,12 @@ public: Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11, Parm12 p12) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9, key.p10, key.p11, key.p12); onCreate(pProduct); } onFetch(pProduct); @@ -1091,13 +1091,13 @@ public: Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11, Parm12 p12, Parm13 p13) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12 - ,key.p13); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9, key.p10, key.p11, key.p12 + , key.p13); onCreate(pProduct); } onFetch(pProduct); @@ -1110,13 +1110,13 @@ public: Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12 - ,key.p13,key.p14); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9, key.p10, key.p11, key.p12 + , key.p13, key.p14); onCreate(pProduct); } onFetch(pProduct); @@ -1129,13 +1129,13 @@ public: Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) { - MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15); + MyKey key(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key))); - if(shouldCreateObject(pProduct)) + if (shouldCreateObject(pProduct)) { - pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3 - ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12 - ,key.p13,key.p14,key.p15); + pProduct = factory.CreateObject(key.id, key.p1, key.p2, key.p3 + , key.p4, key.p5, key.p6, key.p7, key.p8, key.p9, key.p10, key.p11, key.p12 + , key.p13, key.p14, key.p15); onCreate(pProduct); } onFetch(pProduct); @@ -1153,7 +1153,7 @@ public: { AbstractProduct* pProduct(NP::release(object)); typename FetchedObjToKeyMap::iterator itr = providedObjects.find(pProduct); - if(itr == providedObjects.end()) + if (itr == providedObjects.end()) throw CacheException(); onRelease(pProduct); ReleaseObjectFromContainer(getContainerFromKey((*itr).second), pProduct); diff --git a/shared/loki/Factory.h b/shared/loki/Factory.h index abf4ab3b..bf31afc5 100644 --- a/shared/loki/Factory.h +++ b/shared/loki/Factory.h @@ -140,25 +140,25 @@ struct FactoryImpl<AP, Id, NullType> virtual AP* CreateObject(const Id& id ) = 0; }; template <typename AP, typename Id, typename P1 > -struct FactoryImpl<AP,Id, Seq<P1> > +struct FactoryImpl<AP, Id, Seq<P1> > : public FactoryImplBase { typedef typename TypeTraits<P1>::ParameterType Parm1; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1 ) = 0; + virtual AP* CreateObject(const Id& id, Parm1 ) = 0; }; -template<typename AP, typename Id, typename P1,typename P2 > +template<typename AP, typename Id, typename P1, typename P2 > struct FactoryImpl<AP, Id, Seq<P1, P2> > : public FactoryImplBase { typedef typename TypeTraits<P1>::ParameterType Parm1; typedef typename TypeTraits<P2>::ParameterType Parm2; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2 ) = 0; + virtual AP* CreateObject(const Id& id, Parm1, Parm2 ) = 0; }; -template<typename AP, typename Id, typename P1,typename P2,typename P3 > +template<typename AP, typename Id, typename P1, typename P2, typename P3 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3> > : public FactoryImplBase { @@ -166,10 +166,10 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3> > typedef typename TypeTraits<P2>::ParameterType Parm2; typedef typename TypeTraits<P3>::ParameterType Parm3; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3 ) = 0; + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3 ) = 0; }; -template<typename AP, typename Id, typename P1,typename P2,typename P3,typename P4 > +template<typename AP, typename Id, typename P1, typename P2, typename P3, typename P4 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4> > : public FactoryImplBase { @@ -178,11 +178,11 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4> > typedef typename TypeTraits<P3>::ParameterType Parm3; typedef typename TypeTraits<P4>::ParameterType Parm4; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4 ) = 0; + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5 > +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5> > : public FactoryImplBase { @@ -192,12 +192,12 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5> > typedef typename TypeTraits<P4>::ParameterType Parm4; typedef typename TypeTraits<P5>::ParameterType Parm5; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0; + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6> > : public FactoryImplBase { @@ -208,14 +208,14 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6> > typedef typename TypeTraits<P5>::ParameterType Parm5; typedef typename TypeTraits<P6>::ParameterType Parm6; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7> > : public FactoryImplBase { @@ -227,14 +227,14 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7> > typedef typename TypeTraits<P6>::ParameterType Parm6; typedef typename TypeTraits<P7>::ParameterType Parm7; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8> > : public FactoryImplBase { @@ -247,14 +247,14 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8> > typedef typename TypeTraits<P7>::ParameterType Parm7; typedef typename TypeTraits<P8>::ParameterType Parm8; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9> > : public FactoryImplBase { @@ -268,14 +268,14 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9> > typedef typename TypeTraits<P8>::ParameterType Parm8; typedef typename TypeTraits<P9>::ParameterType Parm9; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> > : public FactoryImplBase { @@ -290,15 +290,15 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> > typedef typename TypeTraits<P9>::ParameterType Parm9; typedef typename TypeTraits<P10>::ParameterType Parm10; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10) + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> > : public FactoryImplBase { @@ -314,16 +314,16 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> > typedef typename TypeTraits<P10>::ParameterType Parm10; typedef typename TypeTraits<P11>::ParameterType Parm11; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, Parm11) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> > : public FactoryImplBase { @@ -340,16 +340,16 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 typedef typename TypeTraits<P11>::ParameterType Parm11; typedef typename TypeTraits<P12>::ParameterType Parm12; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, - Parm11,Parm12) + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, + Parm11, Parm12) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12,typename P13> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12, typename P13 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> > : public FactoryImplBase { @@ -367,16 +367,16 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 typedef typename TypeTraits<P12>::ParameterType Parm12; typedef typename TypeTraits<P13>::ParameterType Parm13; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, - Parm11,Parm12,Parm13) + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, + Parm11, Parm12, Parm13) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12,typename P13,typename P14> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12, typename P13, typename P14 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> > : public FactoryImplBase { @@ -395,16 +395,16 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 typedef typename TypeTraits<P13>::ParameterType Parm13; typedef typename TypeTraits<P14>::ParameterType Parm14; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm8,Parm10, - Parm11,Parm12,Parm13,Parm14) + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm8, Parm10, + Parm11, Parm12, Parm13, Parm14) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12,typename P13,typename P14,typename P15 > +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12, typename P13, typename P14, typename P15 > struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> > : public FactoryImplBase { @@ -424,34 +424,34 @@ struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 typedef typename TypeTraits<P14>::ParameterType Parm14; typedef typename TypeTraits<P15>::ParameterType Parm15; virtual ~FactoryImpl() {} - virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, - Parm11,Parm12,Parm13,Parm14,Parm15 ) + virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, + Parm11, Parm12, Parm13, Parm14, Parm15 ) = 0; }; #ifndef LOKI_DISABLE_TYPELIST_MACROS template <typename AP, typename Id, typename P1 > -struct FactoryImpl<AP,Id, LOKI_TYPELIST_1( P1 )> +struct FactoryImpl<AP, Id, LOKI_TYPELIST_1( P1 )> : public FactoryImplBase { typedef typename TypeTraits<P1>::ParameterType Parm1; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1 ) = 0; +virtual AP* CreateObject(const Id& id, Parm1 ) = 0; }; -template<typename AP, typename Id, typename P1,typename P2 > +template<typename AP, typename Id, typename P1, typename P2 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_2( P1, P2 )> : public FactoryImplBase { typedef typename TypeTraits<P1>::ParameterType Parm1; typedef typename TypeTraits<P2>::ParameterType Parm2; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2 ) = 0; +virtual AP* CreateObject(const Id& id, Parm1, Parm2 ) = 0; }; -template<typename AP, typename Id, typename P1,typename P2,typename P3 > +template<typename AP, typename Id, typename P1, typename P2, typename P3 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_3( P1, P2, P3 )> : public FactoryImplBase { @@ -459,10 +459,10 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_3( P1, P2, P3 )> typedef typename TypeTraits<P2>::ParameterType Parm2; typedef typename TypeTraits<P3>::ParameterType Parm3; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3 ) = 0; +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3 ) = 0; }; -template<typename AP, typename Id, typename P1,typename P2,typename P3,typename P4 > +template<typename AP, typename Id, typename P1, typename P2, typename P3, typename P4 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_4( P1, P2, P3, P4 )> : public FactoryImplBase { @@ -471,11 +471,11 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_4( P1, P2, P3, P4 )> typedef typename TypeTraits<P3>::ParameterType Parm3; typedef typename TypeTraits<P4>::ParameterType Parm4; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4 ) = 0; +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5 > +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_5( P1, P2, P3, P4, P5 )> : public FactoryImplBase { @@ -485,12 +485,12 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_5( P1, P2, P3, P4, P5 )> typedef typename TypeTraits<P4>::ParameterType Parm4; typedef typename TypeTraits<P5>::ParameterType Parm5; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0; +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_6( P1, P2, P3, P4, P5, P6 )> : public FactoryImplBase { @@ -501,14 +501,14 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_6( P1, P2, P3, P4, P5, P6 )> typedef typename TypeTraits<P5>::ParameterType Parm5; typedef typename TypeTraits<P6>::ParameterType Parm6; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_7( P1, P2, P3, P4, P5, P6, P7 )> : public FactoryImplBase { @@ -520,14 +520,14 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_7( P1, P2, P3, P4, P5, P6, P7 )> typedef typename TypeTraits<P6>::ParameterType Parm6; typedef typename TypeTraits<P7>::ParameterType Parm7; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7 ) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_8( P1, P2, P3, P4, P5, P6, P7, P8 )> : public FactoryImplBase { @@ -540,14 +540,14 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_8( P1, P2, P3, P4, P5, P6, P7, P8 )> typedef typename TypeTraits<P7>::ParameterType Parm7; typedef typename TypeTraits<P8>::ParameterType Parm8; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_9( P1, P2, P3, P4, P5, P6, P7, P8, P9 )> : public FactoryImplBase { @@ -561,14 +561,14 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_9( P1, P2, P3, P4, P5, P6, P7, P8, P9 ) typedef typename TypeTraits<P8>::ParameterType Parm8; typedef typename TypeTraits<P9>::ParameterType Parm9; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, Parm6, Parm7, Parm8, Parm9) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_10( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 )> : public FactoryImplBase { @@ -583,15 +583,15 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_10( P1, P2, P3, P4, P5, P6, P7, P8, P9, typedef typename TypeTraits<P9>::ParameterType Parm9; typedef typename TypeTraits<P10>::ParameterType Parm10; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10) +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_11( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 )> : public FactoryImplBase { @@ -607,16 +607,16 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_11( P1, P2, P3, P4, P5, P6, P7, P8, P9, typedef typename TypeTraits<P10>::ParameterType Parm10; typedef typename TypeTraits<P11>::ParameterType Parm11; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, Parm11) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_12( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 )> : public FactoryImplBase { @@ -633,16 +633,16 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_12( P1, P2, P3, P4, P5, P6, P7, P8, P9, typedef typename TypeTraits<P11>::ParameterType Parm11; typedef typename TypeTraits<P12>::ParameterType Parm12; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, - Parm11,Parm12) +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, + Parm11, Parm12) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12,typename P13> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12, typename P13 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_13( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13 )> : public FactoryImplBase { @@ -660,16 +660,16 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_13( P1, P2, P3, P4, P5, P6, P7, P8, P9, typedef typename TypeTraits<P12>::ParameterType Parm12; typedef typename TypeTraits<P13>::ParameterType Parm13; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, - Parm11,Parm12,Parm13) +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, + Parm11, Parm12, Parm13) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12,typename P13,typename P14> +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12, typename P13, typename P14 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_14( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14 )> : public FactoryImplBase { @@ -688,16 +688,16 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_14( P1, P2, P3, P4, P5, P6, P7, P8, P9, typedef typename TypeTraits<P13>::ParameterType Parm13; typedef typename TypeTraits<P14>::ParameterType Parm14; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm8,Parm10, - Parm11,Parm12,Parm13,Parm14) +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm8, Parm10, + Parm11, Parm12, Parm13, Parm14) = 0; }; -template<typename AP, typename Id, - typename P1,typename P2,typename P3,typename P4,typename P5, - typename P6,typename P7,typename P8,typename P9,typename P10, - typename P11,typename P12,typename P13,typename P14,typename P15 > +template < typename AP, typename Id, + typename P1, typename P2, typename P3, typename P4, typename P5, + typename P6, typename P7, typename P8, typename P9, typename P10, + typename P11, typename P12, typename P13, typename P14, typename P15 > struct FactoryImpl<AP, Id, LOKI_TYPELIST_15( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15 )> : public FactoryImplBase { @@ -717,9 +717,9 @@ struct FactoryImpl<AP, Id, LOKI_TYPELIST_15( P1, P2, P3, P4, P5, P6, P7, P8, P9, typedef typename TypeTraits<P14>::ParameterType Parm14; typedef typename TypeTraits<P15>::ParameterType Parm15; virtual ~FactoryImpl() {} -virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5, - Parm6, Parm7, Parm8, Parm9,Parm10, - Parm11,Parm12,Parm13,Parm14,Parm15 ) +virtual AP* CreateObject(const Id& id, Parm1, Parm2, Parm3, Parm4, Parm5, + Parm6, Parm7, Parm8, Parm9, Parm10, + Parm11, Parm12, Parm13, Parm14, Parm15 ) = 0; }; @@ -809,8 +809,8 @@ public: std::vector<IdentifierType> RegisteredIds() { std::vector<IdentifierType> ids; - for(typename IdToProductMap::iterator it = associations_.begin(); - it != associations_.end(); ++it) + for (typename IdToProductMap::iterator it = associations_.begin(); + it != associations_.end(); ++it) { ids.push_back(it->first); } @@ -839,7 +839,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2 ); + return (i->second)( p1, p2 ); return this->OnUnknownType(id); } @@ -848,7 +848,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3 ); + return (i->second)( p1, p2, p3 ); return this->OnUnknownType(id); } @@ -857,7 +857,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4 ); + return (i->second)( p1, p2, p3, p4 ); return this->OnUnknownType(id); } @@ -866,7 +866,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5 ); + return (i->second)( p1, p2, p3, p4, p5 ); return this->OnUnknownType(id); } @@ -876,7 +876,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6 ); + return (i->second)( p1, p2, p3, p4, p5, p6 ); return this->OnUnknownType(id); } @@ -886,7 +886,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7 ); return this->OnUnknownType(id); } @@ -896,7 +896,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8 ); return this->OnUnknownType(id); } @@ -906,16 +906,16 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9 ); return this->OnUnknownType(id); } AbstractProduct* CreateObject(const IdentifierType& id, Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5, - Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9,Parm10 p10) + Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 ); return this->OnUnknownType(id); } @@ -926,7 +926,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 ); return this->OnUnknownType(id); } @@ -937,7 +937,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 ); return this->OnUnknownType(id); } @@ -948,7 +948,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 ); return this->OnUnknownType(id); } @@ -959,7 +959,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14 ); return this->OnUnknownType(id); } @@ -970,7 +970,7 @@ public: { typename IdToProductMap::iterator i = associations_.find(id); if (i != associations_.end()) - return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15 ); + return (i->second)( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15 ); return this->OnUnknownType(id); } diff --git a/shared/loki/Function.h b/shared/loki/Function.h index f2badfe9..5f388d3c 100644 --- a/shared/loki/Function.h +++ b/shared/loki/Function.h @@ -54,7 +54,7 @@ struct Function<R()> : public Functor<R> Function(const Function& func) : FBase() { - if( !func.empty()) + if ( !func.empty()) FBase::operator=(func); } @@ -62,14 +62,14 @@ Function(const Function& func) : FBase() template<class R2> Function(Function<R2()> func) : FBase() { - if(!func.empty()) + if (!func.empty()) FBase::operator=(func); } // clear by '= 0' Function(const int i) : FBase() { - if(i==0) + if (i == 0) FBase::clear(); else throw std::runtime_error("Loki::Function(const int i): i!=0"); @@ -79,7 +79,7 @@ template<class Func> Function(Func func) : FBase(func) {} template<class Host, class Func> -Function(const Host& host, const Func& func) : FBase(host,func) {} +Function(const Host& host, const Func& func) : FBase(host, func) {} }; @@ -89,38 +89,38 @@ Function(const Host& host, const Func& func) : FBase(host,func) {} //////////////////////////////////////////////////////////////////////////////// #define LOKI_FUNCTION_BODY \ - \ - Function() : FBase() {} \ - \ - Function(const Function& func) : FBase() \ - { \ - if( !func.empty()) \ - FBase::operator=(func); \ - } \ - \ - Function(const int i) : FBase() \ - { \ - if(i==0) \ - FBase::clear(); \ - else \ - throw std::runtime_error( \ - "Loki::Function(const int i): i!=0"); \ - } \ - \ - template<class Func> \ - Function(Func func) : FBase(func) {} \ - \ - template<class Host, class Func> \ - Function(const Host& host, const Func& func): FBase(host,func) {} + \ + Function() : FBase() {} \ + \ + Function(const Function& func) : FBase() \ + { \ + if( !func.empty()) \ + FBase::operator=(func); \ + } \ + \ + Function(const int i) : FBase() \ + { \ + if(i==0) \ + FBase::clear(); \ + else \ + throw std::runtime_error( \ + "Loki::Function(const int i): i!=0"); \ + } \ + \ + template<class Func> \ + Function(Func func) : FBase(func) {} \ + \ + template<class Host, class Func> \ + Function(const Host& host, const Func& func): FBase(host,func) {} #define LOKI_FUNCTION_R2_CTOR_BODY \ - \ - : FBase() \ - { \ - if(!func.empty()) \ - FBase::operator=(func); \ - } + \ + : FBase() \ + { \ + if(!func.empty()) \ + FBase::operator=(func); \ + } //////////////////////////////////////////////////////////////////////////////// @@ -143,225 +143,225 @@ struct Function<> // or define LOKI_ENABLE_FUNCTION }; -template<class R,class P01> +template<class R, class P01> struct Function<R(P01)> : public Loki::Functor<R, Seq<P01> > { typedef Functor<R, Seq<P01> > FBase; - template<class R2,class Q01> + template<class R2, class Q01> Function(Function<R2(Q01)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R,class P01,class P02> -struct Function<R(P01,P02)> -: public Functor<R, Seq<P01,P02> > +template<class R, class P01, class P02> +struct Function<R(P01, P02)> +: public Functor<R, Seq<P01, P02> > { - typedef Functor<R, Seq<P01,P02> > FBase; + typedef Functor<R, Seq<P01, P02> > FBase; - template<class R2,class Q01, class Q02> - Function(Function<R2(Q01,Q02)> func) + template<class R2, class Q01, class Q02> + Function(Function<R2(Q01, Q02)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R,class P01,class P02, class P03> -struct Function<R(P01,P02,P03)> -: public Functor<R, Seq<P01,P02,P03> > +template<class R, class P01, class P02, class P03> +struct Function<R(P01, P02, P03)> +: public Functor<R, Seq<P01, P02, P03> > { - typedef Functor<R, Seq<P01,P02,P03> > FBase; + typedef Functor<R, Seq<P01, P02, P03> > FBase; - template<class R2,class Q01, class Q02,class Q03> - Function(Function<R2(Q01,Q02,Q03)> func) + template<class R2, class Q01, class Q02, class Q03> + Function(Function<R2(Q01, Q02, Q03)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R,class P01,class P02, class P03,class P04> -struct Function<R(P01,P02,P03,P04)> -: public Functor<R, Seq<P01,P02,P03,P04> > +template<class R, class P01, class P02, class P03, class P04> +struct Function<R(P01, P02, P03, P04)> +: public Functor<R, Seq<P01, P02, P03, P04> > { - typedef Functor<R, Seq<P01,P02,P03,P04> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04> > FBase; - template<class R2,class Q01,class Q02, class Q03,class Q04> - Function(Function<R2(Q01,Q02,Q03,Q04)> func) + template<class R2, class Q01, class Q02, class Q03, class Q04> + Function(Function<R2(Q01, Q02, Q03, Q04)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R,class P01,class P02, class P03,class P04,class P05> -struct Function<R(P01,P02,P03,P04,P05)> -: public Functor<R, Seq<P01,P02,P03,P04,P05> > +template<class R, class P01, class P02, class P03, class P04, class P05> +struct Function<R(P01, P02, P03, P04, P05)> +: public Functor<R, Seq<P01, P02, P03, P04, P05> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05> > FBase; - template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func) + template<class R2, class Q01, class Q02, class Q03, class Q04, class Q05> + Function(Function<R2(Q01, Q02, Q03, Q04, Q05)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06> -struct Function<R(P01,P02,P03,P04,P05,P06)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06 > +struct Function<R(P01, P02, P03, P04, P05, P06)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07> -struct Function<R(P01,P02,P03,P04,P05,P06,P07)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09 > > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09 > > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09,class P10> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09, class P10 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09, P10)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09,class Q10> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09, class Q10 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09, Q10)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09,class P10, - class P11> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09, class P10, + class P11 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11> >FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09,class Q10, - class Q11> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09, class Q10, + class Q11 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09, Q10, Q11)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09,class P10, - class P11,class P12> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09, class P10, + class P11, class P12 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09,class Q10, - class Q11,class Q12> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09, class Q10, + class Q11, class Q12 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09, Q10, Q11, Q12)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09,class P10, - class P11,class P12, class P13> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09, class P10, + class P11, class P12, class P13 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09,class Q10, - class Q11,class Q12, class Q13> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09, class Q10, + class Q11, class Q12, class Q13 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09, Q10, Q11, Q12, Q13)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09,class P10, - class P11,class P12, class P13,class P14> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09, class P10, + class P11, class P12, class P13, class P14 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09,class Q10, - class Q11,class Q12, class Q13,class Q14> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func) + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14> > FBase; + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09, class Q10, + class Q11, class Q12, class Q13, class Q14 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09, Q10, Q11, Q12, Q13, Q14)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY }; -template<class R, class P01,class P02, class P03,class P04,class P05, - class P06,class P07, class P08,class P09,class P10, - class P11,class P12, class P13,class P14,class P15> -struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)> -: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > +template < class R, class P01, class P02, class P03, class P04, class P05, + class P06, class P07, class P08, class P09, class P10, + class P11, class P12, class P13, class P14, class P15 > +struct Function<R(P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15)> +: public Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15> > { - typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > FBase; + typedef Functor<R, Seq<P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15> > FBase; - template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05, - class Q06,class Q07, class Q08,class Q09,class Q10, - class Q11,class Q12, class Q13,class Q14,class Q15> - Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func) + template < class R2, class Q01, class Q02, class Q03, class Q04, class Q05, + class Q06, class Q07, class Q08, class Q09, class Q10, + class Q11, class Q12, class Q13, class Q14, class Q15 > + Function(Function<R2(Q01, Q02, Q03, Q04, Q05, Q06, Q07, Q08, Q09, Q10, Q11, Q12, Q13, Q14, Q15)> func) LOKI_FUNCTION_R2_CTOR_BODY LOKI_FUNCTION_BODY diff --git a/shared/loki/Functor.h b/shared/loki/Functor.h index a03f87c8..664af077 100644 --- a/shared/loki/Functor.h +++ b/shared/loki/Functor.h @@ -122,8 +122,8 @@ struct FunctorImplBase // Specializations of FunctorImpl for up to 15 parameters follow //////////////////////////////////////////////////////////////////////////////// -template <typename R, class TList, - template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL> +template < typename R, class TList, + template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL > class FunctorImpl; //////////////////////////////////////////////////////////////////////////////// @@ -160,8 +160,8 @@ public: // Specialization for 2 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, - template <class, class> class ThreadingModel> +template < typename R, typename P1, typename P2, + template <class, class> class ThreadingModel > class FunctorImpl<R, Seq<P1, P2>, ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -177,8 +177,8 @@ public: // Specialization for 3 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, - template <class, class> class ThreadingModel> +template < typename R, typename P1, typename P2, typename P3, + template <class, class> class ThreadingModel > class FunctorImpl<R, Seq<P1, P2, P3>, ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -195,8 +195,8 @@ public: // Specialization for 4 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, - template <class, class> class ThreadingModel> +template < typename R, typename P1, typename P2, typename P3, typename P4, + template <class, class> class ThreadingModel > class FunctorImpl<R, Seq<P1, P2, P3, P4>, ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -214,9 +214,9 @@ public: // Specialization for 5 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, - template <class, class> class ThreadingModel> + template <class, class> class ThreadingModel > class FunctorImpl<R, Seq<P1, P2, P3, P4, P5>, ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -235,9 +235,9 @@ public: // Specialization for 6 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, - template <class, class> class ThreadingModel> + template <class, class> class ThreadingModel > class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6>, ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -257,9 +257,9 @@ public: // Specialization for 7 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, - template <class, class> class ThreadingModel> + template <class, class> class ThreadingModel > class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7>, ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -281,11 +281,11 @@ public: // Specialization for 8 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, - template <class, class> class ThreadingModel> -class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8>, - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, Seq<P1, P2, P3, P4, P5, P6, P7, P8>, + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -307,11 +307,11 @@ public: // Specialization for 9 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, - template <class, class> class ThreadingModel> -class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9>, - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9>, + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -334,12 +334,12 @@ public: // Specialization for 10 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, - template <class, class> class ThreadingModel> -class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>, - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>, + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -363,13 +363,13 @@ public: // Specialization for 11 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>, - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -394,13 +394,13 @@ public: // Specialization for 12 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>, - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -426,13 +426,13 @@ public: // Specialization for 13 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>, - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -459,14 +459,14 @@ public: // Specialization for 14 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, - template <class, class> class ThreadingModel> -class FunctorImpl<R, - Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, - P14>, - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, + Seq < P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, + P14 > , + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -494,14 +494,14 @@ public: // Specialization for 15 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, - typename P15, template <class, class> class ThreadingModel> -class FunctorImpl<R, - Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, - P14, P15>, - ThreadingModel> + typename P15, template <class, class> class ThreadingModel > +class FunctorImpl < R, + Seq < P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, + P14, P15 > , + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -548,8 +548,8 @@ public: // Specialization for 2 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, - template <class, class> class ThreadingModel> +template < typename R, typename P1, typename P2, + template <class, class> class ThreadingModel > class FunctorImpl<R, LOKI_TYPELIST_2(P1, P2), ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -565,8 +565,8 @@ public: // Specialization for 3 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, - template <class, class> class ThreadingModel> +template < typename R, typename P1, typename P2, typename P3, + template <class, class> class ThreadingModel > class FunctorImpl<R, LOKI_TYPELIST_3(P1, P2, P3), ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -583,8 +583,8 @@ public: // Specialization for 4 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, - template <class, class> class ThreadingModel> +template < typename R, typename P1, typename P2, typename P3, typename P4, + template <class, class> class ThreadingModel > class FunctorImpl<R, LOKI_TYPELIST_4(P1, P2, P3, P4), ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -602,9 +602,9 @@ public: // Specialization for 5 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, - template <class, class> class ThreadingModel> + template <class, class> class ThreadingModel > class FunctorImpl<R, LOKI_TYPELIST_5(P1, P2, P3, P4, P5), ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -623,9 +623,9 @@ public: // Specialization for 6 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, - template <class, class> class ThreadingModel> + template <class, class> class ThreadingModel > class FunctorImpl<R, LOKI_TYPELIST_6(P1, P2, P3, P4, P5, P6), ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -645,9 +645,9 @@ public: // Specialization for 7 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, - template <class, class> class ThreadingModel> + template <class, class> class ThreadingModel > class FunctorImpl<R, LOKI_TYPELIST_7(P1, P2, P3, P4, P5, P6, P7), ThreadingModel> : public Private::FunctorImplBase<R, ThreadingModel> { @@ -669,11 +669,11 @@ public: // Specialization for 8 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, - template <class, class> class ThreadingModel> -class FunctorImpl<R, LOKI_TYPELIST_8(P1, P2, P3, P4, P5, P6, P7, P8), - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_8(P1, P2, P3, P4, P5, P6, P7, P8), + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -695,11 +695,11 @@ public: // Specialization for 9 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, - template <class, class> class ThreadingModel> -class FunctorImpl<R, LOKI_TYPELIST_9(P1, P2, P3, P4, P5, P6, P7, P8, P9), - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_9(P1, P2, P3, P4, P5, P6, P7, P8, P9), + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -722,12 +722,12 @@ public: // Specialization for 10 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, - template <class, class> class ThreadingModel> -class FunctorImpl<R, LOKI_TYPELIST_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10), - ThreadingModel> + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10), + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -751,13 +751,13 @@ public: // Specialization for 11 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11), - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -782,13 +782,13 @@ public: // Specialization for 12 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_12(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12), - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -814,13 +814,13 @@ public: // Specialization for 13 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_13(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13), - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -847,14 +847,14 @@ public: // Specialization for 14 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, - template <class, class> class ThreadingModel> -class FunctorImpl<R, + template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_14(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14), - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -882,14 +882,14 @@ public: // Specialization for 15 parameters //////////////////////////////////////////////////////////////////////////////// -template <typename R, typename P1, typename P2, typename P3, typename P4, +template < typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7, typename P8, typename P9, typename P10, typename P11, typename P12, typename P13, typename P14, - typename P15, template <class, class> class ThreadingModel> -class FunctorImpl<R, + typename P15, template <class, class> class ThreadingModel > +class FunctorImpl < R, LOKI_TYPELIST_15(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15), - ThreadingModel> + ThreadingModel > : public Private::FunctorImplBase<R, ThreadingModel> { public: @@ -957,13 +957,13 @@ public: { // there is no static information if Functor holds a member function // or a free function; this is the main difference to tr1::function - if(typeid(*this) != typeid(rhs)) + if (typeid(*this) != typeid(rhs)) return false; // cannot be equal const FunctorHandler& fh = static_cast<const FunctorHandler&>(rhs); // if this line gives a compiler error, you are using a function object. // you need to implement bool MyFnObj::operator == (const MyFnObj&) const; - return f_==fh.f_; + return f_ == fh.f_; } #endif // operator() implementations for up to 15 arguments @@ -1045,8 +1045,8 @@ private: // Wraps pointers to member functions //////////////////////////////////////////////////////////////////////////////// -template <class ParentFunctor, typename PointerToObj, - typename PointerToMemFn> +template < class ParentFunctor, typename PointerToObj, + typename PointerToMemFn > class MemFunHandler : public ParentFunctor::Impl { typedef typename ParentFunctor::Impl Base; @@ -1080,13 +1080,13 @@ public: bool operator==(const typename Base::FunctorImplBaseType& rhs) const { - if(typeid(*this) != typeid(rhs)) + if (typeid(*this) != typeid(rhs)) return false; // cannot be equal const MemFunHandler& mfh = static_cast<const MemFunHandler&>(rhs); // if this line gives a compiler error, you are using a function object. // you need to implement bool MyFnObj::operator == (const MyFnObj&) const; - return pObj_==mfh.pObj_ && pMemFn_==mfh.pMemFn_; + return pObj_ == mfh.pObj_ && pMemFn_ == mfh.pMemFn_; } #endif @@ -1215,8 +1215,8 @@ public: /// objects which have no operator== implemented, keep in mind when you enable /// operator==. //////////////////////////////////////////////////////////////////////////////// -template <typename R = void, class TList = NullType, - template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL> +template < typename R = void, class TList = NullType, + template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL > class Functor { public: @@ -1295,9 +1295,9 @@ public: bool operator==(const Functor& rhs) const { - if(spImpl_.get()==0 && rhs.spImpl_.get()==0) + if (spImpl_.get() == 0 && rhs.spImpl_.get() == 0) return true; - if(spImpl_.get()!=0 && rhs.spImpl_.get()!=0) + if (spImpl_.get() != 0 && rhs.spImpl_.get() != 0) return *spImpl_.get() == *rhs.spImpl_.get(); else return false; @@ -1305,7 +1305,7 @@ public: bool operator!=(const Functor& rhs) const { - return !(*this==rhs); + return !(*this == rhs); } #endif @@ -1445,7 +1445,7 @@ struct BinderFirstTraits< Functor<R, TList, ThreadingModel> > { typedef Functor<R, TList, ThreadingModel> OriginalFunctor; - typedef typename TL::Erase<TList,typename TL::TypeAt<TList, 0>::Result> + typedef typename TL::Erase<TList, typename TL::TypeAt<TList, 0>::Result> ::Result ParmList; @@ -1493,9 +1493,9 @@ class BinderFirst typedef typename OriginalFunctor::Parm1 BoundType; - typedef typename Private::BinderFirstBoundTypeStorage< + typedef typename Private::BinderFirstBoundTypeStorage < typename Private::BinderFirstTraits<OriginalFunctor> - ::OriginalParm1> + ::OriginalParm1 > ::RefOrValue BoundTypeStorage; @@ -1527,7 +1527,7 @@ public: bool operator==(const typename Base::FunctorImplBaseType& rhs) const { - if(typeid(*this) != typeid(rhs)) + if (typeid(*this) != typeid(rhs)) return false; // cannot be equal // if this line gives a compiler error, you are using a function object. // you need to implement bool MyFnObj::operator == (const MyFnObj&) const; @@ -1659,7 +1659,7 @@ public: bool operator==(const typename Base::Impl::FunctorImplBaseType& rhs) const { - if(typeid(*this) != typeid(rhs)) + if (typeid(*this) != typeid(rhs)) return false; // cannot be equal // if this line gives a compiler error, you are using a function object. // you need to implement bool MyFnObj::operator == (const MyFnObj&) const; diff --git a/shared/loki/HierarchyGenerators.h b/shared/loki/HierarchyGenerators.h index 83ec194c..126e0f3e 100644 --- a/shared/loki/HierarchyGenerators.h +++ b/shared/loki/HierarchyGenerators.h @@ -164,14 +164,14 @@ struct FieldHelper<H, 0> typedef const typename H::LeftBase ConstLeftBase; - typedef typename Select<isConst, ConstLeftBase, - typename H::LeftBase>::Result LeftBase; + typedef typename Select < isConst, ConstLeftBase, + typename H::LeftBase >::Result LeftBase; - typedef typename Select<isTuple, ElementType, - UnitType>::Result UnqualifiedResultType; + typedef typename Select < isTuple, ElementType, + UnitType >::Result UnqualifiedResultType; - typedef typename Select<isConst, const UnqualifiedResultType, - UnqualifiedResultType>::Result ResultType; + typedef typename Select < isConst, const UnqualifiedResultType, + UnqualifiedResultType >::Result ResultType; static ResultType& Do(H& obj) { @@ -194,19 +194,19 @@ struct FieldHelper typedef const typename H::RightBase ConstRightBase; - typedef typename Select<isConst, ConstRightBase, - typename H::RightBase>::Result RightBase; + typedef typename Select < isConst, ConstRightBase, + typename H::RightBase >::Result RightBase; - typedef typename Select<isTuple, ElementType, - UnitType>::Result UnqualifiedResultType; + typedef typename Select < isTuple, ElementType, + UnitType >::Result UnqualifiedResultType; - typedef typename Select<isConst, const UnqualifiedResultType, - UnqualifiedResultType>::Result ResultType; + typedef typename Select < isConst, const UnqualifiedResultType, + UnqualifiedResultType >::Result ResultType; static ResultType& Do(H& obj) { RightBase& rightBase = obj; - return FieldHelper<RightBase, i - 1>::Do(rightBase); + return FieldHelper < RightBase, i - 1 >::Do(rightBase); } }; diff --git a/shared/loki/Key.h b/shared/loki/Key.h index c80d6f4e..a416d6a9 100644 --- a/shared/loki/Key.h +++ b/shared/loki/Key.h @@ -28,7 +28,7 @@ namespace Loki { -template< +template < class Factory, typename IdentifierType > @@ -44,7 +44,7 @@ bool operator<(const Key<F, I> &k1, const Key<F, I> &k2); /** * A Key class */ -template< +template < class Factory, typename IdentifierType > @@ -200,7 +200,7 @@ public: Key(const IdentifierType& id, Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5, - Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9,Parm10& p10) : count(10) + Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9, Parm10& p10) : count(10) { this->id = id; this->p1 = p1; @@ -331,209 +331,209 @@ public: template<class F, typename I> bool operator==(const Key<F, I> &k1, const Key<F, I> &k2) { - if( k1.count != k2.count ) + if ( k1.count != k2.count ) return false; - switch(k1.count) + switch (k1.count) { case -1: return true; case 0: - if( k1.id == k2.id ) + if ( k1.id == k2.id ) return true; else return false; case 1: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) ) return true; else return false; case 2: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) ) return true; else return false; case 3: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) ) return true; else return false; case 4: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) ) return true; else return false; case 5: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) ) return true; else return false; case 6: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) ) return true; else return false; case 7: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) ) return true; else return false; case 8: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) ) return true; else return false; case 9: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) ) return true; else return false; case 10: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) && - (k1.p10 == k2.p10) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) && + (k1.p10 == k2.p10) ) return true; else return false; case 11: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) && - (k1.p10 == k2.p10) && - (k1.p11 == k2.p11) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) && + (k1.p10 == k2.p10) && + (k1.p11 == k2.p11) ) return true; else return false; case 12: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) && - (k1.p10 == k2.p10) && - (k1.p11 == k2.p11) && - (k1.p12 == k2.p12) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) && + (k1.p10 == k2.p10) && + (k1.p11 == k2.p11) && + (k1.p12 == k2.p12) ) return true; else return false; case 13: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) && - (k1.p10 == k2.p10) && - (k1.p11 == k2.p11) && - (k1.p12 == k2.p12) && - (k1.p13 == k2.p13) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) && + (k1.p10 == k2.p10) && + (k1.p11 == k2.p11) && + (k1.p12 == k2.p12) && + (k1.p13 == k2.p13) ) return true; else return false; case 14: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) && - (k1.p10 == k2.p10) && - (k1.p11 == k2.p11) && - (k1.p12 == k2.p12) && - (k1.p13 == k2.p13) && - (k1.p14 == k2.p14) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) && + (k1.p10 == k2.p10) && + (k1.p11 == k2.p11) && + (k1.p12 == k2.p12) && + (k1.p13 == k2.p13) && + (k1.p14 == k2.p14) ) return true; else return false; case 15: - if( (k1.id == k2.id) && - (k1.p1 == k2.p1) && - (k1.p2 == k2.p2) && - (k1.p3 == k2.p3) && - (k1.p4 == k2.p4) && - (k1.p5 == k2.p5) && - (k1.p6 == k2.p6) && - (k1.p7 == k2.p7) && - (k1.p8 == k2.p8) && - (k1.p9 == k2.p9) && - (k1.p10 == k2.p10) && - (k1.p11 == k2.p11) && - (k1.p12 == k2.p12) && - (k1.p13 == k2.p13) && - (k1.p14 == k2.p14) && - (k1.p15 == k2.p15) ) + if ( (k1.id == k2.id) && + (k1.p1 == k2.p1) && + (k1.p2 == k2.p2) && + (k1.p3 == k2.p3) && + (k1.p4 == k2.p4) && + (k1.p5 == k2.p5) && + (k1.p6 == k2.p6) && + (k1.p7 == k2.p7) && + (k1.p8 == k2.p8) && + (k1.p9 == k2.p9) && + (k1.p10 == k2.p10) && + (k1.p11 == k2.p11) && + (k1.p12 == k2.p12) && + (k1.p13 == k2.p13) && + (k1.p14 == k2.p14) && + (k1.p15 == k2.p15) ) return true; else return false; @@ -547,209 +547,209 @@ bool operator==(const Key<F, I> &k1, const Key<F, I> &k2) template<class F, typename I> bool operator<(const Key<F, I> &k1, const Key<F, I> &k2) { - if( k1.count < k2.count ) + if ( k1.count < k2.count ) return true; - switch(k1.count) + switch (k1.count) { case -1: return false; case 0: - if( k1.id < k2.id ) + if ( k1.id < k2.id ) return true; else return false; case 1: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) ) return true; else return false; case 2: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) ) return true; else return false; case 3: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) ) return true; else return false; case 4: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) ) return true; else return false; case 5: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) ) return true; else return false; case 6: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) ) return true; else return false; case 7: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) ) return true; else return false; case 8: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) ) return true; else return false; case 9: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) ) return true; else return false; case 10: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) || - (k1.p10 < k2.p10) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) || + (k1.p10 < k2.p10) ) return true; else return false; case 11: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) || - (k1.p10 < k2.p10) || - (k1.p11 < k2.p11) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) || + (k1.p10 < k2.p10) || + (k1.p11 < k2.p11) ) return true; else return false; case 12: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) || - (k1.p10 < k2.p10) || - (k1.p11 < k2.p11) || - (k1.p12 < k2.p12) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) || + (k1.p10 < k2.p10) || + (k1.p11 < k2.p11) || + (k1.p12 < k2.p12) ) return true; else return false; case 13: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) || - (k1.p10 < k2.p10) || - (k1.p11 < k2.p11) || - (k1.p12 < k2.p12) || - (k1.p13 < k2.p13) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) || + (k1.p10 < k2.p10) || + (k1.p11 < k2.p11) || + (k1.p12 < k2.p12) || + (k1.p13 < k2.p13) ) return true; else return false; case 14: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) || - (k1.p10 < k2.p10) || - (k1.p11 < k2.p11) || - (k1.p12 < k2.p12) || - (k1.p13 < k2.p13) || - (k1.p14 < k2.p14) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) || + (k1.p10 < k2.p10) || + (k1.p11 < k2.p11) || + (k1.p12 < k2.p12) || + (k1.p13 < k2.p13) || + (k1.p14 < k2.p14) ) return true; else return false; case 15: - if( (k1.id < k2.id) || - (k1.p1 < k2.p1) || - (k1.p2 < k2.p2) || - (k1.p3 < k2.p3) || - (k1.p4 < k2.p4) || - (k1.p5 < k2.p5) || - (k1.p6 < k2.p6) || - (k1.p7 < k2.p7) || - (k1.p8 < k2.p8) || - (k1.p9 < k2.p9) || - (k1.p10 < k2.p10) || - (k1.p11 < k2.p11) || - (k1.p12 < k2.p12) || - (k1.p13 < k2.p13) || - (k1.p14 < k2.p14) || - (k1.p15 < k2.p15) ) + if ( (k1.id < k2.id) || + (k1.p1 < k2.p1) || + (k1.p2 < k2.p2) || + (k1.p3 < k2.p3) || + (k1.p4 < k2.p4) || + (k1.p5 < k2.p5) || + (k1.p6 < k2.p6) || + (k1.p7 < k2.p7) || + (k1.p8 < k2.p8) || + (k1.p9 < k2.p9) || + (k1.p10 < k2.p10) || + (k1.p11 < k2.p11) || + (k1.p12 < k2.p12) || + (k1.p13 < k2.p13) || + (k1.p14 < k2.p14) || + (k1.p15 < k2.p15) ) return true; else return false; diff --git a/shared/loki/MultiMethods.h b/shared/loki/MultiMethods.h index ece4fb17..ec5b7788 100644 --- a/shared/loki/MultiMethods.h +++ b/shared/loki/MultiMethods.h @@ -38,8 +38,8 @@ namespace Loki namespace Private { -template <class SomeLhs, class SomeRhs, - class Executor, typename ResultType> +template < class SomeLhs, class SomeRhs, + class Executor, typename ResultType > struct InvocationTraits { static ResultType @@ -85,12 +85,12 @@ class StaticDispatcher { if (Head* p2 = dynamic_cast<Head*>(&rhs)) { - Int2Type<(symmetric && - int(TL::IndexOf<TypesRhs, Head>::value) < - int(TL::IndexOf<TypesLhs, SomeLhs>::value))> i2t; + Int2Type < (symmetric && + int(TL::IndexOf<TypesRhs, Head>::value) < + int(TL::IndexOf<TypesLhs, SomeLhs>::value)) > i2t; - typedef Private::InvocationTraits< - SomeLhs, Head, Executor, ResultType> CallTraits; + typedef Private::InvocationTraits < + SomeLhs, Head, Executor, ResultType > CallTraits; return CallTraits::DoDispatch(lhs, *p2, exec, i2t); } @@ -133,7 +133,7 @@ class BaseLhs, > class BasicDispatcher { - typedef std::pair<TypeInfo,TypeInfo> KeyType; + typedef std::pair<TypeInfo, TypeInfo> KeyType; typedef CallbackType MappedType; typedef AssocVector<KeyType, MappedType> MapType; MapType callbackMap_; @@ -158,28 +158,28 @@ public: }; // Non-inline to reduce compile time overhead... -template <class BaseLhs, class BaseRhs, - typename ResultType, typename CallbackType> -void BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType> +template < class BaseLhs, class BaseRhs, + typename ResultType, typename CallbackType > +void BasicDispatcher<BaseLhs, BaseRhs, ResultType, CallbackType> ::DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun) { callbackMap_[KeyType(lhs, rhs)] = fun; } -template <class BaseLhs, class BaseRhs, - typename ResultType, typename CallbackType> -bool BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType> +template < class BaseLhs, class BaseRhs, + typename ResultType, typename CallbackType > +bool BasicDispatcher<BaseLhs, BaseRhs, ResultType, CallbackType> ::DoRemove(TypeInfo lhs, TypeInfo rhs) { return callbackMap_.erase(KeyType(lhs, rhs)) == 1; } -template <class BaseLhs, class BaseRhs, - typename ResultType, typename CallbackType> -ResultType BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType> +template < class BaseLhs, class BaseRhs, + typename ResultType, typename CallbackType > +ResultType BasicDispatcher<BaseLhs, BaseRhs, ResultType, CallbackType> ::Go(BaseLhs& lhs, BaseRhs& rhs) { - typename MapType::key_type k(typeid(lhs),typeid(rhs)); + typename MapType::key_type k(typeid(lhs), typeid(rhs)); typename MapType::iterator i = callbackMap_.find(k); if (i == callbackMap_.end()) { @@ -223,11 +223,11 @@ struct DynamicCaster namespace Private { -template <class BaseLhs, class BaseRhs, +template < class BaseLhs, class BaseRhs, class SomeLhs, class SomeRhs, typename ResultType, class CastLhs, class CastRhs, - ResultType (*Callback)(SomeLhs&, SomeRhs&)> + ResultType (*Callback)(SomeLhs&, SomeRhs&) > struct FnDispatcherHelper { static ResultType Trampoline(BaseLhs& lhs, BaseRhs& rhs) @@ -247,15 +247,15 @@ struct FnDispatcherHelper // Features automated conversions //////////////////////////////////////////////////////////////////////////////// -template <class BaseLhs, class BaseRhs = BaseLhs, +template < class BaseLhs, class BaseRhs = BaseLhs, typename ResultType = void, template <class, class> class CastingPolicy = DynamicCaster, template <class, class, class, class> - class DispatcherBackend = BasicDispatcher> + class DispatcherBackend = BasicDispatcher > class FnDispatcher { - DispatcherBackend<BaseLhs, BaseRhs, ResultType, - ResultType (*)(BaseLhs&, BaseRhs&)> backEnd_; + DispatcherBackend < BaseLhs, BaseRhs, ResultType, + ResultType (*)(BaseLhs&, BaseRhs&) > backEnd_; public: template <class SomeLhs, class SomeRhs> @@ -264,33 +264,33 @@ public: return backEnd_.template Add<SomeLhs, SomeRhs>(pFun); } - template <class SomeLhs, class SomeRhs, - ResultType (*callback)(SomeLhs&, SomeRhs&)> + template < class SomeLhs, class SomeRhs, + ResultType (*callback)(SomeLhs&, SomeRhs&) > void Add() { - typedef Private::FnDispatcherHelper< + typedef Private::FnDispatcherHelper < BaseLhs, BaseRhs, SomeLhs, SomeRhs, ResultType, - CastingPolicy<SomeLhs,BaseLhs>, - CastingPolicy<SomeRhs,BaseRhs>, - callback> Local; + CastingPolicy<SomeLhs, BaseLhs>, + CastingPolicy<SomeRhs, BaseRhs>, + callback > Local; Add<SomeLhs, SomeRhs>(&Local::Trampoline); } - template <class SomeLhs, class SomeRhs, + template < class SomeLhs, class SomeRhs, ResultType (*callback)(SomeLhs&, SomeRhs&), - bool symmetric> + bool symmetric > void Add(bool = true) // [gcc] dummy bool { - typedef Private::FnDispatcherHelper< + typedef Private::FnDispatcherHelper < BaseLhs, BaseRhs, SomeLhs, SomeRhs, ResultType, - CastingPolicy<SomeLhs,BaseLhs>, - CastingPolicy<SomeRhs,BaseRhs>, - callback> Local; + CastingPolicy<SomeLhs, BaseLhs>, + CastingPolicy<SomeRhs, BaseRhs>, + callback > Local; Add<SomeLhs, SomeRhs>(&Local::Trampoline); if (symmetric) @@ -318,19 +318,19 @@ public: namespace Private { -template <class BaseLhs, class BaseRhs, +template < class BaseLhs, class BaseRhs, class SomeLhs, class SomeRhs, typename ResultType, class CastLhs, class CastRhs, - class Fun, bool SwapArgs> + class Fun, bool SwapArgs > class FunctorDispatcherHelper { Fun fun_; - ResultType Fire(BaseLhs& lhs, BaseRhs& rhs,Int2Type<false>) + ResultType Fire(BaseLhs& lhs, BaseRhs& rhs, Int2Type<false>) { return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs)); } - ResultType Fire(BaseLhs& rhs, BaseRhs& lhs,Int2Type<true>) + ResultType Fire(BaseLhs& rhs, BaseRhs& lhs, Int2Type<true>) { return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs)); } @@ -339,7 +339,7 @@ public: ResultType operator()(BaseLhs& lhs, BaseRhs& rhs) { - return Fire(lhs,rhs,Int2Type<SwapArgs>()); + return Fire(lhs, rhs, Int2Type<SwapArgs>()); } }; } @@ -350,11 +350,11 @@ public: // Features automated casting //////////////////////////////////////////////////////////////////////////////// -template <class BaseLhs, class BaseRhs = BaseLhs, +template < class BaseLhs, class BaseRhs = BaseLhs, typename ResultType = void, template <class, class> class CastingPolicy = DynamicCaster, template <class, class, class, class> - class DispatcherBackend = BasicDispatcher> + class DispatcherBackend = BasicDispatcher > class FunctorDispatcher { typedef LOKI_TYPELIST_2(BaseLhs&, BaseRhs&) ArgsList; @@ -366,31 +366,31 @@ public: template <class SomeLhs, class SomeRhs, class Fun> void Add(const Fun& fun) { - typedef Private::FunctorDispatcherHelper< + typedef Private::FunctorDispatcherHelper < BaseLhs, BaseRhs, SomeLhs, SomeRhs, ResultType, CastingPolicy<SomeLhs, BaseLhs>, CastingPolicy<SomeRhs, BaseRhs>, - Fun, false> Adapter; + Fun, false > Adapter; backEnd_.template Add<SomeLhs, SomeRhs>(FunctorType(Adapter(fun))); } template <class SomeLhs, class SomeRhs, bool symmetric, class Fun> void Add(const Fun& fun) { - Add<SomeLhs,SomeRhs>(fun); + Add<SomeLhs, SomeRhs>(fun); if (symmetric) { // Note: symmetry only makes sense where BaseLhs==BaseRhs - typedef Private::FunctorDispatcherHelper< + typedef Private::FunctorDispatcherHelper < BaseLhs, BaseLhs, SomeLhs, SomeRhs, ResultType, CastingPolicy<SomeLhs, BaseLhs>, CastingPolicy<SomeRhs, BaseLhs>, - Fun, true> AdapterR; + Fun, true > AdapterR; backEnd_.template Add<SomeRhs, SomeLhs>(FunctorType(AdapterR(fun))); } diff --git a/shared/loki/OrderedStatic.h b/shared/loki/OrderedStatic.h index 0f26b6e0..f0ff73c3 100644 --- a/shared/loki/OrderedStatic.h +++ b/shared/loki/OrderedStatic.h @@ -76,8 +76,8 @@ protected: void SetLongevity(T* ptr) { - val_=ptr; - Loki::SetLongevity(val_,longevity_); + val_ = ptr; + Loki::SetLongevity(val_, longevity_); } private: @@ -102,7 +102,7 @@ public: typedef void (OrderedStaticCreatorFunc::*Creator)(); void createObjects(); - void registerObject(unsigned int longevity,OrderedStaticCreatorFunc*,Creator); + void registerObject(unsigned int longevity, OrderedStaticCreatorFunc*, Creator); private: OrderedStaticManagerClass(const OrderedStaticManagerClass&); @@ -110,7 +110,7 @@ private: struct Data { - Data(unsigned int,OrderedStaticCreatorFunc*, Creator); + Data(unsigned int, OrderedStaticCreatorFunc*, Creator); unsigned int longevity; OrderedStaticCreatorFunc* object; Creator creator; @@ -158,7 +158,7 @@ public: OrderedStatic() : Private::OrderedStaticBase<T>(L) { OrderedStaticManager::Instance().registerObject - (L,this,&Private::OrderedStaticCreatorFunc::createObject); + (L, this, &Private::OrderedStaticCreatorFunc::createObject); } void createObject() @@ -178,7 +178,7 @@ public: OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p) { OrderedStaticManager::Instance().registerObject - (L,this,&Private::OrderedStaticCreatorFunc::createObject); + (L, this, &Private::OrderedStaticCreatorFunc::createObject); } void createObject() @@ -203,7 +203,7 @@ public: OrderedStatic(Func p) : Private::OrderedStaticBase<T>(L), para_(p) { OrderedStaticManager::Instance().registerObject - (L,this,&Private::OrderedStaticCreatorFunc::createObject); + (L, this, &Private::OrderedStaticCreatorFunc::createObject); } void createObject() diff --git a/shared/loki/Pimpl.h b/shared/loki/Pimpl.h index 788f76d8..8254e3e2 100644 --- a/shared/loki/Pimpl.h +++ b/shared/loki/Pimpl.h @@ -101,7 +101,7 @@ public: T& operator*() { - return ptr_.operator*(); + return ptr_.operator * (); } const T* operator->() const @@ -111,7 +111,7 @@ public: const T& operator*() const { - return ptr_.operator*(); + return ptr_.operator * (); } Pointer& wrapped() @@ -136,7 +136,7 @@ private: template<class T, typename Pointer = ConstPropPtr<T> > struct PimplOwner { - Pimpl<T,Pointer> LOKI_INHERITED_PIMPL_NAME; + Pimpl<T, Pointer> LOKI_INHERITED_PIMPL_NAME; }; diff --git a/shared/loki/Register.h b/shared/loki/Register.h index 32409f4b..2b549381 100644 --- a/shared/loki/Register.h +++ b/shared/loki/Register.h @@ -113,18 +113,18 @@ struct UnRegisterOnDeleteSet #define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d) #define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \ - \ + \ struct LOKI_CONCAT(check_,CLASS,_isInList_,LIST) \ { \ typedef int LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST); \ }; \ typedef Loki::Select<Loki::TL::IndexOf<LIST, CLASS>::value == -1, \ - CLASS, \ - LOKI_CONCAT(check_,CLASS,_isInList_,LIST)> \ - ::Result LOKI_CONCAT(CLASS,isInList,LIST,result); \ + CLASS, \ + LOKI_CONCAT(check_,CLASS,_isInList_,LIST)> \ + ::Result LOKI_CONCAT(CLASS,isInList,LIST,result); \ typedef LOKI_CONCAT(CLASS,isInList,LIST,result):: \ - LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST) \ - LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList__,LIST); + LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList_,LIST) \ + LOKI_CONCAT(ERROR_class_,CLASS,_isNotInList__,LIST); } // namespace Loki diff --git a/shared/loki/SPCachedFactory.h b/shared/loki/SPCachedFactory.h index aab37127..e1b8ec8c 100644 --- a/shared/loki/SPCachedFactory.h +++ b/shared/loki/SPCachedFactory.h @@ -165,7 +165,7 @@ class AbstractProduct, class SmartPointer { private: - typedef SmartPtr< AbstractProduct,OwnershipPolicy, + typedef SmartPtr < AbstractProduct, OwnershipPolicy, ConversionPolicy, CheckingPolicy, FunctionStorage, ConstnessPolicy > CallBackSP; protected: @@ -195,7 +195,7 @@ private: CallBackSP& SP(*reinterpret_cast<CallBackSP*>(pSP)); ReleaseObject(SP); } - virtual void ReleaseObject(ProductReturn& object)=0; + virtual void ReleaseObject(ProductReturn& object) = 0; const typename CallBackSP::FunctorType fun; }; diff --git a/shared/loki/SafeBits.h b/shared/loki/SafeBits.h index 4105f375..9e160c50 100644 --- a/shared/loki/SafeBits.h +++ b/shared/loki/SafeBits.h @@ -482,10 +482,10 @@ inline SafeBitField< unique_index, word_t > operator != ( bool, SafeBitField< un #ifdef LOKI_SAFE_BIT_FIELD #ifndef LOKI_BIT_FIELD_NONTEMPLATE_INIT #define LOKI_BIT_CONST( field_t, label, bit_index ) \ - static const field_t::const_t label = field_t::const_t::make_bit_const<bit_index>() + static const field_t::const_t label = field_t::const_t::make_bit_const<bit_index>() #else #define LOKI_BIT_CONST( field_t, label, bit_index ) \ - static const field_t::const_t label = field_t::const_t::make_bit_const( bit_index ) + static const field_t::const_t label = field_t::const_t::make_bit_const( bit_index ) #endif // LOKI_BIT_FIELD_NONTEMPLATE_INIT #else inline size_t make_bit_const( size_t i ) { return ( i > 0 ) ? ( size_t(1) << ( ( i > 0 ) ? ( i - 1 ) : 0 ) ) : 0; } diff --git a/shared/loki/SafeFormat.h b/shared/loki/SafeFormat.h index 2734e972..bd2837f9 100644 --- a/shared/loki/SafeFormat.h +++ b/shared/loki/SafeFormat.h @@ -73,7 +73,7 @@ template <class Char> void write(std::pair<Char*, std::size_t>& s, const Char* from, const Char* to) { assert(from <= to); - if(from + s.second < to) + if (from + s.second < to) throw std::overflow_error(""); // s.first: position one past the final copied element s.first = std::copy(from, to, s.first); @@ -106,9 +106,9 @@ struct PrintfState } #define LOKI_PRINTF_STATE_FORWARD(type) \ - PrintfState& operator()(type par) {\ - return (*this)(static_cast< LOKI_SAFEFORMAT_UNSIGNED_LONG >(par)); \ - } + PrintfState& operator()(type par) {\ + return (*this)(static_cast< LOKI_SAFEFORMAT_UNSIGNED_LONG >(par)); \ + } LOKI_PRINTF_STATE_FORWARD(bool) LOKI_PRINTF_STATE_FORWARD(char) @@ -171,21 +171,21 @@ struct PrintfState PrintfState& operator()(void* n) { if (result_ == -1) return *this; // don't even bother - PrintUsing_snprintf(n,"p"); + PrintUsing_snprintf(n, "p"); return *this; } PrintfState& operator()(double n) { if (result_ == -1) return *this; // don't even bother - PrintUsing_snprintf(n,"eEfgG"); + PrintUsing_snprintf(n, "eEfgG"); return *this; } PrintfState& operator()(long double n) { if (result_ == -1) return *this; // don't even bother - PrintUsing_snprintf(n,"eEfgG"); + PrintUsing_snprintf(n, "eEfgG"); return *this; } diff --git a/shared/loki/ScopeGuard.h b/shared/loki/ScopeGuard.h index 46e4d892..99ce569d 100644 --- a/shared/loki/ScopeGuard.h +++ b/shared/loki/ScopeGuard.h @@ -65,7 +65,7 @@ protected: { j.Execute(); } - catch(...) + catch (...) {} } @@ -440,15 +440,15 @@ inline ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun) } template <typename Ret, class Obj1, class Obj2> -inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1& obj) +inline ObjScopeGuardImpl0<Obj1, Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1& obj) { - return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(obj,memFun); + return ObjScopeGuardImpl0<Obj1, Ret(Obj2::*)()>::MakeObjGuard(obj, memFun); } template <typename Ret, class Obj1, class Obj2> -inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1* obj) +inline ObjScopeGuardImpl0<Obj1, Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1* obj) { - return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(*obj,memFun); + return ObjScopeGuardImpl0<Obj1, Ret(Obj2::*)()>::MakeObjGuard(*obj, memFun); } //////////////////////////////////////////////////////////////// @@ -503,15 +503,15 @@ inline ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, } template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b> -inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1& obj, P1b p1) +inline ObjScopeGuardImpl1<Obj1, Ret(Obj2::*)(P1a), P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1& obj, P1b p1) { - return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(obj,memFun,p1); + return ObjScopeGuardImpl1<Obj1, Ret(Obj2::*)(P1a), P1b>::MakeObjGuard(obj, memFun, p1); } template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b> -inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1* obj, P1b p1) +inline ObjScopeGuardImpl1<Obj1, Ret(Obj2::*)(P1a), P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1* obj, P1b p1) { - return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(*obj,memFun,p1); + return ObjScopeGuardImpl1<Obj1, Ret(Obj2::*)(P1a), P1b>::MakeObjGuard(*obj, memFun, p1); } //////////////////////////////////////////////////////////////// @@ -567,15 +567,15 @@ inline ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun mem } template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b> -inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1& obj, P1b p1, P2b p2) +inline ObjScopeGuardImpl2<Obj1, Ret(Obj2::*)(P1a, P2a), P1b, P2b> MakeGuard(Ret(Obj2::*memFun)(P1a, P2a), Obj1& obj, P1b p1, P2b p2) { - return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(obj,memFun,p1,p2); + return ObjScopeGuardImpl2<Obj1, Ret(Obj2::*)(P1a, P2a), P1b, P2b>::MakeObjGuard(obj, memFun, p1, p2); } template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b> -inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1* obj, P1b p1, P2b p2) +inline ObjScopeGuardImpl2<Obj1, Ret(Obj2::*)(P1a, P2a), P1b, P2b> MakeGuard(Ret(Obj2::*memFun)(P1a, P2a), Obj1* obj, P1b p1, P2b p2) { - return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(*obj,memFun,p1,p2); + return ObjScopeGuardImpl2<Obj1, Ret(Obj2::*)(P1a, P2a), P1b, P2b>::MakeObjGuard(*obj, memFun, p1, p2); } //////////////////////////////////////////////////////////////// @@ -662,5 +662,8 @@ MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1* obj, P1b p1, P2b p2, P3b #define LOKI_ON_BLOCK_EXIT ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeGuard #define LOKI_ON_BLOCK_EXIT_OBJ ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeObjGuard +//by ZenJu +#define LOKI_ON_BLOCK_EXIT2(X) ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeGuard([&](){X;}); (void)LOKI_ANONYMOUS_VARIABLE(scopeGuard); + #endif // end file guardian diff --git a/shared/loki/Sequence.h b/shared/loki/Sequence.h index e8c8bd35..04a64174 100644 --- a/shared/loki/Sequence.h +++ b/shared/loki/Sequence.h @@ -22,16 +22,16 @@ namespace Loki template < -class T01=NullType,class T02=NullType,class T03=NullType,class T04=NullType,class T05=NullType, - class T06=NullType,class T07=NullType,class T08=NullType,class T09=NullType,class T10=NullType, - class T11=NullType,class T12=NullType,class T13=NullType,class T14=NullType,class T15=NullType, - class T16=NullType,class T17=NullType,class T18=NullType,class T19=NullType,class T20=NullType +class T01 = NullType, class T02 = NullType, class T03 = NullType, class T04 = NullType, class T05 = NullType, + class T06 = NullType, class T07 = NullType, class T08 = NullType, class T09 = NullType, class T10 = NullType, + class T11 = NullType, class T12 = NullType, class T13 = NullType, class T14 = NullType, class T15 = NullType, + class T16 = NullType, class T17 = NullType, class T18 = NullType, class T19 = NullType, class T20 = NullType > struct Seq { private: - typedef typename Seq< T02, T03, T04, T05, T06, T07, T08, T09, T10, - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>::Type + typedef typename Seq < T02, T03, T04, T05, T06, T07, T08, T09, T10, + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20 >::Type TailResult; public: typedef Typelist<T01, TailResult> Type; diff --git a/shared/loki/Singleton.h b/shared/loki/Singleton.h index c5f1f567..1e479032 100644 --- a/shared/loki/Singleton.h +++ b/shared/loki/Singleton.h @@ -119,7 +119,7 @@ template <typename T, typename Destroyer> class ConcreteLifetimeTracker : public LifetimeTracker { public: - ConcreteLifetimeTracker(T* p,unsigned int longevity, Destroyer d) + ConcreteLifetimeTracker(T* p, unsigned int longevity, Destroyer d) : LifetimeTracker(longevity) , pTracked_(p) , destroyer_(d) @@ -151,7 +151,7 @@ void SetLongevity(T* pDynObject, unsigned int longevity, using namespace Private; // manage lifetime of stack manually - if(pTrackerArray==0) + if (pTrackerArray == 0) pTrackerArray = new TrackerArray; // automatically delete the ConcreteLifetimeTracker object when a exception is thrown @@ -261,7 +261,7 @@ struct CreateUsing { //allocator.destroy(p); p->~T(); - allocator.deallocate(p,1); + allocator.deallocate(p, 1); } }; }; @@ -566,21 +566,21 @@ public: /// \ingroup LongevityLifetimeGroup /// \brief Longest possible SingletonWithLongevity lifetime: 0xFFFFFFFF template <class T> -struct DieLast : SingletonFixedLongevity<0xFFFFFFFF ,T> +struct DieLast : SingletonFixedLongevity<0xFFFFFFFF , T> {}; /// \struct DieDirectlyBeforeLast /// \ingroup LongevityLifetimeGroup /// \brief Lifetime is a one less than DieLast: 0xFFFFFFFF-1 template <class T> -struct DieDirectlyBeforeLast : SingletonFixedLongevity<0xFFFFFFFF-1 ,T> +struct DieDirectlyBeforeLast : SingletonFixedLongevity < 0xFFFFFFFF - 1 , T > {}; /// \struct DieFirst /// \ingroup LongevityLifetimeGroup /// \brief Shortest possible SingletonWithLongevity lifetime: 0 template <class T> -struct DieFirst : SingletonFixedLongevity<0,T> +struct DieFirst : SingletonFixedLongevity<0, T> {}; }//namespace LongevityLifetime @@ -616,7 +616,7 @@ class FollowIntoDeath static void Init() { static bool done = false; - if(!done) + if (!done) { followers_ = new Container; done = true; @@ -632,7 +632,7 @@ class FollowIntoDeath static void DestroyFollowers() { Init(); - for(iterator it = followers_->begin(); it != followers_->end(); ++it) + for (iterator it = followers_->begin(); it != followers_->end(); ++it) (*it)(); delete followers_; } @@ -660,7 +660,7 @@ public: // template instantiation, this adds a additional atexit entry // does not work with SetLonlevity, but there you can control // the lifetime with the GetLongevity function. - Lifetime<Followers<Master> >::ScheduleDestruction(0,Followers<Master>::DestroyFollowers); + Lifetime<Followers<Master> >::ScheduleDestruction(0, Followers<Master>::DestroyFollowers); } static void OnDeadReference() @@ -741,7 +741,7 @@ private: SingletonHolder(); // Data - typedef typename ThreadingModel<T*,MutexPolicy>::VolatileType PtrInstanceType; + typedef typename ThreadingModel<T*, MutexPolicy>::VolatileType PtrInstanceType; static PtrInstanceType pInstance_; static bool destroyed_; }; @@ -783,8 +783,8 @@ class T, template <class, class> class ThreadingModel, class MutexPolicy > -inline T& SingletonHolder<T, CreationPolicy, - LifetimePolicy, ThreadingModel, MutexPolicy>::Instance() +inline T& SingletonHolder < T, CreationPolicy, + LifetimePolicy, ThreadingModel, MutexPolicy >::Instance() { if (!pInstance_) { @@ -805,10 +805,10 @@ template <class> class LifetimePolicy, template <class, class> class ThreadingModel, class MutexPolicy > -void SingletonHolder<T, CreationPolicy, - LifetimePolicy, ThreadingModel, MutexPolicy>::MakeInstance() +void SingletonHolder < T, CreationPolicy, + LifetimePolicy, ThreadingModel, MutexPolicy >::MakeInstance() { - typename ThreadingModel<SingletonHolder,MutexPolicy>::Lock guard; + typename ThreadingModel<SingletonHolder, MutexPolicy>::Lock guard; (void)guard; if (!pInstance_) @@ -875,14 +875,14 @@ public: /// Put this macro called with a SingletonHolder typedef into your cpp file. #define LOKI_SINGLETON_INSTANCE_DEFINITION(SHOLDER) \ -namespace Loki \ -{ \ + namespace Loki \ + { \ template<> \ SHOLDER::ObjectType& Singleton<SHOLDER::ObjectType>::Instance() \ { \ return SHOLDER::Instance(); \ } \ -} + } #endif // end file guardian diff --git a/shared/loki/SmallObj.cpp b/shared/loki/SmallObj.cpp index 0d82c1bb..1c42374f 100644 --- a/shared/loki/SmallObj.cpp +++ b/shared/loki/SmallObj.cpp @@ -1012,7 +1012,7 @@ void FixedAllocator::DoDeallocate(void* p) /// Calculates index into array where a FixedAllocator of numBytes is located. inline std::size_t GetOffset( std::size_t numBytes, std::size_t alignment ) { - const std::size_t alignExtra = alignment-1; + const std::size_t alignExtra = alignment - 1; return ( numBytes + alignExtra ) / alignment; } @@ -1070,7 +1070,7 @@ SmallObjAllocator::SmallObjAllocator( std::size_t pageSize, const std::size_t allocCount = GetOffset( maxObjectSize, objectAlignSize ); pool_ = new FixedAllocator[ allocCount ]; for ( std::size_t i = 0; i < allocCount; ++i ) - pool_[ i ].Initialize( ( i+1 ) * objectAlignSize, pageSize ); + pool_[ i ].Initialize( ( i + 1 ) * objectAlignSize, pageSize ); } // SmallObjAllocator::~SmallObjAllocator -------------------------------------- diff --git a/shared/loki/SmallObj.h b/shared/loki/SmallObj.h index 8725b911..10624cc2 100644 --- a/shared/loki/SmallObj.h +++ b/shared/loki/SmallObj.h @@ -224,14 +224,14 @@ class AllocatorSingleton : public SmallObjAllocator public: /// Defines type of allocator. - typedef AllocatorSingleton< ThreadingModel, chunkSize, + typedef AllocatorSingleton < ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy > MyAllocator; /// Defines type for thread-safety locking mechanism. typedef ThreadingModel< MyAllocator, MutexPolicy > MyThreadingModel; /// Defines singleton made from allocator. - typedef Loki::SingletonHolder< MyAllocator, Loki::CreateStatic, + typedef Loki::SingletonHolder < MyAllocator, Loki::CreateStatic, LifetimePolicy, ThreadingModel > MyAllocatorSingleton; /// Returns reference to the singleton. @@ -441,7 +441,7 @@ class SmallObjectBase public: /// Defines type of allocator singleton, must be public /// to handle singleton lifetime dependencies. - typedef AllocatorSingleton< ThreadingModel, chunkSize, + typedef AllocatorSingleton < ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy > ObjAllocatorSingleton; private: @@ -591,7 +591,7 @@ template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEV template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME, class MutexPolicy = LOKI_DEFAULT_MUTEX > -class SmallObject : public SmallObjectBase< ThreadingModel, chunkSize, +class SmallObject : public SmallObjectBase < ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy > { @@ -627,7 +627,7 @@ template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEV template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME, class MutexPolicy = LOKI_DEFAULT_MUTEX > -class SmallValueObject : public SmallObjectBase< ThreadingModel, chunkSize, +class SmallValueObject : public SmallObjectBase < ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy > { protected: diff --git a/shared/loki/SmartPtr.h b/shared/loki/SmartPtr.h index fb14258e..6f6f9996 100644 --- a/shared/loki/SmartPtr.h +++ b/shared/loki/SmartPtr.h @@ -440,7 +440,7 @@ public: : pCount_(static_cast<uintptr_t*>( SmallObject<>::operator new(sizeof(uintptr_t)))) { - assert(pCount_!=0); + assert(pCount_ != 0); *pCount_ = 1; } @@ -500,7 +500,7 @@ private: /// fixed at a higher design level, and no change to this class could fix it. //////////////////////////////////////////////////////////////////////////////// -template <template <class, class> class ThreadingModel, +template < template <class, class> class ThreadingModel, class MX = LOKI_DEFAULT_MUTEX > struct RefCountedMTAdj { @@ -584,14 +584,14 @@ public: static P Clone(const P& val) { - if(val!=0) + if (val != 0) val->AddRef(); return val; } static bool Release(const P& val) { - if(val!=0) + if (val != 0) val->Release(); return false; } @@ -1138,7 +1138,7 @@ public: typedef typename SP::StoredType StoredType; typedef typename SP::ReferenceType ReferenceType; - typedef typename Select<OP::destructiveCopy,SmartPtr, const SmartPtr>::Result + typedef typename Select<OP::destructiveCopy, SmartPtr, const SmartPtr>::Result CopyArg; private: @@ -1146,7 +1146,7 @@ private: #ifdef LOKI_SMARTPTR_CONVERSION_CONSTRUCTOR_POLICY typedef typename Select< CP::allow, const StoredType&, NeverMatched>::Result ImplicitArg; - typedef typename Select<!CP::allow, const StoredType&, NeverMatched>::Result ExplicitArg; + typedef typename Select < !CP::allow, const StoredType&, NeverMatched >::Result ExplicitArg; #else typedef const StoredType& ImplicitArg; typedef typename Select<false, const StoredType&, NeverMatched>::Result ExplicitArg; @@ -1765,8 +1765,8 @@ typename T, template <class> class CNP > struct less< Loki::SmartPtr<T, OP, CP, KP, SP, CNP > > - : public binary_function<Loki::SmartPtr<T, OP, CP, KP, SP, CNP >, - Loki::SmartPtr<T, OP, CP, KP, SP, CNP >, bool> + : public binary_function < Loki::SmartPtr<T, OP, CP, KP, SP, CNP >, + Loki::SmartPtr<T, OP, CP, KP, SP, CNP >, bool > { bool operator()(const Loki::SmartPtr<T, OP, CP, KP, SP, CNP >& lhs, const Loki::SmartPtr<T, OP, CP, KP, SP, CNP >& rhs) const diff --git a/shared/loki/StrongPtr.h b/shared/loki/StrongPtr.h index 23d70415..868eb48f 100644 --- a/shared/loki/StrongPtr.h +++ b/shared/loki/StrongPtr.h @@ -887,7 +887,7 @@ private: #ifdef LOKI_SMARTPTR_CONVERSION_CONSTRUCTOR_POLICY typedef typename Select< CP::allow, const StoredType&, NeverMatched>::Result ImplicitArg; - typedef typename Select<!CP::allow, const StoredType&, NeverMatched>::Result ExplicitArg; + typedef typename Select < !CP::allow, const StoredType&, NeverMatched >::Result ExplicitArg; #else typedef const StoredType& ImplicitArg; typedef typename Select<false, const StoredType&, NeverMatched>::Result ExplicitArg; @@ -1678,7 +1678,7 @@ typename T, template < class > class CNP > struct less< Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > > - : public binary_function< + : public binary_function < Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >, Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >, bool > { diff --git a/shared/loki/Threads.h b/shared/loki/Threads.h index 8fb5d362..690ca50f 100644 --- a/shared/loki/Threads.h +++ b/shared/loki/Threads.h @@ -92,97 +92,97 @@ #define LOKI_THREADS_MUTEX_CTOR(x) #define LOKI_THREADS_ATOMIC_FUNCTIONS \ - static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - lval *= val; \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDivide(volatile IntType& lval, const IntType val) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - lval /= val; \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicIncrement(volatile IntType& lval) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - ++lval; \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDecrement(volatile IntType& lval) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - --lval; \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static void AtomicAssign(volatile IntType& lval, const IntType val) \ - { InterlockedExchange(&const_cast<IntType&>(lval), val); } \ - \ - static void AtomicAssign(IntType& lval, volatile const IntType& val) \ - { InterlockedExchange(&lval, val); } \ - \ - static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - ++lval; \ - matches = ( lval == compare ); \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - --lval; \ - matches = ( lval == compare ); \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - lval += val; \ - matches = ( lval == compare ); \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - lval -= val; \ - matches = ( lval == compare ); \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - lval *= val; \ - matches = ( lval == compare ); \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ - { \ - ::EnterCriticalSection( &atomic_mutex_ ); \ - lval /= val; \ - matches = ( lval == compare ); \ - ::LeaveCriticalSection( &atomic_mutex_ ); \ - return lval; \ - } + static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + lval *= val; \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDivide(volatile IntType& lval, const IntType val) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + lval /= val; \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicIncrement(volatile IntType& lval) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + ++lval; \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDecrement(volatile IntType& lval) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + --lval; \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static void AtomicAssign(volatile IntType& lval, const IntType val) \ + { InterlockedExchange(&const_cast<IntType&>(lval), val); } \ + \ + static void AtomicAssign(IntType& lval, volatile const IntType& val) \ + { InterlockedExchange(&lval, val); } \ + \ + static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + ++lval; \ + matches = ( lval == compare ); \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + --lval; \ + matches = ( lval == compare ); \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + lval += val; \ + matches = ( lval == compare ); \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + lval -= val; \ + matches = ( lval == compare ); \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + lval *= val; \ + matches = ( lval == compare ); \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ + { \ + ::EnterCriticalSection( &atomic_mutex_ ); \ + lval /= val; \ + matches = ( lval == compare ); \ + ::LeaveCriticalSection( &atomic_mutex_ ); \ + return lval; \ + } #elif defined(LOKI_PTHREAD_H) @@ -206,96 +206,96 @@ #define LOKI_THREADS_LONG long #define LOKI_THREADS_ATOMIC(x) \ - pthread_mutex_lock(&atomic_mutex_); \ - x; \ - pthread_mutex_unlock(&atomic_mutex_) + pthread_mutex_lock(&atomic_mutex_); \ + x; \ + pthread_mutex_unlock(&atomic_mutex_) #define LOKI_THREADS_ATOMIC_FUNCTIONS \ private: \ - static pthread_mutex_t atomic_mutex_; \ + static pthread_mutex_t atomic_mutex_; \ public: \ - static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - lval *= val; \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDivide(volatile IntType& lval, const IntType val) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - lval /= val; \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicIncrement(volatile IntType& lval) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - ++lval; \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDecrement(volatile IntType& lval) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - --lval; \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static void AtomicAssign(volatile IntType& lval, const IntType val) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - lval = val; \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static void AtomicAssign(IntType& lval, volatile const IntType& val) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - lval = val; \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - ++lval; \ - matches = ( compare == lval ); \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - --lval; \ - matches = ( compare == lval ); \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - lval *= val; \ - matches = ( lval == compare ); \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } \ - \ - static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ - { \ - ::pthread_mutex_lock( &atomic_mutex_ ); \ - lval /= val; \ - matches = ( lval == compare ); \ - ::pthread_mutex_unlock( &atomic_mutex_ ); \ - return lval; \ - } + static IntType AtomicMultiply(volatile IntType& lval, const IntType val) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + lval *= val; \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDivide(volatile IntType& lval, const IntType val) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + lval /= val; \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicIncrement(volatile IntType& lval) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + ++lval; \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDecrement(volatile IntType& lval) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + --lval; \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static void AtomicAssign(volatile IntType& lval, const IntType val) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + lval = val; \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static void AtomicAssign(IntType& lval, volatile const IntType& val) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + lval = val; \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches ) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + ++lval; \ + matches = ( compare == lval ); \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches ) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + --lval; \ + matches = ( compare == lval ); \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + lval *= val; \ + matches = ( lval == compare ); \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } \ + \ + static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches ) \ + { \ + ::pthread_mutex_lock( &atomic_mutex_ ); \ + lval /= val; \ + matches = ( lval == compare ); \ + ::pthread_mutex_unlock( &atomic_mutex_ ); \ + return lval; \ + } #else // single threaded diff --git a/shared/loki/TypeManip.h b/shared/loki/TypeManip.h index 6b7f4ab8..7933e340 100644 --- a/shared/loki/TypeManip.h +++ b/shared/loki/TypeManip.h @@ -83,7 +83,7 @@ struct IsSameType }; template <typename T> -struct IsSameType<T,T> +struct IsSameType<T, T> { enum { value = true }; }; @@ -215,7 +215,7 @@ struct SuperSubclass<T, void> // Caveat: might not work if T and U are in a private inheritance hierarchy. //////////////////////////////////////////////////////////////////////////////// -template<class T,class U> +template<class T, class U> struct SuperSubclassStrict { enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists && diff --git a/shared/loki/TypeTraits.h b/shared/loki/TypeTraits.h index 2d5af757..28d0f0c1 100644 --- a/shared/loki/TypeTraits.h +++ b/shared/loki/TypeTraits.h @@ -93,18 +93,18 @@ struct IsCustomFloat namespace Private { #ifndef LOKI_DISABLE_TYPELIST_MACROS -typedef LOKI_TYPELIST_4(unsigned char, unsigned short int,unsigned int, unsigned long int) +typedef LOKI_TYPELIST_4(unsigned char, unsigned short int, unsigned int, unsigned long int) StdUnsignedInts; -typedef LOKI_TYPELIST_4(signed char, short int,int, long int) +typedef LOKI_TYPELIST_4(signed char, short int, int, long int) StdSignedInts; typedef LOKI_TYPELIST_3(bool, char, wchar_t) StdOtherInts; typedef LOKI_TYPELIST_3(float, double, long double) StdFloats; #else -typedef Loki::Seq<unsigned char, unsigned short int,unsigned int, unsigned long int>::Type +typedef Loki::Seq<unsigned char, unsigned short int, unsigned int, unsigned long int>::Type StdUnsignedInts; -typedef Loki::Seq<signed char, short int,int, long int>::Type +typedef Loki::Seq<signed char, short int, int, long int>::Type StdSignedInts; typedef Loki::Seq<bool, char, wchar_t>::Type StdOtherInts; @@ -160,372 +160,372 @@ template <typename T> struct IsFunctionPointerRaw<T(*)()> {enum {result = 1};}; -template <typename T, - typename P01> +template < typename T, + typename P01 > struct IsFunctionPointerRaw<T(*)(P01)> {enum {result = 1};}; -template <typename T, - typename P01, typename P02> -struct IsFunctionPointerRaw<T(*)( - P01, P02)> +template < typename T, + typename P01, typename P02 > +struct IsFunctionPointerRaw < T(*)( + P01, P02) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02, typename P03> -struct IsFunctionPointerRaw<T(*)( - P01, P02, P03)> +template < typename T, + typename P01, typename P02, typename P03 > +struct IsFunctionPointerRaw < T(*)( + P01, P02, P03) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02, typename P03, typename P04> -struct IsFunctionPointerRaw<T(*)( - P01, P02, P03, P04)> +template < typename T, + typename P01, typename P02, typename P03, typename P04 > +struct IsFunctionPointerRaw < T(*)( + P01, P02, P03, P04) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsFunctionPointerRaw<T(*)( - P01, P02, P03, P04, P05)> +template < typename T, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsFunctionPointerRaw < T(*)( + P01, P02, P03, P04, P05) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsFunctionPointerRaw<T(*)( + typename P06 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06)> + P06) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07)> + P06, P07) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07, typename P08 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07, P08)> + P06, P07, P08) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09)> + P06, P07, P08, P09) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, P10)> + P06, P07, P08, P09, P10) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsFunctionPointerRaw<T(*)( + typename P11 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11)> + P11) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12)> + P11, P12) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12, typename P13 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13)> + P11, P12, P13) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14)> + P11, P12, P13, P14) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, P15)> + P11, P12, P13, P14, P15) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsFunctionPointerRaw<T(*)( + typename P16 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16)> + P16) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17)> + P16, P17) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17, typename P18 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18)> + P16, P17, P18) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19)> + P16, P17, P18, P19) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, P20)> + P16, P17, P18, P19, P20) > {enum {result = 1};}; template <typename T> -struct IsFunctionPointerRaw<T(*)( - ...)> +struct IsFunctionPointerRaw < T(*)( + ...) > {enum {result = 1};}; -template <typename T, - typename P01> -struct IsFunctionPointerRaw<T(*)( - P01, ...)> +template < typename T, + typename P01 > +struct IsFunctionPointerRaw < T(*)( + P01, ...) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02> -struct IsFunctionPointerRaw<T(*)( - P01, P02, ...)> +template < typename T, + typename P01, typename P02 > +struct IsFunctionPointerRaw < T(*)( + P01, P02, ...) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02, typename P03> -struct IsFunctionPointerRaw<T(*)( - P01, P02, P03, ...)> +template < typename T, + typename P01, typename P02, typename P03 > +struct IsFunctionPointerRaw < T(*)( + P01, P02, P03, ...) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02, typename P03, typename P04> -struct IsFunctionPointerRaw<T(*)( - P01, P02, P03, P04, ...)> +template < typename T, + typename P01, typename P02, typename P03, typename P04 > +struct IsFunctionPointerRaw < T(*)( + P01, P02, P03, P04, ...) > {enum {result = 1};}; -template <typename T, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsFunctionPointerRaw<T(*)( +template < typename T, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - ...)> + ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsFunctionPointerRaw<T(*)( + typename P06 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, ...)> + P06, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07, ...)> + P06, P07, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07, typename P08 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07, P08, ...)> + P06, P07, P08, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, ...)> + P06, P07, P08, P09, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsFunctionPointerRaw<T(*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - ...)> + ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsFunctionPointerRaw<T(*)( + typename P11 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, ...)> + P11, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, ...)> + P11, P12, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12, typename P13 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, ...)> + P11, P12, P13, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, ...)> + P11, P12, P13, P14, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsFunctionPointerRaw<T(*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - ...)> + ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsFunctionPointerRaw<T(*)( + typename P16 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, ...)> + P16, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, ...)> + P16, P17, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17, typename P18 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, ...)> + P16, P17, P18, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, ...)> + P16, P17, P18, P19, ...) > {enum {result = 1};}; -template <typename T, +template < typename T, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsFunctionPointerRaw<T(*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsFunctionPointerRaw < T(*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, - ...)> + ...) > {enum {result = 1};}; @@ -537,372 +537,372 @@ template <typename T, typename S> struct IsMemberFunctionPointerRaw<T (S::*)()> {enum {result = 1};}; -template <typename T, typename S, - typename P01> +template < typename T, typename S, + typename P01 > struct IsMemberFunctionPointerRaw<T (S::*)(P01)> {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02)> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03)> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04)> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, P05)> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, P05) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06)> + P06) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07)> + P06, P07) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08)> + P06, P07, P08) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09)> + P06, P07, P08, P09) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, P10)> + P06, P07, P08, P09, P10) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11)> + P11) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12)> + P11, P12) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13)> + P11, P12, P13) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14)> + P11, P12, P13, P14) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, P15)> + P11, P12, P13, P14, P15) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16)> + P16) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17)> + P16, P17) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18)> + P16, P17, P18) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19)> + P16, P17, P18, P19) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, P20)> + P16, P17, P18, P19, P20) > {enum {result = 1};}; template <typename T, typename S> -struct IsMemberFunctionPointerRaw<T (S::*)( - ...)> +struct IsMemberFunctionPointerRaw < T (S::*)( + ...) > {enum {result = 1};}; -template <typename T, typename S, - typename P01> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, ...)> +template < typename T, typename S, + typename P01 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, ...) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, ...)> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, ...) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, ...)> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, ...) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, ...)> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, ...) > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - ...)> + ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, ...)> + P06, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, ...)> + P06, P07, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, ...)> + P06, P07, P08, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, ...)> + P06, P07, P08, P09, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - ...)> + ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, ...)> + P11, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, ...)> + P11, P12, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, ...)> + P11, P12, P13, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, ...)> + P11, P12, P13, P14, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - ...)> + ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, ...)> + P16, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, ...)> + P16, P17, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, ...)> + P16, P17, P18, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, ...)> + P16, P17, P18, P19, ...) > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, - ...)> + ...) > {enum {result = 1};}; // Const versions @@ -911,372 +911,372 @@ template <typename T, typename S> struct IsMemberFunctionPointerRaw<T (S::*)() const> {enum {result = 1};}; -template <typename T, typename S, - typename P01> +template < typename T, typename S, + typename P01 > struct IsMemberFunctionPointerRaw<T (S::*)(P01) const> {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02) const> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03) const> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04) const> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, P05) const> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, P05) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06) const> + P06) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07) const> + P06, P07) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08) const> + P06, P07, P08) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09) const> + P06, P07, P08, P09) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, P10) const> + P06, P07, P08, P09, P10) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11) const> + P11) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12) const> + P11, P12) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13) const> + P11, P12, P13) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14) const> + P11, P12, P13, P14) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, P15) const> + P11, P12, P13, P14, P15) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16) const> + P16) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17) const> + P16, P17) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18) const> + P16, P17, P18) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19) const> + P16, P17, P18, P19) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, P20) const> + P16, P17, P18, P19, P20) const > {enum {result = 1};}; template <typename T, typename S> -struct IsMemberFunctionPointerRaw<T (S::*)( - ...) const> +struct IsMemberFunctionPointerRaw < T (S::*)( + ...) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, ...) const> +template < typename T, typename S, + typename P01 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, ...) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, ...) const> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, ...) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, ...) const> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, ...) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, ...) const> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, ...) const > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - ...) const> + ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, ...) const> + P06, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, ...) const> + P06, P07, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, ...) const> + P06, P07, P08, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, ...) const> + P06, P07, P08, P09, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - ...) const> + ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, ...) const> + P11, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, ...) const> + P11, P12, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, ...) const> + P11, P12, P13, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, ...) const> + P11, P12, P13, P14, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - ...) const> + ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, ...) const> + P16, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, ...) const> + P16, P17, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, ...) const> + P16, P17, P18, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, ...) const> + P16, P17, P18, P19, ...) const > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, - ...) const> + ...) const > {enum {result = 1};}; // Volatile versions @@ -1285,372 +1285,372 @@ template <typename T, typename S> struct IsMemberFunctionPointerRaw<T (S::*)() volatile> {enum {result = 1};}; -template <typename T, typename S, - typename P01> +template < typename T, typename S, + typename P01 > struct IsMemberFunctionPointerRaw<T (S::*)(P01) volatile> {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02) volatile> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03) volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04) volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, P05) volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, P05) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06) volatile> + P06) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07) volatile> + P06, P07) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08) volatile> + P06, P07, P08) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09) volatile> + P06, P07, P08, P09) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, P10) volatile> + P06, P07, P08, P09, P10) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11) volatile> + P11) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12) volatile> + P11, P12) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13) volatile> + P11, P12, P13) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14) volatile> + P11, P12, P13, P14) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, P15) volatile> + P11, P12, P13, P14, P15) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16) volatile> + P16) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17) volatile> + P16, P17) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18) volatile> + P16, P17, P18) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19) volatile> + P16, P17, P18, P19) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, P20) volatile> + P16, P17, P18, P19, P20) volatile > {enum {result = 1};}; template <typename T, typename S> -struct IsMemberFunctionPointerRaw<T (S::*)( - ...) volatile> +struct IsMemberFunctionPointerRaw < T (S::*)( + ...) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, ...) volatile> +template < typename T, typename S, + typename P01 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, ...) volatile> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, ...) volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, ...) volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - ...) volatile> + ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, ...) volatile> + P06, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, ...) volatile> + P06, P07, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, ...) volatile> + P06, P07, P08, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, ...) volatile> + P06, P07, P08, P09, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - ...) volatile> + ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, ...) volatile> + P11, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, ...) volatile> + P11, P12, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, ...) volatile> + P11, P12, P13, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, ...) volatile> + P11, P12, P13, P14, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - ...) volatile> + ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, ...) volatile> + P16, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, ...) volatile> + P16, P17, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, ...) volatile> + P16, P17, P18, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, ...) volatile> + P16, P17, P18, P19, ...) volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, - ...) volatile> + ...) volatile > {enum {result = 1};}; // Const volatile versions @@ -1659,372 +1659,372 @@ template <typename T, typename S> struct IsMemberFunctionPointerRaw<T (S::*)() const volatile> {enum {result = 1};}; -template <typename T, typename S, - typename P01> +template < typename T, typename S, + typename P01 > struct IsMemberFunctionPointerRaw<T (S::*)(P01) const volatile> {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02) const volatile> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03) const volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04) const volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, P05) const volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, P05) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06) const volatile> + P06) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07) const volatile> + P06, P07) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08) const volatile> + P06, P07, P08) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09) const volatile> + P06, P07, P08, P09) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, P10) const volatile> + P06, P07, P08, P09, P10) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11) const volatile> + P11) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12) const volatile> + P11, P12) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13) const volatile> + P11, P12, P13) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14) const volatile> + P11, P12, P13, P14) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, P15) const volatile> + P11, P12, P13, P14, P15) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16) const volatile> + P16) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17) const volatile> + P16, P17) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18) const volatile> + P16, P17, P18) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19) const volatile> + P16, P17, P18, P19) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, P20) const volatile> + P16, P17, P18, P19, P20) const volatile > {enum {result = 1};}; template <typename T, typename S> -struct IsMemberFunctionPointerRaw<T (S::*)( - ...) const volatile> +struct IsMemberFunctionPointerRaw < T (S::*)( + ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, ...) const volatile> +template < typename T, typename S, + typename P01 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, ...) const volatile> +template < typename T, typename S, + typename P01, typename P02 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, ...) const volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04> -struct IsMemberFunctionPointerRaw<T (S::*)( - P01, P02, P03, P04, ...) const volatile> +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04 > +struct IsMemberFunctionPointerRaw < T (S::*)( + P01, P02, P03, P04, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, - typename P01, typename P02, typename P03, typename P04, typename P05> -struct IsMemberFunctionPointerRaw<T (S::*)( +template < typename T, typename S, + typename P01, typename P02, typename P03, typename P04, typename P05 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - ...) const volatile> + ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, ...) const volatile> + P06, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, ...) const volatile> + P06, P07, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, ...) const volatile> + P06, P07, P08, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, - P06, P07, P08, P09, ...) const volatile> + P06, P07, P08, P09, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, - typename P06, typename P07, typename P08, typename P09, typename P10> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P06, typename P07, typename P08, typename P09, typename P10 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - ...) const volatile> + ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, ...) const volatile> + P11, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, ...) const volatile> + P11, P12, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, ...) const volatile> + P11, P12, P13, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, - P11, P12, P13, P14, ...) const volatile> + P11, P12, P13, P14, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, - typename P11, typename P12, typename P13, typename P14, typename P15> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P11, typename P12, typename P13, typename P14, typename P15 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - ...) const volatile> + ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, ...) const volatile> + P16, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, ...) const volatile> + P16, P17, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, ...) const volatile> + P16, P17, P18, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, - P16, P17, P18, P19, ...) const volatile> + P16, P17, P18, P19, ...) const volatile > {enum {result = 1};}; -template <typename T, typename S, +template < typename T, typename S, typename P01, typename P02, typename P03, typename P04, typename P05, typename P06, typename P07, typename P08, typename P09, typename P10, typename P11, typename P12, typename P13, typename P14, typename P15, - typename P16, typename P17, typename P18, typename P19, typename P20> -struct IsMemberFunctionPointerRaw<T (S::*)( + typename P16, typename P17, typename P18, typename P19, typename P20 > +struct IsMemberFunctionPointerRaw < T (S::*)( P01, P02, P03, P04, P05, P06, P07, P08, P09, P10, P11, P12, P13, P14, P15, P16, P17, P18, P19, P20, - ...) const volatile> + ...) const volatile > {enum {result = 1};}; }// namespace Private @@ -2179,37 +2179,37 @@ public: enum { isVolatile = UnVolatile<T>::isVolatile }; enum { isReference = ReferenceTraits<UnqualifiedType>::result }; enum { isFunction = FunctionPointerTraits<typename Private::AddPointer<T>::Result >::result }; - enum { isFunctionPointer= FunctionPointerTraits< - typename ReferenceTraits<UnqualifiedType>::ReferredType >::result + enum { isFunctionPointer = FunctionPointerTraits < + typename ReferenceTraits<UnqualifiedType>::ReferredType >::result }; - enum { isMemberFunctionPointer= PToMFunctionTraits< - typename ReferenceTraits<UnqualifiedType>::ReferredType >::result + enum { isMemberFunctionPointer = PToMFunctionTraits < + typename ReferenceTraits<UnqualifiedType>::ReferredType >::result }; - enum { isMemberPointer = PToMTraits< + enum { isMemberPointer = PToMTraits < typename ReferenceTraits<UnqualifiedType>::ReferredType >::result || isMemberFunctionPointer }; - enum { isPointer = PointerTraits< + enum { isPointer = PointerTraits < typename ReferenceTraits<UnqualifiedType>::ReferredType >::result || isFunctionPointer }; enum { isStdUnsignedInt = TL::IndexOf<Private::StdUnsignedInts, UnqualifiedType>::value >= 0 || - TL::IndexOf<Private::StdUnsignedInts, - typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0 + TL::IndexOf < Private::StdUnsignedInts, + typename ReferenceTraits<UnqualifiedType>::ReferredType >::value >= 0 }; enum { isStdSignedInt = TL::IndexOf<Private::StdSignedInts, UnqualifiedType>::value >= 0 || - TL::IndexOf<Private::StdSignedInts, - typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0 + TL::IndexOf < Private::StdSignedInts, + typename ReferenceTraits<UnqualifiedType>::ReferredType >::value >= 0 }; enum { isStdIntegral = isStdUnsignedInt || isStdSignedInt || TL::IndexOf<Private::StdOtherInts, UnqualifiedType>::value >= 0 || - TL::IndexOf<Private::StdOtherInts, - typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0 + TL::IndexOf < Private::StdOtherInts, + typename ReferenceTraits<UnqualifiedType>::ReferredType >::value >= 0 }; enum { isStdFloat = TL::IndexOf<Private::StdFloats, UnqualifiedType>::value >= 0 || - TL::IndexOf<Private::StdFloats, - typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0 + TL::IndexOf < Private::StdFloats, + typename ReferenceTraits<UnqualifiedType>::ReferredType >::value >= 0 }; enum { isStdArith = isStdIntegral || isStdFloat }; enum { isStdFundamental = isStdArith || isStdFloat || Conversion<T, void>::sameType }; @@ -2221,8 +2221,8 @@ public: enum { isArith = isIntegral || isFloat }; enum { isFundamental = isStdFundamental || isArith }; - typedef typename Select<isStdArith || isPointer || isMemberPointer, T, - typename Private::AddParameterType<T>::Result>::Result + typedef typename Select < isStdArith || isPointer || isMemberPointer, T, + typename Private::AddParameterType<T>::Result >::Result ParameterType; }; } diff --git a/shared/loki/Typelist.h b/shared/loki/Typelist.h index ba18032f..e512ac83 100644 --- a/shared/loki/Typelist.h +++ b/shared/loki/Typelist.h @@ -129,7 +129,7 @@ struct TypeAt<Typelist<Head, Tail>, 0> template <class Head, class Tail, unsigned int i> struct TypeAt<Typelist<Head, Tail>, i> { - typedef typename TypeAt<Tail, i - 1>::Result Result; + typedef typename TypeAt < Tail, i - 1 >::Result Result; }; //////////////////////////////////////////////////////////////////////////////// @@ -144,8 +144,8 @@ struct TypeAt<Typelist<Head, Tail>, i> // returns the type in position 'index' in TList, or D if index is out-of-bounds //////////////////////////////////////////////////////////////////////////////// -template <class TList, unsigned int index, - typename DefaultType = NullType> +template < class TList, unsigned int index, + typename DefaultType = NullType > struct TypeAtNonStrict { typedef DefaultType Result; @@ -161,7 +161,7 @@ template <class Head, class Tail, unsigned int i, typename DefaultType> struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType> { typedef typename - TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result; + TypeAtNonStrict < Tail, i - 1, DefaultType >::Result Result; }; //////////////////////////////////////////////////////////////////////////////// @@ -212,7 +212,7 @@ template <> struct Append<NullType, NullType> template <class T> struct Append<NullType, T> { - typedef Typelist<T,NullType> Result; + typedef Typelist<T, NullType> Result; }; template <class Head, class Tail> @@ -224,8 +224,8 @@ struct Append<NullType, Typelist<Head, Tail> > template <class Head, class Tail, class T> struct Append<Typelist<Head, Tail>, T> { - typedef Typelist<Head, - typename Append<Tail, T>::Result> + typedef Typelist < Head, + typename Append<Tail, T>::Result > Result; }; @@ -254,8 +254,8 @@ struct Erase<Typelist<T, Tail>, T> template <class Head, class Tail, class T> // Specialization 3 struct Erase<Typelist<Head, Tail>, T> { - typedef Typelist<Head, - typename Erase<Tail, T>::Result> + typedef Typelist < Head, + typename Erase<Tail, T>::Result > Result; }; @@ -283,8 +283,8 @@ template <class Head, class Tail, class T> struct EraseAll<Typelist<Head, Tail>, T> { // Go all the way down the list removing the type - typedef Typelist<Head, - typename EraseAll<Tail, T>::Result> + typedef Typelist < Head, + typename EraseAll<Tail, T>::Result > Result; }; @@ -337,8 +337,8 @@ struct Replace<Typelist<T, Tail>, T, U> template <class Head, class Tail, class T, class U> struct Replace<Typelist<Head, Tail>, T, U> { - typedef Typelist<Head, - typename Replace<Tail, T, U>::Result> + typedef Typelist < Head, + typename Replace<Tail, T, U>::Result > Result; }; @@ -367,8 +367,8 @@ struct ReplaceAll<Typelist<T, Tail>, T, U> template <class Head, class Tail, class T, class U> struct ReplaceAll<Typelist<Head, Tail>, T, U> { - typedef Typelist<Head, - typename ReplaceAll<Tail, T, U>::Result> + typedef Typelist < Head, + typename ReplaceAll<Tail, T, U>::Result > Result; }; @@ -391,8 +391,8 @@ struct Reverse<NullType> template <class Head, class Tail> struct Reverse< Typelist<Head, Tail> > { - typedef typename Append< - typename Reverse<Tail>::Result, Head>::Result Result; + typedef typename Append < + typename Reverse<Tail>::Result, Head >::Result Result; }; //////////////////////////////////////////////////////////////////////////////// @@ -417,9 +417,9 @@ struct MostDerived<Typelist<Head, Tail>, T> private: typedef typename MostDerived<Tail, T>::Result Candidate; public: - typedef typename Select< - SuperSubclass<Candidate,Head>::value, - Head, Candidate>::Result Result; + typedef typename Select < + SuperSubclass<Candidate, Head>::value, + Head, Candidate >::Result Result; }; //////////////////////////////////////////////////////////////////////////////// @@ -444,8 +444,8 @@ struct DerivedToFront< Typelist<Head, Tail> > private: typedef typename MostDerived<Tail, Head>::Result TheMostDerived; - typedef typename Replace<Tail, - TheMostDerived, Head>::Result Temp; + typedef typename Replace < Tail, + TheMostDerived, Head >::Result Temp; typedef typename DerivedToFront<Temp>::Result L; public: typedef Typelist<TheMostDerived, L> Result; diff --git a/shared/loki/TypelistMacros.h b/shared/loki/TypelistMacros.h index 1c3c3e63..4bd34cb7 100644 --- a/shared/loki/TypelistMacros.h +++ b/shared/loki/TypelistMacros.h @@ -61,291 +61,291 @@ #define LOKI_TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \ ::Loki::Typelist<T1, LOKI_TYPELIST_11(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12) > + T11, T12) > #define LOKI_TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \ ::Loki::Typelist<T1, LOKI_TYPELIST_12(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13) > + T11, T12, T13) > #define LOKI_TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14) > + T11, T12, T13, T14) \ +::Loki::Typelist<T1, LOKI_TYPELIST_13(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14) > #define LOKI_TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15) > + T11, T12, T13, T14, T15) \ +::Loki::Typelist<T1, LOKI_TYPELIST_14(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15) > #define LOKI_TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_15(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16) > + T11, T12, T13, T14, T15, T16) \ +::Loki::Typelist<T1, LOKI_TYPELIST_15(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16) > #define LOKI_TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_16(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17) > + T11, T12, T13, T14, T15, T16, T17) \ +::Loki::Typelist<T1, LOKI_TYPELIST_16(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17) > #define LOKI_TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_17(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18) > + T11, T12, T13, T14, T15, T16, T17, T18) \ +::Loki::Typelist<T1, LOKI_TYPELIST_17(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18) > #define LOKI_TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_18(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19) > + T11, T12, T13, T14, T15, T16, T17, T18, T19) \ +::Loki::Typelist<T1, LOKI_TYPELIST_18(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19) > #define LOKI_TYPELIST_20(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_19(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) \ +::Loki::Typelist<T1, LOKI_TYPELIST_19(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) > #define LOKI_TYPELIST_21(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_20(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) \ +::Loki::Typelist<T1, LOKI_TYPELIST_20(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) > #define LOKI_TYPELIST_22(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_21(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) \ +::Loki::Typelist<T1, LOKI_TYPELIST_21(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) > #define LOKI_TYPELIST_23(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_22(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) \ +::Loki::Typelist<T1, LOKI_TYPELIST_22(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23) > #define LOKI_TYPELIST_24(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_23(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) \ +::Loki::Typelist<T1, LOKI_TYPELIST_23(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24) > #define LOKI_TYPELIST_25(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_24(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) \ +::Loki::Typelist<T1, LOKI_TYPELIST_24(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25) > #define LOKI_TYPELIST_26(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_25(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26) \ +::Loki::Typelist<T1, LOKI_TYPELIST_25(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26) > #define LOKI_TYPELIST_27(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_26(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27) \ +::Loki::Typelist<T1, LOKI_TYPELIST_26(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27) > #define LOKI_TYPELIST_28(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_27(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28) \ +::Loki::Typelist<T1, LOKI_TYPELIST_27(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28) > #define LOKI_TYPELIST_29(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_28(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29) \ +::Loki::Typelist<T1, LOKI_TYPELIST_28(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29) > #define LOKI_TYPELIST_30(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_29(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) \ +::Loki::Typelist<T1, LOKI_TYPELIST_29(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30) > #define LOKI_TYPELIST_31(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_30(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) \ +::Loki::Typelist<T1, LOKI_TYPELIST_30(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31) > #define LOKI_TYPELIST_32(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_31(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) \ +::Loki::Typelist<T1, LOKI_TYPELIST_31(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32) > #define LOKI_TYPELIST_33(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_32(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) \ +::Loki::Typelist<T1, LOKI_TYPELIST_32(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33) > #define LOKI_TYPELIST_34(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_33(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) \ +::Loki::Typelist<T1, LOKI_TYPELIST_33(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34) > #define LOKI_TYPELIST_35(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_34(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35) \ +::Loki::Typelist<T1, LOKI_TYPELIST_34(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35) > #define LOKI_TYPELIST_36(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_35(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36) \ +::Loki::Typelist<T1, LOKI_TYPELIST_35(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36) > #define LOKI_TYPELIST_37(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_36(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37) \ +::Loki::Typelist<T1, LOKI_TYPELIST_36(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37) > #define LOKI_TYPELIST_38(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_37(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38) \ +::Loki::Typelist<T1, LOKI_TYPELIST_37(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38) > #define LOKI_TYPELIST_39(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_38(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39) \ +::Loki::Typelist<T1, LOKI_TYPELIST_38(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39) > #define LOKI_TYPELIST_40(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_39(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) \ +::Loki::Typelist<T1, LOKI_TYPELIST_39(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40) > #define LOKI_TYPELIST_41(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_40(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) \ +::Loki::Typelist<T1, LOKI_TYPELIST_40(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41) > #define LOKI_TYPELIST_42(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_41(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) \ +::Loki::Typelist<T1, LOKI_TYPELIST_41(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42) > #define LOKI_TYPELIST_43(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) \ +::Loki::Typelist<T1, LOKI_TYPELIST_42(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43) > #define LOKI_TYPELIST_44(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) \ +::Loki::Typelist<T1, LOKI_TYPELIST_43(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44) > #define LOKI_TYPELIST_45(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45) \ +::Loki::Typelist<T1, LOKI_TYPELIST_44(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45) > #define LOKI_TYPELIST_46(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46) \ +::Loki::Typelist<T1, LOKI_TYPELIST_45(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46) > #define LOKI_TYPELIST_47(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47) \ +::Loki::Typelist<T1, LOKI_TYPELIST_46(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47) > #define LOKI_TYPELIST_48(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47, T48) \ +::Loki::Typelist<T1, LOKI_TYPELIST_47(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47, T48) > #define LOKI_TYPELIST_49(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47, T48, T49) \ +::Loki::Typelist<T1, LOKI_TYPELIST_48(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47, T48, T49) > #define LOKI_TYPELIST_50(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) \ - ::Loki::Typelist<T1, LOKI_TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ - T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ - T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ - T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ - T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) > + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) \ +::Loki::Typelist<T1, LOKI_TYPELIST_49(T2, T3, T4, T5, T6, T7, T8, T9, T10, \ + T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, \ + T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, \ + T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, \ + T41, T42, T43, T44, T45, T46, T47, T48, T49, T50) > #endif //LOKI_DISABLE_TYPELIST_MACROS diff --git a/shared/loki/Visitor.h b/shared/loki/Visitor.h index f6b0ad81..85b8acd2 100644 --- a/shared/loki/Visitor.h +++ b/shared/loki/Visitor.h @@ -249,7 +249,7 @@ typename R = void, > class BaseVisitable; -template<typename R,template <typename, class> class CatchAll> +template<typename R, template <typename, class> class CatchAll> class BaseVisitable<R, CatchAll, false> { public: @@ -262,7 +262,7 @@ protected: // give access only to the hierarchy static ReturnType AcceptImpl(T& visited, BaseVisitor& guest) { // Apply the Acyclic Visitor - if (Visitor<T,R>* p = dynamic_cast<Visitor<T,R>*>(&guest)) + if (Visitor<T, R>* p = dynamic_cast<Visitor<T, R>*>(&guest)) { return p->Visit(visited); } @@ -270,7 +270,7 @@ protected: // give access only to the hierarchy } }; -template<typename R,template <typename, class> class CatchAll> +template<typename R, template <typename, class> class CatchAll> class BaseVisitable<R, CatchAll, true> { public: @@ -283,7 +283,7 @@ protected: // give access only to the hierarchy static ReturnType AcceptImpl(const T& visited, BaseVisitor& guest) { // Apply the Acyclic Visitor - if (Visitor<T,R,true>* p = dynamic_cast<Visitor<T,R,true>*>(&guest)) + if (Visitor<T, R, true>* p = dynamic_cast<Visitor<T, R, true>*>(&guest)) { return p->Visit(visited); } diff --git a/shared/long_path_prefix.h b/shared/long_path_prefix.h index 45fde0fa..ca6961a9 100644 --- a/shared/long_path_prefix.h +++ b/shared/long_path_prefix.h @@ -83,7 +83,7 @@ inline Zstring zen::applyLongPathPrefixCreateDir(const Zstring& path) //throw() { //special rule for ::CreateDirectoryEx(): MAX_PATH - 12(=^ 8.3 filename) is threshold - return applyLongPathPrefixImpl<MAX_PATH - 12>(path); + return applyLongPathPrefixImpl < MAX_PATH - 12 > (path); } diff --git a/shared/parse_lng.h b/shared/parse_lng.h index b943d222..034deb68 100644 --- a/shared/parse_lng.h +++ b/shared/parse_lng.h @@ -309,7 +309,7 @@ private: { std::string tmp; for (std::string::const_iterator i = text.begin(); i != text.end(); ++i) - if(*i == '\r') + if (*i == '\r') { std::string::const_iterator next = i + 1; if (next != text.end() && *next == '\n') @@ -451,7 +451,7 @@ private: } - if (!pluralList.empty()&& static_cast<int>(pluralList.size()) != formCount) //invalid number of plural forms + if (!pluralList.empty() && static_cast<int>(pluralList.size()) != formCount) //invalid number of plural forms throw ParsingError(scn.position().first, scn.position().second); consumeToken(Token::TK_TRG_END); @@ -572,7 +572,7 @@ void generateLng(const TranslationList& in, const TransHeader& header, std::stri fileStream += KnownTokens::text(Token::TK_TRG_BEGIN); fileStream += translation; - fileStream += KnownTokens::text(Token::TK_TRG_END) + LB; + fileStream += KnownTokens::text(Token::TK_TRG_END) + LB + LB; } else if (plural) @@ -590,7 +590,7 @@ void generateLng(const TranslationList& in, const TransHeader& header, std::stri fileStream += KnownTokens::text(Token::TK_PLURAL_END) + LB; fileStream += KnownTokens::text(Token::TK_PLURAL_BEGIN); fileStream += engPlural; - fileStream += KnownTokens::text(Token::TK_PLURAL_END)+ LB; + fileStream += KnownTokens::text(Token::TK_PLURAL_END) + LB; fileStream += KnownTokens::text(Token::TK_SRC_END) + LB; fileStream += KnownTokens::text(Token::TK_TRG_BEGIN); @@ -605,7 +605,7 @@ void generateLng(const TranslationList& in, const TransHeader& header, std::stri fileStream += plForm; fileStream += KnownTokens::text(Token::TK_PLURAL_END) + LB; } - fileStream += KnownTokens::text(Token::TK_TRG_END) + LB; + fileStream += KnownTokens::text(Token::TK_TRG_END) + LB + LB; } else { diff --git a/shared/parse_plural.h b/shared/parse_plural.h index 1139ffb6..1d2bcd95 100644 --- a/shared/parse_plural.h +++ b/shared/parse_plural.h @@ -240,7 +240,7 @@ private: const Expression& e = parse(); expr = &dynamic_cast<const Expr<int>&>(e); } - catch(std::bad_cast&) { throw ParsingError(); } + catch (std::bad_cast&) { throw ParsingError(); } consumeToken(Token::TK_END); } @@ -327,7 +327,7 @@ private: Token::Type t = token().type; if (t == Token::TK_LESS || //associativity: n/a - t == Token::TK_LESS_EQUAL|| + t == Token::TK_LESS_EQUAL || t == Token::TK_GREATER || t == Token::TK_GREATER_EQUAL) { diff --git a/shared/parse_txt.h b/shared/parse_txt.h index ca155dec..479f950e 100644 --- a/shared/parse_txt.h +++ b/shared/parse_txt.h @@ -16,8 +16,8 @@ namespace zen class ExtractLines { public: - ExtractLines(const Zstring& filename, const std::string& lineBreak = std::string()); //throw (FileError) - bool getLine(std::string& output); //throw (FileError) + ExtractLines(const Zstring& filename, const std::string& lineBreak = std::string()); //throw FileError + bool getLine(std::string& output); //throw FileError private: zen::FileInput inputStream; diff --git a/shared/privilege.cpp b/shared/privilege.cpp index eaeac866..6c7d951b 100644 --- a/shared/privilege.cpp +++ b/shared/privilege.cpp @@ -13,17 +13,14 @@ Privileges& Privileges::getInstance() } -bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) +bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw FileError { HANDLE hToken = NULL; if (!::OpenProcessToken(::GetCurrentProcess(), //__in HANDLE ProcessHandle, TOKEN_QUERY, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); - (void)dummy; //silence warning "unused variable" - + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hToken)); LUID luid = {}; if (!::LookupPrivilegeValue( @@ -49,16 +46,14 @@ bool Privileges::privilegeIsActive(LPCTSTR privilege) //throw (FileError) } -void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw (FileError) +void Privileges::setPrivilege(LPCTSTR privilege, bool enable) //throw FileError { HANDLE hToken = NULL; if (!::OpenProcessToken(::GetCurrentProcess(), //__in HANDLE ProcessHandle, TOKEN_ADJUST_PRIVILEGES, //__in DWORD DesiredAccess, &hToken)) //__out PHANDLE TokenHandle throw FileError(_("Error setting privilege:") + " \"" + privilege + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hToken); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hToken)); LUID luid = {}; if (!::LookupPrivilegeValue( diff --git a/shared/privilege.h b/shared/privilege.h index 6ac99e6f..09fe0d08 100644 --- a/shared/privilege.h +++ b/shared/privilege.h @@ -15,7 +15,7 @@ class Privileges public: static Privileges& getInstance(); - void ensureActive(LPCTSTR privilege) //throw (FileError) + void ensureActive(LPCTSTR privilege) //throw FileError { if (activePrivileges.find(privilege) != activePrivileges.end()) return; //privilege already active @@ -42,7 +42,7 @@ private: if (i->second) Privileges::setPrivilege(i->first.c_str(), false); } - catch(...) {} + catch (...) {} } static bool privilegeIsActive(LPCTSTR privilege); //throw FileError diff --git a/shared/recycler.cpp b/shared/recycler.cpp index 92b7b222..8c4a9da1 100644 --- a/shared/recycler.cpp +++ b/shared/recycler.cpp @@ -14,7 +14,6 @@ #include <boost/thread/once.hpp> #include "dll_loader.h" #include <wx/msw/wrapwin.h> //includes "windows.h" -#include "build_info.h" #include "assert_static.h" #include <algorithm> #include <functional> @@ -33,17 +32,6 @@ using namespace zen; namespace { #ifdef FFS_WIN -inline -std::wstring getRecyclerDllName() -{ - assert_static(util::is32BitBuild || util::is64BitBuild); - - return util::is64BitBuild ? - L"FileOperation_x64.dll": - L"FileOperation_Win32.dll"; -} - - bool vistaOrLater() { OSVERSIONINFO osvi = {}; @@ -71,7 +59,7 @@ IFileOperation - multiple files 2,1s Nevertheless, let's use IFileOperation for better error reporting! */ -void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw (FileError) +void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw FileError { if (filesToDelete.empty()) return; @@ -87,12 +75,12 @@ void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw ( std::back_inserter(fileNames), std::mem_fun_ref(&Zstring::c_str)); using namespace fileop; - MoveToRecycleBinFct moveToRecycler = util::getDllFun<MoveToRecycleBinFct>(getRecyclerDllName(), moveToRecycleBinFctName); - GetLastErrorFct getLastError = util::getDllFun<GetLastErrorFct> (getRecyclerDllName(), getLastErrorFctName); + const util::DllFun<MoveToRecycleBinFct> moveToRecycler(getDllName(), moveToRecycleBinFctName); + const util::DllFun<GetLastErrorFct> getLastError (getDllName(), getLastErrorFctName); - if (moveToRecycler == NULL || getLastError == NULL) + if (!moveToRecycler || !getLastError) throw FileError(_("Error moving to Recycle Bin:") + "\n\"" + fileNames[0] + "\"" + //report first file only... better than nothing - "\n\n" + _("Could not load a required DLL:") + " \"" + getRecyclerDllName() + "\""); + "\n\n" + _("Could not load a required DLL:") + " \"" + getDllName() + "\""); //#warning moving long file paths to recycler does not work! clarify! // std::vector<Zstring> temp; @@ -140,7 +128,7 @@ void moveToWindowsRecycler(const std::vector<Zstring>& filesToDelete) //throw ( } -bool zen::moveToRecycleBin(const Zstring& filename) //throw (FileError) +bool zen::moveToRecycleBin(const Zstring& filename) //throw FileError { if (!somethingExists(filename)) return false; //neither file nor any other object with that name existing: no error situation, manual deletion relies on it! @@ -151,7 +139,7 @@ bool zen::moveToRecycleBin(const Zstring& filename) //throw (FileError) std::vector<Zstring> fileNames; fileNames.push_back(filename); - ::moveToWindowsRecycler(fileNames); //throw (FileError) + ::moveToWindowsRecycler(fileNames); //throw FileError #elif defined FFS_LINUX Glib::RefPtr<Gio::File> fileObj = Gio::File::create_for_path(filename.c_str()); //never fails diff --git a/shared/resolve_path.cpp b/shared/resolve_path.cpp index 2a9cb7e6..f22b4505 100644 --- a/shared/resolve_path.cpp +++ b/shared/resolve_path.cpp @@ -3,9 +3,11 @@ #include <wx/datetime.h> #include "string_conv.h" #include "loki/ScopeGuard.h" +#include <map> #ifdef FFS_WIN #include "dll_loader.h" +#include <Shlobj.h> #include <wx/msw/wrapwin.h> //includes "windows.h" #include "long_path_prefix.h" #ifdef _MSC_VER @@ -26,6 +28,17 @@ namespace #ifdef FFS_WIN Zstring resolveBrokenNetworkMap(const Zstring& dirname) //circumvent issue with disconnected network maps that could be activated by a simple explorer double click { + /* + ATTENTION: it is not safe to call ::WNetGetConnection() for every network share: + + network type |::WNetGetConnection rv | lpRemoteName | existing UNC path + -----------------------------|-------------------------|---------------------------------|---------------- + inactive local network share | ERROR_CONNECTION_UNAVAIL| \\192.168.1.27\new2 | YES + WebDrive | NO_ERROR | \\Webdrive-ZenJu\GNU | NO + Box.net (WebDav) | NO_ERROR | \\www.box.net\DavWWWRoot\dav | YES + NetDrive | ERROR_NOT_CONNECTED | <empty> | NO + */ + if (dirname.size() >= 2 && iswalpha(dirname[0]) && dirname[1] == L':') { Zstring driveLetter(dirname.c_str(), 2); //e.g.: "Q:" @@ -37,13 +50,12 @@ Zstring resolveBrokenNetworkMap(const Zstring& dirname) //circumvent issue with DWORD rv = ::WNetGetConnection(driveLetter.c_str(), //__in LPCTSTR lpLocalName in the form "<driveletter>:" &remoteNameBuffer[0], //__out LPTSTR lpRemoteName, &bufferSize); //__inout LPDWORD lpnLength - if (rv == NO_ERROR || - rv == ERROR_CONNECTION_UNAVAIL) //remoteNameBuffer will be filled nevertheless! - { - Zstring networkShare = &remoteNameBuffer[0]; - if (!networkShare.empty()) - return networkShare + (dirname.c_str() + 2); //replace "Q:\subdir" by "\\server\share\subdir" - } + if (rv == ERROR_CONNECTION_UNAVAIL) //remoteNameBuffer will be filled nevertheless! + { + Zstring networkShare = &remoteNameBuffer[0]; + if (!networkShare.empty()) + return networkShare + (dirname.c_str() + 2); //replace "Q:\subdir" by "\\server\share\subdir" + } } } return dirname; @@ -80,6 +92,96 @@ Zstring resolveRelativePath(const Zstring& relativeName) //additional: resolves #endif +#ifdef FFS_WIN +class CsidlConstants +{ +public: + typedef std::map<Zstring, Zstring, LessFilename> CsidlToDirMap; //case-insensitive comparison + + static const CsidlToDirMap& get() + { + static CsidlConstants inst; + return inst.csidlToDir; + } + +private: + CsidlConstants() + { + auto addCsidl = [&](int csidl, const Zstring& paramName) + { + wchar_t buffer[MAX_PATH]; + if (SUCCEEDED(::SHGetFolderPath(NULL, //__in HWND hwndOwner, + csidl | CSIDL_FLAG_DONT_VERIFY, //__in int nFolder, + NULL, //__in HANDLE hToken, + 0 /* == SHGFP_TYPE_CURRENT*/, //__in DWORD dwFlags, + buffer))) //__out LPTSTR pszPath + { + Zstring dirname = buffer; + if (!dirname.empty()) + csidlToDir.insert(std::make_pair(paramName, dirname)); + } + }; + + addCsidl(CSIDL_DESKTOPDIRECTORY, L"csidl_Desktop"); // C:\Users\username\Desktop + addCsidl(CSIDL_COMMON_DESKTOPDIRECTORY, L"csidl_PublicDesktop"); // C:\Users\All Users\Desktop + + addCsidl(CSIDL_MYMUSIC, L"csidl_MyMusic"); // C:\Users\username\My Documents\My Music + addCsidl(CSIDL_COMMON_MUSIC, L"csidl_PublicMusic"); // C:\Users\All Users\Documents\My Music + + addCsidl(CSIDL_MYPICTURES, L"csidl_MyPictures"); // C:\Users\username\My Documents\My Pictures + addCsidl(CSIDL_COMMON_PICTURES, L"csidl_PublicPictures"); // C:\Users\All Users\Documents\My Pictures + + addCsidl(CSIDL_MYVIDEO, L"csidl_MyVideo"); // C:\Users\username\My Documents\My Videos + addCsidl(CSIDL_COMMON_VIDEO, L"csidl_PublicVideo"); // C:\Users\All Users\Documents\My Videos + + addCsidl(CSIDL_PERSONAL, L"csidl_MyDocuments"); // C:\Users\username\My Documents + addCsidl(CSIDL_COMMON_DOCUMENTS, L"csidl_PublicDocuments"); // C:\Users\All Users\Documents + + addCsidl(CSIDL_STARTMENU, L"csidl_StartMenu"); // C:\Users\username\Start Menu + addCsidl(CSIDL_COMMON_STARTMENU, L"csidl_PublicStartMenu"); // C:\Users\All Users\Start Menu + + addCsidl(CSIDL_FAVORITES, L"csidl_Favorites"); // C:\Users\username\Favorites + addCsidl(CSIDL_COMMON_FAVORITES, L"csidl_PublicFavorites"); // C:\Users\All Users\Favoriten + + addCsidl(CSIDL_TEMPLATES, L"csidl_Templates"); // C:\Users\username\Templates + addCsidl(CSIDL_COMMON_TEMPLATES, L"csidl_PublicTemplates"); // C:\Users\All Users\Templates + + addCsidl(CSIDL_RESOURCES, L"csidl_Resources"); // C:\Windows\Resources + + //CSIDL_APPDATA covered by %AppData% + //CSIDL_LOCAL_APPDATA covered by %LocalAppData% + //CSIDL_COMMON_APPDATA covered by %ProgramData% + + //CSIDL_PROFILE covered by %UserProfile% + } + + CsidlConstants(const CsidlConstants&); + CsidlConstants& operator=(const CsidlConstants&); + + CsidlToDirMap csidlToDir; +}; +#endif + + +wxString getEnvValue(const wxString& envName) //return empty on error +{ + //try to apply environment variables + wxString envValue; + if (wxGetEnv(envName, &envValue)) + { + //some postprocessing: + trim(envValue); //remove leading, trailing blanks + + //remove leading, trailing double-quotes + if (startsWith(envValue, L"\"") && + endsWith(envValue, L"\"") && + envValue.length() >= 2) + envValue = wxString(envValue.c_str() + 1, envValue.length() - 2); + } + return envValue; +} + + bool replaceMacro(wxString& macro) //macro without %-characters, return true if replaced successfully { if (macro.IsEmpty()) @@ -117,22 +219,27 @@ bool replaceMacro(wxString& macro) //macro without %-characters, return true if if (processPhrase(L"sec" , L"%S")) return true; //try to apply environment variables - wxString envValue; - if (wxGetEnv(macro, &envValue)) { - macro = envValue; - - //some postprocessing: - macro.Trim(true); //remove leading, trailing blanks - macro.Trim(false); // + wxString envValue = getEnvValue(macro); + if (!envValue.empty()) + { + macro = envValue; + return true; + } + } - //remove leading, trailing double-quotes - if (macro.StartsWith(wxT("\"")) && - macro.EndsWith(wxT("\"")) && - macro.length() >= 2) - macro = wxString(macro.c_str() + 1, macro.length() - 2); - return true; +#ifdef FFS_WIN + //try to resolve CSIDL values + { + auto csidlMap = CsidlConstants::get(); + auto iter = csidlMap.find(toZ(macro)); + if (iter != csidlMap.end()) + { + macro = toWx(iter->second); + return true; + } } +#endif return false; } @@ -190,7 +297,7 @@ private: #endif -Zstring getVolumePath(const Zstring& volumeName) //empty string on error +Zstring volumenNameToPath(const Zstring& volumeName) //return empty string on error { #ifdef FFS_WIN std::vector<wchar_t> volGuid(10000); @@ -198,8 +305,7 @@ Zstring getVolumePath(const Zstring& volumeName) //empty string on error HANDLE hVol = ::FindFirstVolume(&volGuid[0], static_cast<DWORD>(volGuid.size())); if (hVol != INVALID_HANDLE_VALUE) { - Loki::ScopeGuard dummy = Loki::MakeGuard(::FindVolumeClose, hVol); - (void)dummy; + LOKI_ON_BLOCK_EXIT2(::FindVolumeClose(hVol)); do { @@ -222,10 +328,8 @@ Zstring getVolumePath(const Zstring& volumeName) //empty string on error DWORD cchBufferLength, PDWORD lpcchReturnLength); - static const GetVolumePathNamesForVolumeNameWFunc getVolumePathNamesForVolumeName = - util::getDllFun<GetVolumePathNamesForVolumeNameWFunc>(L"kernel32.dll", "GetVolumePathNamesForVolumeNameW"); - - if (getVolumePathNamesForVolumeName != NULL) + const util::DllFun<GetVolumePathNamesForVolumeNameWFunc> getVolumePathNamesForVolumeName(L"kernel32.dll", "GetVolumePathNamesForVolumeNameW"); + if (getVolumePathNamesForVolumeName) { std::vector<wchar_t> volPath(10000); @@ -261,6 +365,28 @@ Zstring getVolumePath(const Zstring& volumeName) //empty string on error } +#ifdef FFS_WIN +Zstring volumePathToName(const Zstring& volumePath) //return empty string on error +{ + const DWORD bufferSize = MAX_PATH + 1; + std::vector<wchar_t> volName(bufferSize); + + if (::GetVolumeInformation(volumePath.c_str(), //__in_opt LPCTSTR lpRootPathName, + &volName[0], //__out LPTSTR lpVolumeNameBuffer, + bufferSize, //__in DWORD nVolumeNameSize, + NULL, //__out_opt LPDWORD lpVolumeSerialNumber, + NULL, //__out_opt LPDWORD lpMaximumComponentLength, + NULL, //__out_opt LPDWORD lpFileSystemFlags, + NULL, //__out LPTSTR lpFileSystemNameBuffer, + 0)) //__in DWORD nFileSystemNameSize + { + return &volName[0]; + } + return Zstring(); +} +#endif + + void expandVolumeName(Zstring& text) // [volname]:\folder [volname]\folder [volname]folder -> C:\folder { Zstring before; @@ -287,7 +413,7 @@ void expandVolumeName(Zstring& text) // [volname]:\folder [volname]\folde if (volname.empty()) return; - Zstring volPath = getVolumePath(volname); //return empty string on error + Zstring volPath = volumenNameToPath(volname); //return empty string on error if (volPath.empty()) return; @@ -299,6 +425,86 @@ void expandVolumeName(Zstring& text) // [volname]:\folder [volname]\folde } +#ifdef FFS_WIN +std::vector<Zstring> zen::getDirectoryAliases(Zstring dirname) +{ + trim(dirname, true, false); + + std::vector<Zstring> output; + + if (dirname.empty()) + return output; + + //1. replace volume path by volume name: c:\dirname -> [SYSTEM]\dirname + if (dirname.size() >= 3 && + std::iswalpha(dirname[0]) && + dirname[1] == L':' && + dirname[2] == L'\\') + { + Zstring volname = volumePathToName(Zstring(dirname.c_str(), 3)); + if (!volname.empty()) + output.push_back(L"[" + volname + L"]" + Zstring(dirname.c_str() + 2)); + } + + //2. replace volume name by volume path: [SYSTEM]\dirname -> c:\dirname + { + Zstring testVolname = dirname; + expandVolumeName(testVolname); + if (testVolname != dirname) + output.push_back(testVolname); + } + + //3. environment variables: C:\Users\username -> %USERPROFILE% + { + std::map<Zstring, Zstring> envToDir; + + //get list of useful variables + auto addEnvVar = [&](const wxString& envName) + { + wxString envVal = getEnvValue(envName); //return empty on error + if (!envVal.empty()) + envToDir.insert(std::make_pair(toZ(envName), toZ(envVal))); + }; + addEnvVar(L"AllUsersProfile"); // C:\ProgramData + addEnvVar(L"AppData"); // C:\Users\username\AppData\Roaming + addEnvVar(L"LocalAppData"); // C:\Users\username\AppData\Local + addEnvVar(L"ProgramData"); // C:\ProgramData + addEnvVar(L"ProgramFiles"); // C:\Program Files + addEnvVar(L"ProgramFiles(x86)");// C:\Program Files (x86) + addEnvVar(L"Public"); // C:\Users\Public + addEnvVar(L"UserProfile"); // C:\Users\username + addEnvVar(L"WinDir"); // C:\Windows + addEnvVar(L"Temp"); // C:\Windows\Temp + + //add CSIDL values: http://msdn.microsoft.com/en-us/library/bb762494(v=vs.85).aspx + auto csidlMap = CsidlConstants::get(); + envToDir.insert(csidlMap.begin(), csidlMap.end()); + + Zstring tmp = dirname; + ::makeUpper(tmp); + std::for_each(envToDir.begin(), envToDir.end(), + [&](const std::pair<Zstring, Zstring>& entry) + { + Zstring tmp2 = entry.second; //case-insensitive "startsWith()" + ::makeUpper(tmp2); // + if (startsWith(tmp, tmp2)) + output.push_back(L"%" + entry.first + L"%" + (dirname.c_str() + tmp2.size())); + }); + } + + //5. replace (all) macros: //%USERPROFILE% -> C:\Users\username + { + wxString testMacros = toWx(dirname); + expandMacros(testMacros); + if (toZ(testMacros) != dirname) + output.push_back(toZ(testMacros)); + } + + return output; +} +#endif + + Zstring zen::getFormattedDirectoryName(const Zstring& dirname) { //Formatting is needed since functions expect the directory to end with '\' to be able to split the relative names. diff --git a/shared/resolve_path.h b/shared/resolve_path.h index f6ae58cb..3be1d78e 100644 --- a/shared/resolve_path.h +++ b/shared/resolve_path.h @@ -13,6 +13,11 @@ namespace zen { Zstring getFormattedDirectoryName(const Zstring& dirname); + + +#ifdef FFS_WIN +std::vector<Zstring> getDirectoryAliases(Zstring dirname); +#endif } diff --git a/shared/serialize.cpp b/shared/serialize.cpp index 26102820..06d409df 100644 --- a/shared/serialize.cpp +++ b/shared/serialize.cpp @@ -10,7 +10,7 @@ using namespace zen; -void ReadInputStream::throwReadError() const //throw (FileError) +void ReadInputStream::throwReadError() const //throw FileError { throw zen::FileError(_("Error reading from synchronization database:") + " \n" + "\"" + errorObjName_.c_str() + "\""); } @@ -32,7 +32,7 @@ ReadInputStream::CharArray ReadInputStream::readArrayC() const //-------------------------------------------------------------------------------------------------------- -void WriteOutputStream::throwWriteError() const //throw (FileError) +void WriteOutputStream::throwWriteError() const //throw FileError { throw zen::FileError(_("Error writing to synchronization database:") + " \n" + "\"" + errorObjName_.c_str() + "\""); } diff --git a/shared/serialize.h b/shared/serialize.h index c8a94ad1..6930bcb9 100644 --- a/shared/serialize.h +++ b/shared/serialize.h @@ -30,13 +30,13 @@ template <class S> void writeString(wxOutputStream& stream, const S& str); class FileInputStream : public wxInputStream { public: - FileInputStream(const Zstring& filename) : //throw (FileError) + FileInputStream(const Zstring& filename) : //throw FileError fileObj(filename) {} private: virtual size_t OnSysRead(void* buffer, size_t bufsize) { - return fileObj.read(buffer, bufsize); //throw (FileError) + return fileObj.read(buffer, bufsize); //throw FileError } zen::FileInput fileObj; @@ -46,13 +46,13 @@ private: class FileOutputStream : public wxOutputStream { public: - FileOutputStream(const Zstring& filename) : //throw (FileError) + FileOutputStream(const Zstring& filename) : //throw FileError fileObj(filename, zen::FileOutput::ACC_OVERWRITE) {} private: virtual size_t OnSysWrite(const void* buffer, size_t bufsize) { - fileObj.write(buffer, bufsize); //throw (FileError) + fileObj.write(buffer, bufsize); //throw FileError return bufsize; } @@ -61,19 +61,19 @@ private: -class ReadInputStream //throw (FileError) +class ReadInputStream //throw FileError { protected: ReadInputStream(wxInputStream& stream, const wxString& errorObjName) : stream_(stream), errorObjName_(errorObjName) {} template <class T> - T readNumberC() const; //throw (FileError), checked read operation + T readNumberC() const; //throw FileError, checked read operation template <class S> - S readStringC() const; //throw (FileError), checked read operation + S readStringC() const; //throw FileError, checked read operation typedef std::shared_ptr<std::vector<char> > CharArray; //there's no guarantee std::string has a ref-counted implementation... so use this "thing" - CharArray readArrayC() const; //throw (FileError) + CharArray readArrayC() const; //throw FileError void check() const; @@ -84,23 +84,23 @@ protected: private: wxInputStream& stream_; - void throwReadError() const; //throw (FileError) + void throwReadError() const; //throw FileError const wxString& errorObjName_; //used for error text only }; -class WriteOutputStream //throw (FileError) +class WriteOutputStream //throw FileError { protected: WriteOutputStream(const wxString& errorObjName, wxOutputStream& stream) : stream_(stream), errorObjName_(errorObjName) {} template <class T> - void writeNumberC(T number) const; //throw (FileError), checked write operation + void writeNumberC(T number) const; //throw FileError, checked write operation template <class S> - void writeStringC(const S& str) const; //throw (FileError), checked write operation + void writeStringC(const S& str) const; //throw FileError, checked write operation - void writeArrayC(const std::vector<char>& buffer) const; //throw (FileError) + void writeArrayC(const std::vector<char>& buffer) const; //throw FileError void check() const; @@ -111,7 +111,7 @@ protected: private: wxOutputStream& stream_; - void throwWriteError() const; //throw (FileError) + void throwWriteError() const; //throw FileError const wxString& errorObjName_; //used for error text only! }; @@ -168,7 +168,7 @@ S readString(wxInputStream& stream) { typedef typename S::value_type CharType; - const boost::uint32_t strLength = readPOD<boost::uint32_t>(stream); + const auto strLength = readPOD<boost::uint32_t>(stream); if (strLength <= 1000) { CharType buffer[1000]; @@ -177,7 +177,7 @@ S readString(wxInputStream& stream) } else { - std::vector<CharType> buffer(strLength); //throw (std::bad_alloc) + std::vector<CharType> buffer(strLength); //throw std::bad_alloc stream.Read(&buffer[0], sizeof(CharType) * strLength); return S(&buffer[0], strLength); } diff --git a/shared/shadow.cpp b/shared/shadow.cpp index f000a69b..7f25076e 100644 --- a/shared/shadow.cpp +++ b/shared/shadow.cpp @@ -20,31 +20,12 @@ using namespace shadow; namespace { -bool newerThanXP() -{ - OSVERSIONINFO osvi = {}; - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - if (::GetVersionEx(&osvi)) - return osvi.dwMajorVersion > 5 || - (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion > 1) ; - //XP has majorVersion == 5, minorVersion == 1 - //Server 2003 has majorVersion == 5, minorVersion == 2 - //version overview: http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx - return false; -} - - bool runningWOW64() //test if process is running under WOW64 (reference http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx) { //dynamically load windows API function - typedef BOOL (WINAPI *IsWow64ProcessFun)( - HANDLE hProcess, - PBOOL Wow64Process); - - const IsWow64ProcessFun isWow64Process = - util::getDllFun<IsWow64ProcessFun>(L"kernel32.dll", "IsWow64Process"); + typedef BOOL (WINAPI *IsWow64ProcessFun)(HANDLE hProcess, PBOOL Wow64Process); + const util::DllFun<IsWow64ProcessFun> isWow64Process(L"kernel32.dll", "IsWow64Process"); if (isWow64Process) { BOOL isWow64 = FALSE; @@ -54,27 +35,6 @@ bool runningWOW64() //test if process is running under WOW64 (reference http://m return false; } - - -inline -std::wstring getShadowDllName() -{ - /* - distinguish a bunch of VSS builds: we use XP and Server 2003 implementations... - VSS version and compatibility overview: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx - */ - - assert_static(util::is32BitBuild || util::is64BitBuild); - - return newerThanXP() ? - (util::is64BitBuild ? - L"Shadow_Server2003_x64.dll" : - L"Shadow_Server2003_Win32.dll") : - - (util::is64BitBuild ? - L"Shadow_XP_x64.dll" : - L"Shadow_XP_Win32.dll"); -} } //############################################################################################################# @@ -84,21 +44,19 @@ class ShadowCopy::ShadowVolume { public: ShadowVolume(const Zstring& volumeNameFormatted) : //throw(FileError) + createShadowCopy(getDllName(), createShadowCopyFctName), + releaseShadowCopy(getDllName(), releaseShadowCopyFctName), backupHandle(0) { - createShadowCopy = util::getDllFun<CreateShadowCopyFct>(getShadowDllName(), createShadowCopyFctName); - releaseShadowCopy = util::getDllFun<ReleaseShadowCopyFct>(getShadowDllName(), releaseShadowCopyFctName); - //check if shadow copy dll was loaded correctly - if (createShadowCopy == NULL || - releaseShadowCopy == NULL) - throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" + - _("Could not load a required DLL:") + " \"" + getShadowDllName() + "\""); + if (!createShadowCopy || !releaseShadowCopy) + throw FileError(_("Error accessing Volume Shadow Copy Service!") + "\n" + + _("Could not load a required DLL:") + " \"" + getDllName() + "\""); //VSS does not support running under WOW64 except for Windows XP and Windows Server 2003 //(Reference: http://msdn.microsoft.com/en-us/library/aa384627(VS.85).aspx) if (runningWOW64()) - throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" + + throw FileError(_("Error accessing Volume Shadow Copy Service!") + "\n" + _("Making shadow copies on WOW64 is not supported. Please use FreeFileSync 64-bit version.")); //--------------------------------------------------------------------------------------------------------- @@ -106,14 +64,13 @@ public: wchar_t shadowVolName[1000]; wchar_t errorMessage[1000]; - if (!createShadowCopy( - volumeNameFormatted.c_str(), - shadowVolName, - 1000, - &backupHandle, - errorMessage, - 1000)) - throw FileError(_("Error starting Volume Shadow Copy Service!") + "\n" + + if (!createShadowCopy(volumeNameFormatted.c_str(), + shadowVolName, + 1000, + &backupHandle, + errorMessage, + 1000)) + throw FileError(_("Error accessing Volume Shadow Copy Service!") + "\n" + "(" + errorMessage + " Volume: \"" + volumeNameFormatted + "\")"); shadowVol = Zstring(shadowVolName) + FILE_NAME_SEPARATOR; //shadowVolName NEVER has a trailing backslash @@ -133,8 +90,8 @@ private: ShadowVolume(const ShadowVolume&); ShadowVolume& operator=(const ShadowVolume&); - shadow::CreateShadowCopyFct createShadowCopy; - shadow::ReleaseShadowCopyFct releaseShadowCopy; + const util::DllFun<CreateShadowCopyFct> createShadowCopy; + const util::DllFun<ReleaseShadowCopyFct> releaseShadowCopy; Zstring shadowVol; diff --git a/shared/shell_execute.h b/shared/shell_execute.h index 64797eff..a127ee06 100644 --- a/shared/shell_execute.h +++ b/shared/shell_execute.h @@ -69,7 +69,7 @@ void shellExecute(const wxString& command, ExecutionType type = EXEC_TYPE_ASYNC) if (!::ShellExecuteEx(&execInfo)) //__inout LPSHELLEXECUTEINFO lpExecInfo { - wxString errorMsg = _("Invalid commandline: %x"); + wxString errorMsg = _("Invalid command line: %x"); wxString cmdFmt = wxString(L"\nFile: ") + filename + L"\nArg: " + arguments; errorMsg.Replace(L"%x", cmdFmt); @@ -92,7 +92,7 @@ void shellExecute(const wxString& command, ExecutionType type = EXEC_TYPE_ASYNC) int rv = ::system(utf8CvrtTo<std::string>(command).c_str()); //do NOT use std::system as its documentation says nothing about "WEXITSTATUS(rv)", ect... if (rv == -1 || WEXITSTATUS(rv) == 127) //http://linux.die.net/man/3/system "In case /bin/sh could not be executed, the exit status will be that of a command that does exit(127)" { - wxString errorMsg = _("Invalid commandline: %x"); + wxString errorMsg = _("Invalid command line: %x"); replace(errorMsg, L"%x", L"\n" + command); wxMessageBox(errorMsg); return; @@ -100,7 +100,7 @@ void shellExecute(const wxString& command, ExecutionType type = EXEC_TYPE_ASYNC) } else { - // ! unfortunately it seems there is no way on Linux to get a failure notification for calling an invalid commandline asynchronously ! + // ! unfortunately it seems there is no way on Linux to get a failure notification for calling an invalid command line asynchronously ! //by default wxExecute uses a zero sized dummy window as a hack to keep focus which leaves a useless empty icon in ALT-TAB list //=> use wxEXEC_NODISABLE and roll our own window disabler! (see comment in app.cpp: void *wxGUIAppTraits::BeforeChildWaitLoop()) diff --git a/shared/stl_tools.h b/shared/stl_tools.h new file mode 100644 index 00000000..6cfe35f8 --- /dev/null +++ b/shared/stl_tools.h @@ -0,0 +1,49 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** + +#ifndef STL_TOOLS_HEADER_84567184321434 +#define STL_TOOLS_HEADER_84567184321434 + +//no need to drag in any STL includes :) + +namespace zen +{ +template <class V, class Predicate> inline +void vector_remove_if(V& vec, Predicate p) +{ + vec.erase(std::remove_if(vec.begin(), vec.end(), p), vec.end()); +} + + +template <class S, class Predicate> inline +void set_remove_if(S& set, Predicate p) +{ + for (auto iter = set.begin(); iter != set.end();) + if (p(*iter)) + set.erase(iter++); + else + ++iter; +} + + +template <class M, class Predicate> inline +void map_remove_if(M& map, Predicate p) { set_remove_if(map, p); } + + +// binary search returning an iterator +template <class ForwardIterator, class T, typename Compare> inline +ForwardIterator custom_binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp) +{ + first = std::lower_bound(first, last, value, comp); + if (first != last && !comp(value, *first)) + return first; + else + return last; +} +} + + +#endif //STL_TOOLS_HEADER_84567184321434
\ No newline at end of file diff --git a/shared/string_tools.h b/shared/string_tools.h index d2e2c597..8951d942 100644 --- a/shared/string_tools.h +++ b/shared/string_tools.h @@ -311,8 +311,7 @@ bool endsWith(const S& str, const T& postfix) } -// get all characters after the last occurence of ch -// (returns the whole string if ch not found) +//returns the whole string if ch not found template <class S, class T> inline S afterLast(const S& str, const T& ch) { @@ -329,8 +328,7 @@ S afterLast(const S& str, const T& ch) } -// get all characters before the last occurence of ch -// (returns empty string if ch not found) +//returns empty string if ch not found template <class S, class T> inline S beforeLast(const S& str, const T& ch) { @@ -515,7 +513,7 @@ private: { wchar_t buffer[50]; #ifdef __MINGW32__ - int charsWritten = ::swprintf(buffer, L"%f", static_cast<double>(number)); //MinGW does not comply to the C standard! + int charsWritten = ::swprintf(buffer, L"%f", static_cast<double>(number)); //MinGW does not comply to the C standard here #else int charsWritten = std::swprintf(buffer, 50, L"%f", static_cast<double>(number)); #endif @@ -662,12 +660,12 @@ inline S toString(const Num& number) //convert number to string the C++ way { using namespace implementation; - return CvrtNumberToString<S, Num, + return CvrtNumberToString < S, Num, Loki::TypeTraits<Num>::isSignedInt ? NUM_TYPE_SIGNED_INT : Loki::TypeTraits<Num>::isUnsignedInt ? NUM_TYPE_UNSIGNED_INT : Loki::TypeTraits<Num>::isFloat ? NUM_TYPE_FLOATING_POINT : NUM_TYPE_OTHER - >().convert(number); + > ().convert(number); } @@ -676,12 +674,12 @@ inline Num toNumber(const S& str) //convert string to number the C++ way { using namespace implementation; - return CvrtStringToNumber<S, Num, + return CvrtStringToNumber < S, Num, Loki::TypeTraits<Num>::isSignedInt ? NUM_TYPE_SIGNED_INT : Loki::TypeTraits<Num>::isUnsignedInt ? NUM_TYPE_UNSIGNED_INT : Loki::TypeTraits<Num>::isFloat ? NUM_TYPE_FLOATING_POINT : NUM_TYPE_OTHER - >().convert(str); + > ().convert(str); } } diff --git a/shared/string_utf8.h b/shared/string_utf8.h index 26f4c3f2..8c920752 100644 --- a/shared/string_utf8.h +++ b/shared/string_utf8.h @@ -134,21 +134,21 @@ OutputIterator codePointToUtf8(CodePoint cp, OutputIterator result) //http://en. *result++ = static_cast<Char8>(cp); else if (cp < 0x800) { - *result++ = static_cast<Char8>((cp >> 6 )| 0xc0); - *result++ = static_cast<Char8>((cp & 0x3f )| 0x80); + *result++ = static_cast<Char8>((cp >> 6 ) | 0xc0); + *result++ = static_cast<Char8>((cp & 0x3f ) | 0x80); } else if (cp < 0x10000) { - *result++ = static_cast<Char8>((cp >> 12 )| 0xe0); - *result++ = static_cast<Char8>(((cp >> 6) & 0x3f )| 0x80); - *result++ = static_cast<Char8>((cp & 0x3f )| 0x80); + *result++ = static_cast<Char8>((cp >> 12 ) | 0xe0); + *result++ = static_cast<Char8>(((cp >> 6) & 0x3f ) | 0x80); + *result++ = static_cast<Char8>((cp & 0x3f ) | 0x80); } else { - *result++ = static_cast<Char8>((cp >> 18 )| 0xf0); - *result++ = static_cast<Char8>(((cp >> 12) & 0x3f )| 0x80); - *result++ = static_cast<Char8>(((cp >> 6) & 0x3f )| 0x80); - *result++ = static_cast<Char8>((cp & 0x3f )| 0x80); + *result++ = static_cast<Char8>((cp >> 18 ) | 0xf0); + *result++ = static_cast<Char8>(((cp >> 12) & 0x3f ) | 0x80); + *result++ = static_cast<Char8>(((cp >> 6) & 0x3f ) | 0x80); + *result++ = static_cast<Char8>((cp & 0x3f ) | 0x80); } return result; } @@ -179,7 +179,7 @@ Function utf8ToCodePoint(CharIterator first, CharIterator last, Function f) //f for ( ; first != last; ++first) { - auto getChar = [&](Char8& ch ) -> bool + auto getChar = [&](Char8 & ch) -> bool { if (++first == last) { diff --git a/shared/symlink_target.h b/shared/symlink_target.h index ef7b2275..9ab0ea3f 100644 --- a/shared/symlink_target.h +++ b/shared/symlink_target.h @@ -24,6 +24,8 @@ #ifdef _MSC_VER //I don't have Windows Driver Kit at hands right now, so unfortunately we need to redefine this structures and cross fingers... + +//from ntifs.h typedef struct _REPARSE_DATA_BUFFER { ULONG ReparseTag; @@ -60,7 +62,7 @@ typedef struct _REPARSE_DATA_BUFFER namespace { //retrieve raw target data of symlink or junction -Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) +Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw FileError { using namespace zen; #ifdef FFS_WIN @@ -69,25 +71,24 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) try //reading certain symlinks requires admin rights! This shall not cause an error in user mode! { //allow access to certain symbolic links/junctions - Privileges::getInstance().ensureActive(SE_BACKUP_NAME); //throw (FileError) + Privileges::getInstance().ensureActive(SE_BACKUP_NAME); //throw FileError } catch (...) {} const HANDLE hLink = ::CreateFile(applyLongPathPrefix(linkPath).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL); if (hLink == INVALID_HANDLE_VALUE) throw FileError(_("Error resolving symbolic link:") + "\n\"" + linkPath + "\"" + "\n\n" + getLastErrorFormatted()); - - Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hLink); - (void)dummy; //silence warning "unused variable" + LOKI_ON_BLOCK_EXIT2(::CloseHandle(hLink)); //respect alignment issues... - std::vector<char> buffer(REPARSE_DATA_BUFFER_HEADER_SIZE + MAXIMUM_REPARSE_DATA_BUFFER_SIZE); + const DWORD bufferSize = REPARSE_DATA_BUFFER_HEADER_SIZE + MAXIMUM_REPARSE_DATA_BUFFER_SIZE; + std::vector<char> buffer(bufferSize); DWORD bytesReturned; //dummy value required by FSCTL_GET_REPARSE_POINT! if (!::DeviceIoControl(hLink, //__in HANDLE hDevice, @@ -95,7 +96,7 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) NULL, //__in_opt LPVOID lpInBuffer, 0, //__in DWORD nInBufferSize, &buffer[0], //__out_opt LPVOID lpOutBuffer, - static_cast<DWORD>(buffer.size()), //__in DWORD nOutBufferSize, + bufferSize, //__in DWORD nOutBufferSize, &bytesReturned, //__out_opt LPDWORD lpBytesReturned, NULL)) //__inout_opt LPOVERLAPPED lpOverlapped throw FileError(_("Error resolving symbolic link:") + "\n\"" + linkPath + "\"" + "\n\n" + getLastErrorFormatted()); @@ -124,9 +125,9 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) #elif defined FFS_LINUX const int BUFFER_SIZE = 10000; - char buffer[BUFFER_SIZE]; + std::vector<char> buffer(BUFFER_SIZE); - const int bytesWritten = ::readlink(linkPath.c_str(), buffer, BUFFER_SIZE); + const int bytesWritten = ::readlink(linkPath.c_str(), &buffer[0], BUFFER_SIZE); if (bytesWritten < 0 || bytesWritten >= BUFFER_SIZE) { std::wstring errorMessage = _("Error resolving symbolic link:") + "\n\"" + linkPath + "\""; @@ -136,7 +137,7 @@ Zstring getSymlinkRawTargetString(const Zstring& linkPath) //throw (FileError) } buffer[bytesWritten] = 0; //set null-terminating char - return buffer; + return Zstring(&buffer[0], bytesWritten); #endif } } diff --git a/shared/taskbar.cpp b/shared/taskbar.cpp index 005df705..9edc7288 100644 --- a/shared/taskbar.cpp +++ b/shared/taskbar.cpp @@ -39,16 +39,6 @@ bool windows7TaskbarAvailable() //version overview: http://msdn.microsoft.com/en-us/library/ms724834(VS.85).aspx return false; } - - -std::wstring getTaskBarDllName() -{ - assert_static(util::is32BitBuild || util::is64BitBuild); - - return util::is64BitBuild ? - L"Taskbar7_x64.dll" : - L"Taskbar7_Win32.dll"; -} } //######################################################################################################## @@ -58,8 +48,8 @@ class Taskbar::Pimpl //throw (TaskbarNotAvailable) public: Pimpl(const wxTopLevelWindow& window) : assocWindow(window.GetHWND()), - setStatus_(util::getDllFun<SetStatusFct>( getTaskBarDllName(), setStatusFctName)), - setProgress_(util::getDllFun<SetProgressFct>(getTaskBarDllName(), setProgressFctName)) + setStatus_ (getDllName(), setStatusFctName), + setProgress_(getDllName(), setProgressFctName) { if (!assocWindow || !setProgress_ || !setStatus_) throw TaskbarNotAvailable(); @@ -95,15 +85,15 @@ public: setStatus_(assocWindow, tbSevenStatus); } - void setProgress(size_t current, size_t total) + void setProgress(double fraction) { - setProgress_(assocWindow, current, total); + setProgress_(assocWindow, fraction * 100000, 100000); } private: void* assocWindow; //HWND - const SetStatusFct setStatus_; - const SetProgressFct setProgress_; + const util::DllFun<SetStatusFct> setStatus_; + const util::DllFun<SetProgressFct> setProgress_; }; #elif defined HAVE_UBUNTU_UNITY //Ubuntu unity @@ -150,9 +140,9 @@ public: } } - void setProgress(size_t current, size_t total) + void setProgress(double fraction) { - unity_launcher_entry_set_progress(tbEntry, total == 0 ? 0 : double(current) / total); + unity_launcher_entry_set_progress(tbEntry, fraction); } private: @@ -177,4 +167,4 @@ Taskbar::Taskbar(const wxTopLevelWindow& window) : pimpl_(new Pimpl(window)) {} Taskbar::~Taskbar() {} //std::unique_ptr ... void Taskbar::setStatus(Status status) { pimpl_->setStatus(status); } -void Taskbar::setProgress(size_t current, size_t total) { pimpl_->setProgress(current, total); } +void Taskbar::setProgress(double fraction) { pimpl_->setProgress(fraction); } diff --git a/shared/taskbar.h b/shared/taskbar.h index 54e0a431..b78b4494 100644 --- a/shared/taskbar.h +++ b/shared/taskbar.h @@ -40,7 +40,7 @@ public: }; void setStatus(Status status); - void setProgress(size_t current, size_t total); + void setProgress(double fraction); //between [0, 1] private: class Pimpl; diff --git a/shared/util.cpp b/shared/util.cpp index d780d683..292d87c1 100644 --- a/shared/util.cpp +++ b/shared/util.cpp @@ -70,11 +70,10 @@ wxString zen::formatFilesizeToShortString(UInt64 size) } -wxString zen::formatPercentage(zen::Int64 dividend, zen::Int64 divisor) +wxString zen::formatPercentage(double fraction) { - const double ratio = divisor != 0 ? to<double>(dividend) * 100.0 / to<double>(divisor) : 0; wxString output = _("%x%"); - output.Replace(wxT("%x"), wxString::Format(wxT("%3.2f"), ratio), false); + output.Replace(wxT("%x"), wxString::Format(wxT("%3.2f"), fraction * 100.0), false); return output; } @@ -130,14 +129,7 @@ bool isVistaOrLater() wxString zen::utcTimeToLocalString(zen::Int64 utcTime) { #ifdef FFS_WIN - //convert ansi C time to FILETIME - zen::UInt64 fileTimeLong = to<zen::UInt64>(utcTime + //may be < 0 - zen::Int64(3054539008UL, 2)); //timeshift between ansi C time and FILETIME in seconds == 11644473600s - fileTimeLong *= 10000000U; - - FILETIME lastWriteTimeUtc = {}; - lastWriteTimeUtc.dwLowDateTime = fileTimeLong.getLo(); - lastWriteTimeUtc.dwHighDateTime = fileTimeLong.getHi(); + FILETIME lastWriteTimeUtc = tofiletime(utcTime); //convert ansi C time to FILETIME SYSTEMTIME systemTimeLocal = {}; diff --git a/shared/util.h b/shared/util.h index 0e08280e..e45262ab 100644 --- a/shared/util.h +++ b/shared/util.h @@ -17,7 +17,7 @@ namespace zen wxString extractJobName(const wxString& configFilename); wxString formatFilesizeToShortString(UInt64 filesize); -wxString formatPercentage(Int64 dividend, Int64 divisor); +wxString formatPercentage(double fraction); //between [0, 1] template <class NumberType> wxString toStringSep(NumberType number); //convert number to wxString including thousands separator diff --git a/shared/warn_static.h b/shared/warn_static.h index bb4f4a6f..66513871 100644 --- a/shared/warn_static.h +++ b/shared/warn_static.h @@ -20,15 +20,15 @@ Usage: #define MAKE_STRING(NUM) MAKE_STRING_SUB(NUM) #define warn_static(TXT) \ -__pragma(message (__FILE__ "(" MAKE_STRING(__LINE__) "): Warning: " ## TXT)) + __pragma(message (__FILE__ "(" MAKE_STRING(__LINE__) "): Warning: " ## TXT)) #elif defined __GNUC__ #define LOKI_CONCAT( X, Y ) LOKI_CONCAT_SUB( X, Y ) #define LOKI_CONCAT_SUB( X, Y ) X##Y #define warn_static(TXT) \ -typedef int STATIC_WARNING __attribute__ ((deprecated)); \ -enum { LOKI_CONCAT(warn_static_dummy_value, __LINE__) = sizeof(STATIC_WARNING) }; + typedef int STATIC_WARNING __attribute__ ((deprecated)); \ + enum { LOKI_CONCAT(warn_static_dummy_value, __LINE__) = sizeof(STATIC_WARNING) }; #endif diff --git a/shared/wx_choice_enum.h b/shared/wx_choice_enum.h index e8fbeead..b8833725 100644 --- a/shared/wx_choice_enum.h +++ b/shared/wx_choice_enum.h @@ -20,7 +20,7 @@ Member variable: Constructor code: enumDescrMap. - add(ON_ERROR_POPUP , _("Show popup") , _("Show popup on errors or warnings")). + add(ON_ERROR_POPUP , _("Show pop-up") , _("Show pop-up on errors or warnings")). add(ON_ERROR_IGNORE, _("Ignore errors") , _("Hide all error and warning messages")). add(ON_ERROR_EXIT , _("Exit instantly"), _("Abort synchronization immediately")); diff --git a/shared/wx_timespan.h b/shared/wx_timespan.h index 2e566927..d11b328e 100644 --- a/shared/wx_timespan.h +++ b/shared/wx_timespan.h @@ -43,10 +43,10 @@ public: wxBoxSizer* bSizer27 = new wxBoxSizer( wxHORIZONTAL ); m_textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE ); - bSizer27->Add(m_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + bSizer27->Add(m_textCtrl, 1, wxALIGN_CENTER_VERTICAL | wxEXPAND, 5 ); - m_spinBtn = new wxSpinButton(this, wxID_ANY, wxDefaultPosition, wxSize( 20,-1 ), wxSP_ARROW_KEYS ); - bSizer27->Add(m_spinBtn, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_spinBtn = new wxSpinButton(this, wxID_ANY, wxDefaultPosition, wxSize( 20, -1 ), wxSP_ARROW_KEYS ); + bSizer27->Add(m_spinBtn, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND, 5 ); SetSizer(bSizer27); Layout(); diff --git a/shared/xml_base.cpp b/shared/xml_base.cpp index c7c92401..e0b497f9 100644 --- a/shared/xml_base.cpp +++ b/shared/xml_base.cpp @@ -16,28 +16,31 @@ using namespace zen; //loadXmlDocument vs loadStream: //1. better error reporting //2. quick exit if (potentially large) input file is not an XML -void xmlAccess::loadXmlDocument(const wxString& filename, XmlDoc& doc) //throw FfsXmlError() +void xmlAccess::loadXmlDocument(const wxString& filename, XmlDoc& doc) //throw FfsXmlError { std::string stream; try { { //quick test whether input is an XML: avoid loading large binary files up front! - //doesn't correctly handle BOM! (but no issue yet...) const std::string xmlBegin = "<?xml version="; - std::vector<char> buffer(xmlBegin.size()); + std::vector<char> buffer(xmlBegin.size() + sizeof(zen::BYTE_ORDER_MARK_UTF8)); - FileInput inputFile(toZ(filename)); //throw (FileError); - const size_t bytesRead = inputFile.read(&buffer[0], buffer.size()); //throw (FileError) - if (bytesRead < xmlBegin.size() || !std::equal(buffer.begin(), buffer.end(), xmlBegin.begin())) + FileInput inputFile(toZ(filename)); //throw FileError; + const size_t bytesRead = inputFile.read(&buffer[0], buffer.size()); //throw FileError + + const std::string fileBegin(&buffer[0], bytesRead); + + if (!startsWith(fileBegin, xmlBegin) && + !startsWith(fileBegin, zen::BYTE_ORDER_MARK_UTF8 + xmlBegin)) //respect BOM! throw FfsXmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); } - const zen::UInt64 fs = zen::getFilesize(toZ(filename)); //throw (FileError) + const zen::UInt64 fs = zen::getFilesize(toZ(filename)); //throw FileError stream.resize(to<size_t>(fs)); - FileInput inputFile(toZ(filename)); //throw (FileError); - const size_t bytesRead = inputFile.read(&stream[0], stream.size()); //throw (FileError) + FileInput inputFile(toZ(filename)); //throw FileError + const size_t bytesRead = inputFile.read(&stream[0], stream.size()); //throw FileError if (bytesRead < to<size_t>(fs)) { wxString errorMessage = wxString(_("Error reading file:")) + wxT("\n\"") + filename + wxT("\""); @@ -85,14 +88,14 @@ void xmlAccess::saveXmlDocument(const zen::XmlDoc& doc, const wxString& filename if (zen::loadStream(filename) == stream) //throw XmlFileError saveNecessary = false; } - catch(const zen::XmlFileError&) {} + catch (const zen::XmlFileError&) {} } catch (FileError&) {} if (saveNecessary) try { - FileOutput outputFile(toZ(filename), FileOutput::ACC_OVERWRITE); //throw (FileError) + FileOutput outputFile(toZ(filename), FileOutput::ACC_OVERWRITE); //throw FileError outputFile.write(stream.c_str(), stream.length()); // } catch (const FileError& error) //more detailed error messages than with wxWidgets diff --git a/shared/zbase.h b/shared/zbase.h index 55bc0d96..5f404887 100644 --- a/shared/zbase.h +++ b/shared/zbase.h @@ -54,8 +54,8 @@ template <typename T, //Character Type void setLength(T* ptr, size_t newLength) */ -template <typename T, //Character Type - class AP> //Allocator Policy +template < typename T, //Character Type + class AP > //Allocator Policy class StorageDeepCopy : public AP { protected: @@ -107,8 +107,8 @@ private: }; -template <typename T, //Character Type - class AP> //Allocator Policy +template < typename T, //Character Type + class AP > //Allocator Policy class StorageRefCountThreadSafe : public AP { protected: @@ -181,9 +181,9 @@ private: //perf note: interstingly StorageDeepCopy and StorageRefCountThreadSafe show same performance in FFS comparison -template <class T, //Character Type +template < class T, //Character Type template <class, class> class SP = StorageRefCountThreadSafe, //Storage Policy - class AP = AllocatorOptimalSpeed> //Allocator Policy + class AP = AllocatorOptimalSpeed > //Allocator Policy class Zbase : public SP<T, AP> { public: @@ -191,7 +191,7 @@ public: Zbase(const T* source); //implicit conversion from a C-string Zbase(const T* source, size_t length); Zbase(const Zbase& source); - Zbase(Zbase&& tmp); + Zbase(Zbase && tmp); explicit Zbase(T source); //dangerous if implicit: T buffer[]; Zbase name = buffer; ups... //allow explicit construction from different string type, prevent ambiguity via SFINAE template <class S> explicit Zbase(const S& other, typename S::value_type = 0); @@ -253,7 +253,7 @@ public: void push_back(T val); //STL access Zbase& operator=(const Zbase& source); - Zbase& operator=(Zbase&& tmp); + Zbase& operator=(Zbase && tmp); Zbase& operator=(const T* source); Zbase& operator=(T source); Zbase& operator+=(const Zbase& other); @@ -374,7 +374,7 @@ Zbase<T, SP, AP>::Zbase(const Zbase<T, SP, AP>& source) template <class T, template <class, class> class SP, class AP> inline -Zbase<T, SP, AP>::Zbase(Zbase<T, SP, AP>&& tmp) +Zbase<T, SP, AP>::Zbase(Zbase<T, SP, AP> && tmp) { rawStr = this->clone(tmp.rawStr); //for a ref-counting string there probably isn't a faster way, even with r-value references } @@ -828,7 +828,7 @@ Zbase<T, SP, AP>& Zbase<T, SP, AP>::operator=(const Zbase<T, SP, AP>& source) template <class T, template <class, class> class SP, class AP> inline -Zbase<T, SP, AP>& Zbase<T, SP, AP>::operator=(Zbase<T, SP, AP>&& tmp) +Zbase<T, SP, AP>& Zbase<T, SP, AP>::operator=(Zbase<T, SP, AP> && tmp) { swap(tmp); return *this; diff --git a/shared/zstring.cpp b/shared/zstring.cpp index e1df17ee..45762000 100644 --- a/shared/zstring.cpp +++ b/shared/zstring.cpp @@ -107,25 +107,25 @@ bool hasInvariantLocale() const LCID ZSTRING_INVARIANT_LOCALE = hasInvariantLocale() ? LOCALE_INVARIANT : MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); //see: http://msdn.microsoft.com/en-us/goglobal/bb688122.aspx + + +//try to call "CompareStringOrdinal" for low-level string comparison: unfortunately available not before Windows Vista! +//by a factor ~3 faster than old string comparison using "LCMapString" +typedef int (WINAPI* CompareStringOrdinalFunc)(LPCWSTR lpString1, + int cchCount1, + LPCWSTR lpString2, + int cchCount2, + BOOL bIgnoreCase); +util::DllFun<CompareStringOrdinalFunc> ordinalCompare; //caveat: function scope static initialization is not thread-safe in VS 2010! +boost::once_flag initCmpStrOrdOnce = BOOST_ONCE_INIT; } int z_impl::compareFilenamesWin(const wchar_t* a, const wchar_t* b, size_t sizeA, size_t sizeB) { - //try to call "CompareStringOrdinal" for low-level string comparison: unfortunately available not before Windows Vista! - //by a factor ~3 faster than old string comparison using "LCMapString" - typedef int (WINAPI *CompareStringOrdinalFunc)( - LPCWSTR lpString1, - int cchCount1, - LPCWSTR lpString2, - int cchCount2, - BOOL bIgnoreCase); - static CompareStringOrdinalFunc ordinalCompare = NULL; //caveat: function scope static initialization is not thread-safe in VS 2010! - static boost::once_flag once = BOOST_ONCE_INIT; - boost::call_once(once, []() { ordinalCompare = util::getDllFun<CompareStringOrdinalFunc>(L"kernel32.dll", "CompareStringOrdinal"); }); - - - if (ordinalCompare != NULL) //this additional test has no noticeable performance impact + boost::call_once(initCmpStrOrdOnce, []() { ordinalCompare = util::DllFun<CompareStringOrdinalFunc>(L"kernel32.dll", "CompareStringOrdinal"); }); + + if (ordinalCompare) //this additional test has no noticeable performance impact { const int rv = ordinalCompare(a, //pointer to first string static_cast<int>(sizeA), //size, in bytes or characters, of first string diff --git a/shared/zstring.h b/shared/zstring.h index 3b4837db..8c30007b 100644 --- a/shared/zstring.h +++ b/shared/zstring.h @@ -102,7 +102,7 @@ struct EqualFilename //case-insensitive on Windows, case-sensitive on Linux #ifdef FFS_WIN template <template <class, class> class SP, class AP> -void MakeUpper(Zbase<wchar_t, SP, AP>& str); +void makeUpper(Zbase<wchar_t, SP, AP>& str); #endif #ifdef FFS_WIN //Windows stores filenames in wide character format @@ -196,7 +196,7 @@ bool EqualFilename::operator()(const Zbase<T, SP, AP>& lhs, const Zbase<T, SP, A #ifdef FFS_WIN template <template <class, class> class SP, class AP> inline -void MakeUpper(Zbase<wchar_t, SP, AP>& str) +void makeUpper(Zbase<wchar_t, SP, AP>& str) { z_impl::makeUpperCaseWin(str.begin(), str.length()); } |