mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-20 06:17:15 +01:00
committed latest 1.3 snapshot
This commit is contained in:
parent
a8332eaaf3
commit
b7a945da93
@ -253,9 +253,18 @@
|
||||
<File
|
||||
RelativePath=".\src\ByteOrder.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Checksum.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Debugger.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAny.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyHolder.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Environment.cpp">
|
||||
</File>
|
||||
@ -557,12 +566,21 @@
|
||||
<File
|
||||
RelativePath=".\include\Poco\ByteOrder.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Checksum.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Config.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Debugger.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicAny.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicAnyHolder.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicFactory.h">
|
||||
</File>
|
||||
@ -694,6 +712,15 @@
|
||||
<File
|
||||
RelativePath=".\src\DeflatingStream.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream_POSIX.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream_WIN32.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\HexBinaryDecoder.cpp">
|
||||
</File>
|
||||
@ -752,6 +779,63 @@
|
||||
<File
|
||||
RelativePath=".\include\Poco\DeflatingStream.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\FileStream.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\FileStream_POSIX.h">
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\FileStream_WIN32.h">
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\HexBinaryDecoder.h">
|
||||
</File>
|
||||
@ -2794,6 +2878,90 @@
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory_DUMMY.cpp">
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory_POSIX.cpp">
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory_WIN32.cpp">
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -2861,6 +3029,18 @@
|
||||
<File
|
||||
RelativePath=".\include\Poco\Process_WIN32U.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory_DUMMY.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory_POSIX.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory_WIN32.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Version="8.00"
|
||||
Name="Foundation"
|
||||
ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
||||
RootNamespace="Foundation"
|
||||
@ -363,10 +363,22 @@
|
||||
RelativePath=".\src\ByteOrder.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Checksum.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Debugger.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAny.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyHolder.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Environment.cpp"
|
||||
>
|
||||
@ -767,6 +779,10 @@
|
||||
RelativePath=".\include\Poco\ByteOrder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Checksum.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\Config.h"
|
||||
>
|
||||
@ -775,6 +791,14 @@
|
||||
RelativePath=".\include\Poco\Debugger.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicAny.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicAnyHolder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\DynamicFactory.h"
|
||||
>
|
||||
@ -947,6 +971,82 @@
|
||||
RelativePath=".\src\DeflatingStream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream_POSIX.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream_WIN32.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\HexBinaryDecoder.cpp"
|
||||
>
|
||||
@ -1023,6 +1123,18 @@
|
||||
RelativePath=".\include\Poco\DeflatingStream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\FileStream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\FileStream_POSIX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\FileStream_WIN32.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\HexBinaryDecoder.h"
|
||||
>
|
||||
@ -3703,6 +3815,86 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory_DUMMY.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory_POSIX.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemory_WIN32.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="debug_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_shared|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="release_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="debug_static|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -3791,6 +3983,22 @@
|
||||
RelativePath=".\include\Poco\Process_WIN32U.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory_DUMMY.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory_POSIX.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Poco\SharedMemory_WIN32.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/Foundation/Makefile#35 $
|
||||
# $Id: //poco/Main/Foundation/Makefile#40 $
|
||||
#
|
||||
# Makefile for Poco Foundation
|
||||
#
|
||||
@ -9,7 +9,7 @@
|
||||
include $(POCO_BASE)/build/rules/global
|
||||
|
||||
objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder \
|
||||
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Configurable ConsoleChannel \
|
||||
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Configurable ConsoleChannel \
|
||||
CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
|
||||
Debugger DeflatingStream DigestEngine DigestStream DirectoryIterator \
|
||||
Environment Event EventArgs ErrorHandler Exception FPEnvironment File Glob \
|
||||
@ -29,7 +29,8 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
|
||||
ThreadPool ActiveDispatcher Timer Timespan Timestamp Timezone Token URI \
|
||||
FileStreamFactory URIStreamFactory URIStreamOpener UTF16Encoding Windows1252Encoding \
|
||||
UTF8Encoding UnicodeConverter UUID UUIDGenerator Void Format \
|
||||
Pipe PipeImpl PipeStream \
|
||||
Pipe PipeImpl PipeStream DynamicAny DynamicAnyHolder SharedMemory \
|
||||
FileStream \
|
||||
adler32 chartables compress crc32 \
|
||||
deflate get gzio infback inffast inflate inftrees maketables pcre study \
|
||||
trees zutil
|
||||
|
@ -13,6 +13,7 @@ BinaryWriter
|
||||
Bugcheck
|
||||
ByteOrder
|
||||
Channel
|
||||
Checksum
|
||||
Configurable
|
||||
ConsoleChannel
|
||||
CountingStream
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AbstractCache.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/AbstractCache.h#12 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/AbstractCache.h#13 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Cache
|
||||
@ -93,6 +93,14 @@ public:
|
||||
doAdd(key, val);
|
||||
}
|
||||
|
||||
void add(const TKey& key, SharedPtr<TValue > val)
|
||||
/// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail!
|
||||
/// If for the key already an entry exists, it will be overwritten.
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
doAdd(key, val);
|
||||
}
|
||||
|
||||
void remove(const TKey& key)
|
||||
/// Removes an entry from the cache. If the entry is not found,
|
||||
/// the remove is ignored.
|
||||
@ -198,6 +206,20 @@ protected:
|
||||
doReplace();
|
||||
}
|
||||
|
||||
void doAdd(const TKey& key, SharedPtr<TValue>& val)
|
||||
/// Adds the key value pair to the cache.
|
||||
/// If for the key already an entry exists, it will be overwritten.
|
||||
{
|
||||
Iterator it = _data.find(key);
|
||||
doRemove(it);
|
||||
|
||||
KeyValueArgs<TKey, TValue> args(key, *val);
|
||||
Add.notify(this, args);
|
||||
_data.insert(std::make_pair(key, val));
|
||||
|
||||
doReplace();
|
||||
}
|
||||
|
||||
void doRemove(Iterator it)
|
||||
/// Removes an entry from the cache. If the entry is not found
|
||||
/// the remove is ignored.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Any.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Any.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Any.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -60,7 +60,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
template <typename ValueType>
|
||||
Any(const ValueType& value):
|
||||
_content(new Holder<ValueType>(value))
|
||||
/// Creates an any which stores the init parameter inside.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ArchiveStrategy.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ArchiveStrategy.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ArchiveStrategy.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -96,7 +96,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<class DT>
|
||||
template <class DT>
|
||||
class ArchiveByTimestampStrategy: public ArchiveStrategy
|
||||
/// A timestamp (YYYYMMDDhhmmss) is appended to archived
|
||||
/// log files.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Base64Encoder.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Base64Encoder.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Base64Encoder.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -56,9 +56,20 @@ class Foundation_API Base64EncoderBuf: public UnbufferedStreamBuf
|
||||
public:
|
||||
Base64EncoderBuf(std::ostream& ostr);
|
||||
~Base64EncoderBuf();
|
||||
|
||||
int close();
|
||||
/// Closes the stream buffer.
|
||||
|
||||
void setLineLength(int lineLength);
|
||||
/// Specify the line length.
|
||||
///
|
||||
/// After the given number of characters have been written,
|
||||
/// a newline character will be written.
|
||||
///
|
||||
/// Specify 0 for an unlimited line length.
|
||||
|
||||
int getLineLength() const;
|
||||
/// Returns the currently set line length.
|
||||
|
||||
private:
|
||||
int writeToDevice(char c);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferedBidirectionalStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -51,7 +51,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template<typename ch, typename tr, typename ba = BufferAllocator<ch> >
|
||||
template <typename ch, typename tr, typename ba = BufferAllocator<ch> >
|
||||
class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf<ch, tr>
|
||||
/// This is an implementation of a buffered bidirectional
|
||||
/// streambuf that greatly simplifies the implementation of
|
||||
@ -82,8 +82,7 @@ public:
|
||||
_pWriteBuffer(Allocator::allocate(_bufsize)),
|
||||
_mode(mode)
|
||||
{
|
||||
this->setg(_pReadBuffer + 4, _pReadBuffer + 4, _pReadBuffer + 4);
|
||||
this->setp(_pWriteBuffer, _pWriteBuffer + (_bufsize - 1));
|
||||
resetBuffers();
|
||||
}
|
||||
|
||||
~BasicBufferedBidirectionalStreamBuf()
|
||||
@ -91,7 +90,7 @@ public:
|
||||
Allocator::deallocate(_pReadBuffer, _bufsize);
|
||||
Allocator::deallocate(_pWriteBuffer, _bufsize);
|
||||
}
|
||||
|
||||
|
||||
virtual int_type overflow(int_type c)
|
||||
{
|
||||
if (!(_mode & IOS::out)) return char_traits::eof();
|
||||
@ -101,7 +100,7 @@ public:
|
||||
*this->pptr() = char_traits::to_char_type(c);
|
||||
this->pbump(1);
|
||||
}
|
||||
if (flush_buffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
|
||||
return c;
|
||||
}
|
||||
@ -131,11 +130,28 @@ public:
|
||||
{
|
||||
if (this->pptr() && this->pptr() > this->pbase())
|
||||
{
|
||||
if (flush_buffer() == -1) return -1;
|
||||
if (flushBuffer() == -1) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
void setMode(openmode mode)
|
||||
{
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
openmode getMode() const
|
||||
{
|
||||
return _mode;
|
||||
}
|
||||
|
||||
void resetBuffers()
|
||||
{
|
||||
this->setg(_pReadBuffer + 4, _pReadBuffer + 4, _pReadBuffer + 4);
|
||||
this->setp(_pWriteBuffer, _pWriteBuffer + (_bufsize - 1));
|
||||
}
|
||||
|
||||
private:
|
||||
virtual int readFromDevice(char_type* buffer, std::streamsize length)
|
||||
{
|
||||
@ -147,7 +163,7 @@ private:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int flush_buffer()
|
||||
int flushBuffer()
|
||||
{
|
||||
int n = int(this->pptr() - this->pbase());
|
||||
if (writeToDevice(this->pbase(), n) == n)
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// BufferedStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedStreamBuf.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/BufferedStreamBuf.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -99,7 +99,7 @@ public:
|
||||
*this->pptr() = char_traits::to_char_type(c);
|
||||
this->pbump(1);
|
||||
}
|
||||
if (flush_buffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||
|
||||
return c;
|
||||
}
|
||||
@ -129,11 +129,22 @@ public:
|
||||
{
|
||||
if (this->pptr() && this->pptr() > this->pbase())
|
||||
{
|
||||
if (flush_buffer() == -1) return -1;
|
||||
if (flushBuffer() == -1) return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
void setMode(openmode mode)
|
||||
{
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
openmode getMode() const
|
||||
{
|
||||
return _mode;
|
||||
}
|
||||
|
||||
private:
|
||||
virtual int readFromDevice(char_type* buffer, std::streamsize length)
|
||||
{
|
||||
@ -145,7 +156,7 @@ private:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int flush_buffer()
|
||||
int flushBuffer()
|
||||
{
|
||||
int n = int(this->pptr() - this->pbase());
|
||||
if (writeToDevice(this->pbase(), n) == n)
|
||||
|
130
Foundation/include/Poco/Checksum.h
Normal file
130
Foundation/include/Poco/Checksum.h
Normal file
@ -0,0 +1,130 @@
|
||||
//
|
||||
// Checksum.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Checksum.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: Checksum
|
||||
//
|
||||
// Definition of the Checksum class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Checksum_INCLUDED
|
||||
#define Foundation_Checksum_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API Checksum
|
||||
/// This class calculates CRC-32 or Adler-32 checksums
|
||||
/// for arbitrary data.
|
||||
///
|
||||
/// A cyclic redundancy check (CRC) is a type of hash function, which is used to produce a
|
||||
/// small, fixed-size checksum of a larger block of data, such as a packet of network
|
||||
/// traffic or a computer file. CRC-32 is one of the most commonly used CRC algorithms.
|
||||
///
|
||||
/// Adler-32 is a checksum algorithm which was invented by Mark Adler.
|
||||
/// It is almost as reliable as a 32-bit cyclic redundancy check for protecting against
|
||||
/// accidental modification of data, such as distortions occurring during a transmission,
|
||||
/// but is significantly faster to calculate in software.
|
||||
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
TYPE_ADLER32 = 0,
|
||||
TYPE_CRC32
|
||||
};
|
||||
|
||||
Checksum();
|
||||
/// Creates a CRC-32 checksum initialized to 0.
|
||||
|
||||
Checksum(Type t);
|
||||
/// Creates the Checksum, using the given type.
|
||||
|
||||
~Checksum();
|
||||
/// Destroys the Checksum.
|
||||
|
||||
void update(const char* data, unsigned length);
|
||||
/// Updates the checksum with the given data.
|
||||
|
||||
void update(const std::string& data);
|
||||
/// Updates the checksum with the given data.
|
||||
|
||||
void update(char data);
|
||||
/// Updates the checksum with the given data.
|
||||
|
||||
Poco::UInt32 checksum() const;
|
||||
/// Returns the calculated checksum.
|
||||
|
||||
Type type() const;
|
||||
/// Which type of checksum are we calulcating
|
||||
|
||||
private:
|
||||
Type _type;
|
||||
Poco::UInt32 _value;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void Checksum::update(const std::string& data)
|
||||
{
|
||||
update(data.c_str(), static_cast<unsigned int>(data.size()));
|
||||
}
|
||||
|
||||
|
||||
inline void Checksum::update(char c)
|
||||
{
|
||||
update(&c, 1);
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt32 Checksum::checksum() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
inline Checksum::Type Checksum::type() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Checksum_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Config.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Config.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Config.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -41,7 +41,7 @@
|
||||
|
||||
|
||||
// Define to enable Windows Unicode (UTF-8) support.
|
||||
// #define POCO_WIN32_UTF8
|
||||
#define POCO_WIN32_UTF8
|
||||
|
||||
|
||||
// Define to disable FPEnvironment support
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTime.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DateTime.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DateTime.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -238,6 +238,12 @@ public:
|
||||
DateTime& operator += (const Timespan& span);
|
||||
DateTime& operator -= (const Timespan& span);
|
||||
|
||||
void makeUTC(int tzd);
|
||||
/// Converts a local time into UTC, by applying the given time zone differential.
|
||||
|
||||
void makeLocal(int tzd);
|
||||
/// Converts a UTC time into a local time, by applying the given time zone differential.
|
||||
|
||||
static bool isLeapYear(int year);
|
||||
/// Returns true if the given year is a leap year;
|
||||
/// false otherwise.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeParser.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DateTimeParser.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DateTimeParser.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -53,6 +53,11 @@ class Foundation_API DateTimeParser
|
||||
/// parse a meaningful result, even from malformed input
|
||||
/// strings.
|
||||
///
|
||||
/// The returned DateTime will always contain a time in the same
|
||||
/// timezone as the time in the string. Call DateTime::makeUTC()
|
||||
/// with the timeZoneDifferential returned by parse() to convert
|
||||
/// the DateTime to UTC.
|
||||
///
|
||||
/// Note: When parsing a time in 12-hour (AM/PM) format, the hour
|
||||
/// (%h) must be parsed before the AM/PM designator (%a, %A),
|
||||
/// otherwise the AM/PM designator will be ignored.
|
||||
|
130
Foundation/include/Poco/DynamicAny.h
Normal file
130
Foundation/include/Poco/DynamicAny.h
Normal file
@ -0,0 +1,130 @@
|
||||
//
|
||||
// DynamicAny.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#2 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Core
|
||||
// Module: DynamicAny
|
||||
//
|
||||
// Definition of the DynamicAny class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_DynamicAny_INCLUDED
|
||||
#define Poco_DynamicAny_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Poco.h"
|
||||
#include "Poco/DynamicAnyHolder.h"
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API DynamicAny
|
||||
/// A DynamicAny allows to store data of different types and to convert between these types transparently.
|
||||
/// It's the reponsibility of the programmer to ensure that conversions are meaningful.
|
||||
/// For example: it is possible to convert between string and character. An empty string gets converted to
|
||||
/// the char '\0', a non-empty string gets truncated to the very first character. Numeric values are truncated,
|
||||
/// no overflow/underflow errors are checked. A string value "false" can be converted to a boolean value false,
|
||||
/// any other string not "false" (not case sensitive) or "0" to true (e.g: "hi" -> true).
|
||||
///
|
||||
/// A DynamicAny can be created from a value of any type for which a
|
||||
/// specialization of DynamicAnyHolderImpl is available.
|
||||
{
|
||||
public:
|
||||
DynamicAny();
|
||||
/// Creates a DynamicAny holding an int with value 0.
|
||||
|
||||
template <typename T>
|
||||
DynamicAny(const T &val):
|
||||
_pHolder(new DynamicAnyHolderImpl<T>(val))
|
||||
/// Creates the DynamicAny from the given value.
|
||||
{
|
||||
}
|
||||
|
||||
DynamicAny(const char* pVal);
|
||||
// Convenience constructor for const char* which gets mapped to a std::string internally, i.e. pVal is deep-copied.
|
||||
|
||||
DynamicAny(const DynamicAny& other);
|
||||
/// Copy constructor.
|
||||
|
||||
~DynamicAny();
|
||||
/// Destroys the DynamicAny.
|
||||
|
||||
void swap(DynamicAny& other);
|
||||
/// Swaps the content of the this DynamicAny with the other DynamicAny.
|
||||
|
||||
template <typename T>
|
||||
void convert(T& val) const
|
||||
/// Invoke this method to perform conversion.
|
||||
///
|
||||
/// Example usage:
|
||||
/// DynamicAny any("42");
|
||||
/// int i;
|
||||
/// any.convert(i);
|
||||
{
|
||||
_pHolder->convert(val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T convert() const
|
||||
/// Invoke this method to perform conversion.
|
||||
///
|
||||
/// Example usage:
|
||||
/// DynamicAny any("42");
|
||||
/// int i = any.convert<int>();
|
||||
{
|
||||
T result;
|
||||
_pHolder->convert(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DynamicAny& operator = (const T& other)
|
||||
/// Assignment operator
|
||||
{
|
||||
DynamicAny tmp(other);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::type_info& type() const;
|
||||
/// Returns the type information of the stored content.
|
||||
|
||||
private:
|
||||
DynamicAnyHolder* _pHolder;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Poco_DynamicAny_INCLUDED
|
1612
Foundation/include/Poco/DynamicAnyHolder.h
Normal file
1612
Foundation/include/Poco/DynamicAnyHolder.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -112,7 +112,15 @@ public:
|
||||
|
||||
bool canWrite() const;
|
||||
/// Returns true iff the file is writeable.
|
||||
|
||||
|
||||
bool canExecute() const;
|
||||
/// Returns true iff the file is executable.
|
||||
///
|
||||
/// On Windows and OpenVMS, the file must have
|
||||
/// the extension ".EXE" to be executable.
|
||||
/// On Unix platforms, the executable permission
|
||||
/// bit must be set.
|
||||
|
||||
bool isFile() const;
|
||||
/// Returns true iff the file is a regular file.
|
||||
|
||||
@ -121,7 +129,7 @@ public:
|
||||
|
||||
bool isDirectory() const;
|
||||
/// Returns true iff the file is a directory.
|
||||
|
||||
|
||||
Timestamp created() const;
|
||||
/// Returns the creation date of the file.
|
||||
|
||||
@ -148,6 +156,13 @@ public:
|
||||
/// writeable (if flag is false) by setting the
|
||||
/// file's flags in the filesystem accordingly.
|
||||
|
||||
void setExecutable(bool flag = true);
|
||||
/// Makes the file executable (if flag is true), or
|
||||
/// non-executable (if flag is false) by setting
|
||||
/// the file's permission bits accordingly.
|
||||
///
|
||||
/// Does nothing on Windows and OpenVMS.
|
||||
|
||||
void copyTo(const std::string& path) const;
|
||||
/// Copies the file to the given path. The target path
|
||||
/// can be a directory.
|
||||
@ -193,6 +208,10 @@ public:
|
||||
bool operator <= (const File& file) const;
|
||||
bool operator > (const File& file) const;
|
||||
bool operator >= (const File& file) const;
|
||||
|
||||
static void handleLastError(const std::string& path);
|
||||
/// For internal use only. Throws an appropriate
|
||||
/// exception for the last file-related error.
|
||||
};
|
||||
|
||||
|
||||
|
194
Foundation/include/Poco/FileStream.h
Normal file
194
Foundation/include/Poco/FileStream.h
Normal file
@ -0,0 +1,194 @@
|
||||
//
|
||||
// FileStream.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/FileStream.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: FileStream
|
||||
//
|
||||
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FileStream_INCLUDED
|
||||
#define Foundation_FileStream_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "FileStream_WIN32.h"
|
||||
#else
|
||||
#include "FileStream_POSIX.h"
|
||||
#endif
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API FileIOS: public virtual std::ios
|
||||
/// The base class for FileInputStream and FileOutputStream.
|
||||
///
|
||||
/// This class is needed to ensure the correct initialization
|
||||
/// order of the stream buffer and base classes.
|
||||
///
|
||||
/// Files are always opened in binary mode, a text mode
|
||||
/// with CR-LF translation is not supported. Thus, the
|
||||
/// file is always opened as if the std::ios::binary flag
|
||||
/// was specified.
|
||||
/// Use an InputLineEndingConverter or OutputLineEndingConverter
|
||||
/// if you require CR-LF translation.
|
||||
///
|
||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||
{
|
||||
public:
|
||||
FileIOS(std::ios::openmode defaultMode);
|
||||
/// Creates the basic stream.
|
||||
|
||||
~FileIOS();
|
||||
/// Destroys the stream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the file specified by path, using the given mode.
|
||||
///
|
||||
/// Throws a FileException (or a similar exception) if the file
|
||||
/// does not exist or is not accessible for other reasons and
|
||||
/// a new file cannot be created.
|
||||
|
||||
void close();
|
||||
/// Closes the file stream.
|
||||
|
||||
FileStreamBuf* rdbuf();
|
||||
/// Returns a pointer to the underlying streambuf.
|
||||
|
||||
protected:
|
||||
FileStreamBuf _buf;
|
||||
std::ios::openmode _defaultMode;
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API FileInputStream: public FileIOS, public std::istream
|
||||
/// An input stream for reading from a file.
|
||||
///
|
||||
/// Files are always opened in binary mode, a text mode
|
||||
/// with CR-LF translation is not supported. Thus, the
|
||||
/// file is always opened as if the std::ios::binary flag
|
||||
/// was specified.
|
||||
/// Use an InputLineEndingConverter if you require CR-LF translation.
|
||||
///
|
||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||
{
|
||||
public:
|
||||
FileInputStream();
|
||||
/// Creates an unopened FileInputStream.
|
||||
|
||||
FileInputStream(const std::string& path, std::ios::openmode mode = std::ios::in);
|
||||
/// Creates the FileInputStream for the file given by path, using
|
||||
/// the given mode.
|
||||
///
|
||||
/// The std::ios::in flag is always set, regardless of the actual
|
||||
/// value specified for mode.
|
||||
///
|
||||
/// Throws a FileNotFoundException (or a similar exception) if the file
|
||||
/// does not exist or is not accessible for other reasons.
|
||||
|
||||
~FileInputStream();
|
||||
/// Destroys the stream.
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API FileOutputStream: public FileIOS, public std::ostream
|
||||
/// An output stream for writing to a file.
|
||||
///
|
||||
/// Files are always opened in binary mode, a text mode
|
||||
/// with CR-LF translation is not supported. Thus, the
|
||||
/// file is always opened as if the std::ios::binary flag
|
||||
/// was specified.
|
||||
/// Use an OutputLineEndingConverter if you require CR-LF translation.
|
||||
///
|
||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||
{
|
||||
public:
|
||||
FileOutputStream();
|
||||
/// Creats an unopened FileOutputStream.
|
||||
|
||||
FileOutputStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::trunc);
|
||||
/// Creates the FileOutputStream for the file given by path, using
|
||||
/// the given mode.
|
||||
///
|
||||
/// The std::ios::out is always set, regardless of the actual
|
||||
/// value specified for mode.
|
||||
///
|
||||
/// Throws a FileException (or a similar exception) if the file
|
||||
/// does not exist or is not accessible for other reasons and
|
||||
/// a new file cannot be created.
|
||||
|
||||
~FileOutputStream();
|
||||
/// Destroys the FileOutputStream.
|
||||
};
|
||||
|
||||
|
||||
class Foundation_API FileStream: public FileIOS, public std::iostream
|
||||
/// A stream for reading from and writing to a file.
|
||||
///
|
||||
/// Files are always opened in binary mode, a text mode
|
||||
/// with CR-LF translation is not supported. Thus, the
|
||||
/// file is always opened as if the std::ios::binary flag
|
||||
/// was specified.
|
||||
/// Use an InputLineEndingConverter or OutputLineEndingConverter
|
||||
/// if you require CR-LF translation.
|
||||
///
|
||||
/// A seek (seekg() or seekp()) operation will always set the
|
||||
/// read position and the write position simultaneously to the
|
||||
/// same value.
|
||||
///
|
||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||
{
|
||||
public:
|
||||
FileStream();
|
||||
/// Creats an unopened FileStream.
|
||||
|
||||
FileStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in);
|
||||
/// Creates the FileStream for the file given by path, using
|
||||
/// the given mode.
|
||||
|
||||
~FileStream();
|
||||
/// Destroys the FileOutputStream.
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_FileStream_INCLUDED
|
93
Foundation/include/Poco/FileStream_POSIX.h
Normal file
93
Foundation/include/Poco/FileStream_POSIX.h
Normal file
@ -0,0 +1,93 @@
|
||||
//
|
||||
// FileStream_POSIX.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/FileStream_POSIX.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: FileStream
|
||||
//
|
||||
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FileStream_POSIX_INCLUDED
|
||||
#define Foundation_FileStream_POSIX_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/BufferedBidirectionalStreamBuf.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
||||
/// This stream buffer handles Fileio
|
||||
{
|
||||
public:
|
||||
FileStreamBuf();
|
||||
/// Creates a FileStreamBuf.
|
||||
|
||||
~FileStreamBuf();
|
||||
/// Destroys the FileStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the given file in the given mode.
|
||||
|
||||
void close();
|
||||
/// Closes the File stream buffer.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// Change position by offset, according to way and mode.
|
||||
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// Change to specified position, according to mode.
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
BUFFER_SIZE = 4096
|
||||
};
|
||||
|
||||
int readFromDevice(char* buffer, std::streamsize length);
|
||||
int writeToDevice(const char* buffer, std::streamsize length);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
int _fd;
|
||||
std::streamoff _pos;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_FileStream_WIN32_INCLUDED
|
92
Foundation/include/Poco/FileStream_WIN32.h
Normal file
92
Foundation/include/Poco/FileStream_WIN32.h
Normal file
@ -0,0 +1,92 @@
|
||||
//
|
||||
// FileStream_WIN32.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/FileStream_WIN32.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: FileStream
|
||||
//
|
||||
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_FileStream_WIN32_INCLUDED
|
||||
#define Foundation_FileStream_WIN32_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/BufferedBidirectionalStreamBuf.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
||||
/// This stream buffer handles Fileio
|
||||
{
|
||||
public:
|
||||
FileStreamBuf();
|
||||
/// Creates a FileStreamBuf.
|
||||
|
||||
~FileStreamBuf();
|
||||
/// Destroys the FileStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
/// Opens the given file in the given mode.
|
||||
|
||||
void close();
|
||||
/// Closes the File stream buffer
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// change position by offset, according to way and mode
|
||||
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
/// change to specified position, according to mode
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
BUFFER_SIZE = 4096
|
||||
};
|
||||
|
||||
int readFromDevice(char* buffer, std::streamsize length);
|
||||
int writeToDevice(const char* buffer, std::streamsize length);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
HANDLE _handle;
|
||||
UInt64 _pos;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_FileStream_WIN32_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_UNIX.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_UNIX.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_UNIX.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -60,6 +60,7 @@ protected:
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
@ -69,12 +70,13 @@ protected:
|
||||
FileSizeImpl getSizeImpl() const;
|
||||
void setSizeImpl(FileSizeImpl size);
|
||||
void setWriteableImpl(bool flag = true);
|
||||
void setExecutableImpl(bool flag = true);
|
||||
void copyToImpl(const std::string& path) const;
|
||||
void renameToImpl(const std::string& path);
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
static void handleError(const std::string& path);
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_VMS.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_VMS.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_VMS.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -61,6 +61,7 @@ protected:
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
@ -70,12 +71,13 @@ protected:
|
||||
FileSizeImpl getSizeImpl() const;
|
||||
void setSizeImpl(FileSizeImpl size);
|
||||
void setWriteableImpl(bool flag = true);
|
||||
void setExecutableImpl(bool flag = true);
|
||||
void copyToImpl(const std::string& path) const;
|
||||
void renameToImpl(const std::string& path);
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
static void handleError(const std::string& path);
|
||||
static void handleLastError(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_WIN32.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_WIN32.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_WIN32.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -61,6 +61,7 @@ protected:
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
@ -70,12 +71,13 @@ protected:
|
||||
FileSizeImpl getSizeImpl() const;
|
||||
void setSizeImpl(FileSizeImpl size);
|
||||
void setWriteableImpl(bool flag = true);
|
||||
void setExecutableImpl(bool flag = true);
|
||||
void copyToImpl(const std::string& path) const;
|
||||
void renameToImpl(const std::string& path);
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
static void handleError(const std::string& path);
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_WIN32U.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_WIN32U.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File_WIN32U.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -61,6 +61,7 @@ protected:
|
||||
bool existsImpl() const;
|
||||
bool canReadImpl() const;
|
||||
bool canWriteImpl() const;
|
||||
bool canExecuteImpl() const;
|
||||
bool isFileImpl() const;
|
||||
bool isDirectoryImpl() const;
|
||||
bool isLinkImpl() const;
|
||||
@ -70,12 +71,13 @@ protected:
|
||||
FileSizeImpl getSizeImpl() const;
|
||||
void setSizeImpl(FileSizeImpl size);
|
||||
void setWriteableImpl(bool flag = true);
|
||||
void setExecutableImpl(bool flag = true);
|
||||
void copyToImpl(const std::string& path) const;
|
||||
void renameToImpl(const std::string& path);
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
static void handleError(const std::string& path);
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HashTable.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HashTable.h#7 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HashTable.h#8 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
@ -87,7 +87,7 @@ public:
|
||||
_size(ht._size),
|
||||
_maxCapacity(ht._maxCapacity)
|
||||
{
|
||||
for (int i = 0; i < _maxCapacity; ++i)
|
||||
for (UInt32 i = 0; i < _maxCapacity; ++i)
|
||||
{
|
||||
if (ht._entries[i])
|
||||
_entries[i] = new HashEntryMap(ht._entries[i]->begin(), ht._entries[i]->end());
|
||||
@ -112,7 +112,7 @@ public:
|
||||
_entries = new HashEntryMap*[_maxCapacity];
|
||||
_size = ht._size;
|
||||
|
||||
for (int i = 0; i < _maxCapacity; ++i)
|
||||
for (UInt32 i = 0; i < _maxCapacity; ++i)
|
||||
{
|
||||
if (ht._entries[i])
|
||||
_entries[i] = new HashEntryMap(ht._entries[i]->begin(), ht._entries[i]->end());
|
||||
@ -127,7 +127,7 @@ public:
|
||||
{
|
||||
if (!_entries)
|
||||
return;
|
||||
for (int i = 0; i < _maxCapacity; ++i)
|
||||
for (UInt32 i = 0; i < _maxCapacity; ++i)
|
||||
{
|
||||
if (_entries[i])
|
||||
delete _entries[i];
|
||||
@ -323,7 +323,7 @@ public:
|
||||
return;
|
||||
}
|
||||
_size = 0;
|
||||
for (int i=0; i < oldSize; ++i)
|
||||
for (UInt32 i = 0; i < oldSize; ++i)
|
||||
{
|
||||
if (cpy[i])
|
||||
{
|
||||
@ -350,7 +350,7 @@ public:
|
||||
#ifdef DEBUG
|
||||
UInt32 totalSize = 0;
|
||||
#endif
|
||||
for (int i=0; i < _maxCapacity; ++i)
|
||||
for (UInt32 i = 0; i < _maxCapacity; ++i)
|
||||
{
|
||||
if (_entries[i])
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HexBinaryEncoder.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HexBinaryEncoder.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/HexBinaryEncoder.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -60,11 +60,23 @@ class Foundation_API HexBinaryEncoderBuf: public UnbufferedStreamBuf
|
||||
public:
|
||||
HexBinaryEncoderBuf(std::ostream& ostr);
|
||||
~HexBinaryEncoderBuf();
|
||||
|
||||
int close();
|
||||
/// Closes the stream buffer.
|
||||
|
||||
void setLineLength(int lineLength);
|
||||
/// Specify the line length.
|
||||
///
|
||||
/// After the given number of characters have been written,
|
||||
/// a newline character will be written.
|
||||
///
|
||||
/// Specify 0 for an unlimited line length.
|
||||
|
||||
int getLineLength() const;
|
||||
/// Returns the currently set line length.
|
||||
|
||||
void setUppercase(bool flag = true);
|
||||
/// Specify whether hex digits a-f are written in upper or lower case.
|
||||
|
||||
private:
|
||||
int writeToDevice(char c);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// InflatingStream.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/InflatingStream.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/InflatingStream.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -61,7 +61,8 @@ public:
|
||||
enum StreamType
|
||||
{
|
||||
STREAM_ZLIB,
|
||||
STREAM_GZIP
|
||||
STREAM_GZIP,
|
||||
STREAM_ZIP // ZIP is handled as STREAM_ZLIB, except that we do not check the ADLER32 value (must be checked by an outside class!)
|
||||
};
|
||||
|
||||
InflatingStreamBuf(std::istream& istr, StreamType type);
|
||||
@ -85,6 +86,7 @@ private:
|
||||
char* _buffer;
|
||||
z_stream _zstr;
|
||||
bool _eof;
|
||||
bool _check;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LocalDateTime.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/LocalDateTime.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/LocalDateTime.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -100,7 +100,13 @@ public:
|
||||
|
||||
LocalDateTime(int tzd, const DateTime& dateTime);
|
||||
/// Creates a LocalDateTime from the UTC time given in dateTime,
|
||||
/// using the given time zone differential.
|
||||
/// using the given time zone differential. Adjusts dateTime
|
||||
/// for the given time zone differential.
|
||||
|
||||
LocalDateTime(int tzd, const DateTime& dateTime, bool adjust);
|
||||
/// Creates a LocalDateTime from the UTC time given in dateTime,
|
||||
/// using the given time zone differential. If adjust is true,
|
||||
/// adjusts dateTime for the given time zone differential.
|
||||
|
||||
LocalDateTime(double julianDay);
|
||||
/// Creates a LocalDateTime for the given Julian day in the local time zone.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LogFile_STD.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/LogFile_STD.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/LogFile_STD.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -42,14 +42,14 @@
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include <fstream>
|
||||
#include "Poco/FileStream.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API LogFileImpl
|
||||
/// The implementation of LogFile for Windows.
|
||||
/// The implementation of LogFile for non-Windows platforms.
|
||||
/// The native filesystem APIs are used for
|
||||
/// total control over locking behavior.
|
||||
{
|
||||
@ -62,9 +62,9 @@ public:
|
||||
const std::string& pathImpl() const;
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
mutable std::ofstream _str;
|
||||
Timestamp _creationDate;
|
||||
std::string _path;
|
||||
mutable Poco::FileOutputStream _str;
|
||||
Timestamp _creationDate;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Path.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Path.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Path.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -294,7 +294,7 @@ public:
|
||||
/// Returns the platform's path separator, which separates
|
||||
/// single paths in a list of paths.
|
||||
///
|
||||
/// On Unix systems, this is the colon ':'. Opn Windows systems,
|
||||
/// On Unix systems, this is the colon ':'. On Windows systems,
|
||||
/// this is the semicolon ';'. On OpenVMS systems, this is the
|
||||
/// comma ','.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// RotateStrategy.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/RotateStrategy.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/RotateStrategy.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -71,7 +71,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class DT>
|
||||
template <class DT>
|
||||
class RotateAtTimeStrategy: public RotateStrategy
|
||||
/// The file is rotated at specified [day,][hour]:minute
|
||||
{
|
||||
|
130
Foundation/include/Poco/SharedMemory.h
Normal file
130
Foundation/include/Poco/SharedMemory.h
Normal file
@ -0,0 +1,130 @@
|
||||
//
|
||||
// SharedMemory.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory.h#3 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemory
|
||||
//
|
||||
// Definition of the SharedMemory class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_SharedMemory_INCLUDED
|
||||
#define Poco_SharedMemory_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Poco.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class SharedMemoryImpl;
|
||||
class File;
|
||||
|
||||
|
||||
class Foundation_API SharedMemory
|
||||
/// Create and manage a shared memory object.
|
||||
///
|
||||
/// A SharedMemory object has value semantics, but
|
||||
/// is implemented using a handle/implementation idiom.
|
||||
/// Therefore, multiple SharedMemory objects can share
|
||||
/// a single, reference counted SharedMemoryImpl object.
|
||||
{
|
||||
public:
|
||||
enum AccessMode
|
||||
{
|
||||
AM_READ = 0,
|
||||
AM_WRITE
|
||||
};
|
||||
|
||||
SharedMemory();
|
||||
/// Default constructor creates an unmapped SharedMemory object.
|
||||
/// No clients can connect to an unmapped SharedMemory object.
|
||||
|
||||
SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint = 0);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
/// contain any slashes or backslashes.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
SharedMemory(const File& file, AccessMode mode, const void* addrHint = 0);
|
||||
/// Maps the entire contents of file into a shared memory segment.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
SharedMemory(const SharedMemory& other);
|
||||
/// Creates a SharedMemory object by copying another one.
|
||||
|
||||
~SharedMemory();
|
||||
/// Destroys the SharedMemory.
|
||||
|
||||
SharedMemory& operator = (const SharedMemory& other);
|
||||
/// Assigns another SharedMemory object.
|
||||
|
||||
void swap(SharedMemory& other);
|
||||
/// Swaps the SharedMemory object with another one.
|
||||
|
||||
char* begin() const;
|
||||
/// Returns the start address of the shared memory segment.
|
||||
/// Will be NULL for illegal segments.
|
||||
|
||||
char* end() const;
|
||||
/// Returns the one-past-end end address of the shared memory segment.
|
||||
/// Will be NULL for illegal segments.
|
||||
|
||||
private:
|
||||
SharedMemoryImpl* _pImpl;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline void SharedMemory::swap(SharedMemory& other)
|
||||
{
|
||||
using std::swap;
|
||||
swap(_pImpl, other._pImpl);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco::Poco
|
||||
|
||||
|
||||
#endif // Poco_SharedMemory_INCLUDED
|
110
Foundation/include/Poco/SharedMemory_DUMMY.h
Normal file
110
Foundation/include/Poco/SharedMemory_DUMMY.h
Normal file
@ -0,0 +1,110 @@
|
||||
//
|
||||
// SharedMemoryImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_DUMMY.h#3 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemoryImpl
|
||||
//
|
||||
// Definition of the SharedMemoryImpl class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_SharedMemoryImpl_INCLUDED
|
||||
#define Poco_SharedMemoryImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Poco.h"
|
||||
#include "Poco/SharedMemory.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API SharedMemoryImpl: public RefCountedObject
|
||||
/// A dummy implementation of shared memory, for systems
|
||||
/// that do not have shared memory support.
|
||||
{
|
||||
public:
|
||||
SharedMemoryImpl(const std::string& id, std::size_t size, SharedMemory::AccessMode mode, const void* addr);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
/// contain any slashes or backslashes.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
SharedMemoryImpl(const Poco::File& aFile, SharedMemory::AccessMode mode, const void* addr);
|
||||
/// Maps the entire contents of file into a shared memory segment.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
char* begin() const;
|
||||
/// Returns the start address of the shared memory segment.
|
||||
|
||||
char* end() const;
|
||||
/// Returns the one-past-end end address of the shared memory segment.
|
||||
|
||||
protected:
|
||||
~SharedMemoryImpl();
|
||||
/// Destroys the SharedMemoryImpl.
|
||||
|
||||
private:
|
||||
SharedMemoryImpl();
|
||||
SharedMemoryImpl(const SharedMemoryImpl&);
|
||||
SharedMemoryImpl& operator = (const SharedMemoryImpl&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline char* SharedMemoryImpl::begin() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
inline char* SharedMemoryImpl::end() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Poco_SharedMemoryImpl_INCLUDED
|
125
Foundation/include/Poco/SharedMemory_POSIX.h
Normal file
125
Foundation/include/Poco/SharedMemory_POSIX.h
Normal file
@ -0,0 +1,125 @@
|
||||
//
|
||||
// SharedMemoryImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_POSIX.h#4 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemoryImpl
|
||||
//
|
||||
// Definition of the SharedMemoryImpl class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_SharedMemoryImpl_INCLUDED
|
||||
#define Poco_SharedMemoryImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Poco.h"
|
||||
#include "Poco/SharedMemory.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API SharedMemoryImpl: public RefCountedObject
|
||||
/// Shared memory implementation for POSIX platforms.
|
||||
{
|
||||
public:
|
||||
SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
/// contain any slashes or backslashes.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
/// Maps the entire contents of file into a shared memory segment.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
char* begin() const;
|
||||
/// Returns the start address of the shared memory segment.
|
||||
|
||||
char* end() const;
|
||||
/// Returns the one-past-end end address of the shared memory segment.
|
||||
|
||||
protected:
|
||||
void map(const void* addrHint);
|
||||
/// Maps the shared memory object.
|
||||
|
||||
void unmap();
|
||||
/// Unmaps the shared memory object.
|
||||
|
||||
void close();
|
||||
/// Releases the handle for the shared memory segment.
|
||||
|
||||
~SharedMemoryImpl();
|
||||
/// Destroys the SharedMemoryImpl.
|
||||
|
||||
private:
|
||||
SharedMemoryImpl();
|
||||
SharedMemoryImpl(const SharedMemoryImpl&);
|
||||
SharedMemoryImpl& operator = (const SharedMemoryImpl&);
|
||||
|
||||
std::size_t _size;
|
||||
int _fd;
|
||||
char* _address;
|
||||
SharedMemory::AccessMode _access;
|
||||
std::string _name;
|
||||
bool _fileMapped;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline char* SharedMemoryImpl::begin() const
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
|
||||
inline char* SharedMemoryImpl::end() const
|
||||
{
|
||||
return _address + _size;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Poco_SharedMemoryImpl_INCLUDED
|
125
Foundation/include/Poco/SharedMemory_WIN32.h
Normal file
125
Foundation/include/Poco/SharedMemory_WIN32.h
Normal file
@ -0,0 +1,125 @@
|
||||
//
|
||||
// SharedMemoryImpl.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedMemory_WIN32.h#3 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemoryImpl
|
||||
//
|
||||
// Definition of the SharedMemoryImpl class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_SharedMemoryImpl_INCLUDED
|
||||
#define Poco_SharedMemoryImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Poco.h"
|
||||
#include "Poco/SharedMemory.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API SharedMemoryImpl: public RefCountedObject
|
||||
/// Shared memory implementation for Windows platforms.
|
||||
{
|
||||
public:
|
||||
SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
/// Creates or connects to a shared memory object with the given name.
|
||||
///
|
||||
/// For maximum portability, name should be a valid Unix filename and not
|
||||
/// contain any slashes or backslashes.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint);
|
||||
/// Maps the entire contents of file into a shared memory segment.
|
||||
///
|
||||
/// An address hint can be passed to the system, specifying the desired
|
||||
/// start address of the shared memory area. Whether the hint
|
||||
/// is actually honored is, however, up to the system. Windows platform
|
||||
/// will generally ignore the hint.
|
||||
|
||||
char* begin() const;
|
||||
/// Returns the beginn address of the SharedMemory segment. Will be null for illegal segments.
|
||||
|
||||
char* end() const;
|
||||
/// Points past the last byte of the end address of the SharedMemory segment. Will be null for illegal segments.
|
||||
|
||||
protected:
|
||||
void map();
|
||||
/// Maps the shared memory object.
|
||||
|
||||
void unmap();
|
||||
/// Unmaps the shared memory object.
|
||||
|
||||
void close();
|
||||
/// Releases the handle for the shared memory segment.
|
||||
|
||||
~SharedMemoryImpl();
|
||||
/// Destroys the SharedMemoryImpl.
|
||||
|
||||
private:
|
||||
SharedMemoryImpl();
|
||||
SharedMemoryImpl(const SharedMemoryImpl&);
|
||||
SharedMemoryImpl& operator = (const SharedMemoryImpl&);
|
||||
|
||||
std::string _name;
|
||||
HANDLE _memHandle;
|
||||
HANDLE _fileHandle;
|
||||
DWORD _size;
|
||||
DWORD _mode;
|
||||
char* _address;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline char* SharedMemoryImpl::begin() const
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
|
||||
inline char* SharedMemoryImpl::end() const
|
||||
{
|
||||
return _address + _size;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Poco_SharedMemoryImpl_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SharedPtr.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedPtr.h#9 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SharedPtr.h#10 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -373,7 +373,7 @@ private:
|
||||
ReferenceCounter* _pCounter;
|
||||
C* _ptr;
|
||||
|
||||
template<class Other> friend class SharedPtr;
|
||||
template <class Other> friend class SharedPtr;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SimpleHashTable.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SimpleHashTable.h#10 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SimpleHashTable.h#11 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Hashing
|
||||
@ -317,13 +317,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool exists(const Key& key)
|
||||
bool exists(const Key& key) const
|
||||
{
|
||||
UInt32 hsh = hash(key);
|
||||
return existsRaw(key, hsh);
|
||||
}
|
||||
|
||||
bool existsRaw(const Key& key, UInt32 hsh)
|
||||
bool existsRaw(const Key& key, UInt32 hsh) const
|
||||
{
|
||||
UInt32 origHash = hsh;
|
||||
while (true)
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Timespan.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Timespan.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Timespan.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -145,7 +145,7 @@ public:
|
||||
|
||||
int useconds() const;
|
||||
/// Returns the fractions of a second
|
||||
/// in microseconds (0 to 999).
|
||||
/// in microseconds (0 to 999999).
|
||||
|
||||
TimeDiff totalMicroseconds() const;
|
||||
/// Returns the total number of microseconds.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Tuple.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Tuple.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Tuple.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -54,7 +54,7 @@ namespace Poco {
|
||||
#endif
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1 = NullTypeList,
|
||||
class T2 = NullTypeList,
|
||||
class T3 = NullTypeList,
|
||||
@ -130,19 +130,19 @@ struct Tuple
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -168,7 +168,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -241,19 +241,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,N
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -279,7 +279,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template< class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -349,19 +349,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,NullT
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -387,7 +387,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -454,19 +454,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,NullTypeL
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -492,7 +492,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -556,19 +556,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -594,7 +594,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -655,19 +655,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -693,7 +693,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -751,19 +751,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -789,7 +789,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -844,19 +844,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -882,7 +882,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -934,19 +934,19 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -972,7 +972,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1021,19 +1021,19 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9,T10, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1059,7 +1059,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1105,19 +1105,19 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1143,7 +1143,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1186,19 +1186,19 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1224,7 +1224,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1264,19 +1264,19 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1302,7 +1302,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1339,19 +1339,19 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1377,7 +1377,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1411,19 +1411,19 @@ struct Tuple<T0, T1,T2,T3,T4,T5, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1449,7 +1449,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3,
|
||||
@ -1480,19 +1480,19 @@ struct Tuple<T0, T1,T2,T3,T4, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1518,7 +1518,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2,
|
||||
class T3>
|
||||
@ -1546,19 +1546,19 @@ struct Tuple<T0, T1,T2,T3, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1584,7 +1584,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1,
|
||||
class T2>
|
||||
struct Tuple<T0, T1,T2, NullTypeList>
|
||||
@ -1609,19 +1609,19 @@ struct Tuple<T0, T1,T2, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1647,7 +1647,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0,
|
||||
template <class T0,
|
||||
class T1>
|
||||
struct Tuple<T0, T1, NullTypeList>
|
||||
{
|
||||
@ -1668,19 +1668,19 @@ struct Tuple<T0, T1, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
@ -1706,7 +1706,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
template<class T0>
|
||||
template <class T0>
|
||||
struct Tuple<T0, NullTypeList>
|
||||
{
|
||||
typedef TypeList<T0, NullTypeList> Type;
|
||||
@ -1725,19 +1725,19 @@ struct Tuple<T0, NullTypeList>
|
||||
{
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::ConstHeadType& get() const
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
typename TypeGetter<N, Type>::HeadType& get()
|
||||
{
|
||||
return Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data);
|
||||
}
|
||||
|
||||
template<int N>
|
||||
template <int N>
|
||||
void set(typename TypeGetter<N, Type>::ConstHeadType& val)
|
||||
{
|
||||
Getter<N>::template get<typename TypeGetter<N, Type>::HeadType, typename Type::HeadType, typename Type::TailType>(_data) = val;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// TypeList.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/TypeList.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/TypeList.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -212,23 +212,23 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct TypeListType<>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template<int n>
|
||||
template <int n>
|
||||
struct Getter
|
||||
{
|
||||
template<class Ret, class Head, class Tail>
|
||||
template <class Ret, class Head, class Tail>
|
||||
inline static Ret& get(TypeList<Head, Tail>& val)
|
||||
{
|
||||
return Getter<n-1>::template get<Ret, typename Tail::HeadType, typename Tail::TailType>(val.tail);
|
||||
}
|
||||
|
||||
template<class Ret, class Head, class Tail>
|
||||
template <class Ret, class Head, class Tail>
|
||||
inline static const Ret& get(const TypeList<Head, Tail>& val)
|
||||
{
|
||||
return Getter<n-1>::template get<Ret, typename Tail::HeadType, typename Tail::TailType>(val.tail);
|
||||
@ -236,16 +236,16 @@ struct Getter
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct Getter<0>
|
||||
{
|
||||
template<class Ret, class Head, class Tail>
|
||||
template <class Ret, class Head, class Tail>
|
||||
inline static Ret& get(TypeList<Head, Tail>& val)
|
||||
{
|
||||
return val.head;
|
||||
}
|
||||
|
||||
template<class Ret, class Head, class Tail>
|
||||
template <class Ret, class Head, class Tail>
|
||||
inline static const Ret& get(const TypeList<Head, Tail>& val)
|
||||
{
|
||||
return val.head;
|
||||
@ -326,28 +326,28 @@ struct TypeAppender;
|
||||
///
|
||||
|
||||
|
||||
template<>
|
||||
template <>
|
||||
struct TypeAppender<NullTypeList, NullTypeList>
|
||||
{
|
||||
typedef NullTypeList HeadType;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
struct TypeAppender<NullTypeList, T>
|
||||
{
|
||||
typedef POCO_TYPELIST_1(T) HeadType;
|
||||
};
|
||||
|
||||
|
||||
template<class Head, class Tail>
|
||||
template <class Head, class Tail>
|
||||
struct TypeAppender<NullTypeList, TypeList<Head, Tail> >
|
||||
{
|
||||
typedef TypeList<Head, Tail> HeadType;
|
||||
};
|
||||
|
||||
|
||||
template<class Head, class Tail, class T>
|
||||
template <class Head, class Tail, class T>
|
||||
struct TypeAppender<TypeList<Head, Tail>, T>
|
||||
{
|
||||
typedef TypeList<Head, typename TypeAppender<Tail, T>::HeadType> HeadType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// UnufferedStreamBuf.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UnbufferedStreamBuf.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UnbufferedStreamBuf.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -50,7 +50,7 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template<typename ch, typename tr>
|
||||
template <typename ch, typename tr>
|
||||
class BasicUnbufferedStreamBuf: public std::basic_streambuf<ch, tr>
|
||||
/// This is an implementation of an unbuffered streambuf
|
||||
/// that greatly simplifies the implementation of
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTime.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/samples/DateTime/src/DateTime.cpp#9 $
|
||||
// $Id: //poco/Main/Foundation/samples/DateTime/src/DateTime.cpp#10 $
|
||||
//
|
||||
// This sample demonstrates the DateTime class.
|
||||
//
|
||||
@ -32,30 +32,30 @@
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/LocalDateTime.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
#include "Poco/DateTimeFormatter.h"
|
||||
#include "Poco/DateTimeParser.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using Poco::LocalDateTime;
|
||||
using Poco::DateTime;
|
||||
using Poco::DateTimeFormat;
|
||||
using Poco::DateTimeFormatter;
|
||||
using Poco::DateTimeParser;
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
DateTime now;
|
||||
|
||||
std::cout << "Today is "
|
||||
<< DateTimeFormat::WEEKDAY_NAMES[now.dayOfWeek()] << ", "
|
||||
<< DateTimeFormat::MONTH_NAMES[now.month() - 1] << " "
|
||||
<< now.day() << " - "
|
||||
<< "day number "
|
||||
<< now.dayOfYear()
|
||||
<< " in "
|
||||
<< now.year()
|
||||
<< " and day number "
|
||||
<< (long) now.julianDay()
|
||||
<< " in the Julian calendar." << std::endl;
|
||||
LocalDateTime now;
|
||||
|
||||
std::string str = DateTimeFormatter::format(now, DateTimeFormat::ISO8601_FORMAT);
|
||||
DateTime dt;
|
||||
int tzd;
|
||||
DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, str, dt, tzd);
|
||||
dt.makeUTC(tzd);
|
||||
LocalDateTime ldt(tzd, dt);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// NotificationQueue.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/samples/NotificationQueue/src/NotificationQueue.cpp#10 $
|
||||
// $Id: //poco/Main/Foundation/samples/NotificationQueue/src/NotificationQueue.cpp#11 $
|
||||
//
|
||||
// This sample demonstrates the NotificationQueue, ThreadPool,
|
||||
// FastMutex and ScopedLock classes.
|
||||
@ -95,10 +95,10 @@ public:
|
||||
WorkNotification* pWorkNf = dynamic_cast<WorkNotification*>(pNf.get());
|
||||
if (pWorkNf)
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
std::cout << _name << " got work notification " << pWorkNf->data() << std::endl;
|
||||
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
std::cout << _name << " got work notification " << pWorkNf->data() << std::endl;
|
||||
}
|
||||
Thread::sleep(rnd.next(200));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ArchiveStrategy.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/ArchiveStrategy.cpp#7 $
|
||||
// $Id: //poco/Main/Foundation/src/ArchiveStrategy.cpp#8 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -44,7 +44,7 @@
|
||||
#include "Poco/ActiveDispatcher.h"
|
||||
#include "Poco/ActiveMethod.h"
|
||||
#include "Poco/Void.h"
|
||||
#include <fstream>
|
||||
#include "Poco/FileStream.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -74,9 +74,9 @@ protected:
|
||||
{
|
||||
std::string gzPath(path);
|
||||
gzPath.append(".gz");
|
||||
std::ifstream istr(Path::transcode(path).c_str(), std::ios::binary | std::ios::in);
|
||||
FileInputStream istr(path, std::ios::binary | std::ios::in);
|
||||
if (!istr.good()) throw OpenFileException(path);
|
||||
std::ofstream ostr(Path::transcode(gzPath).c_str(), std::ios::binary | std::ios::out);
|
||||
FileOutputStream ostr(gzPath, std::ios::binary | std::ios::out);
|
||||
if (ostr.good())
|
||||
{
|
||||
DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// AsyncChannel.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/AsyncChannel.cpp#10 $
|
||||
// $Id: //poco/Main/Foundation/src/AsyncChannel.cpp#12 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -98,7 +98,10 @@ Channel* AsyncChannel::getChannel() const
|
||||
|
||||
void AsyncChannel::open()
|
||||
{
|
||||
_thread.start(*this);
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
|
||||
if (!_thread.isRunning())
|
||||
_thread.start(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -115,6 +118,8 @@ void AsyncChannel::close()
|
||||
|
||||
void AsyncChannel::log(const Message& msg)
|
||||
{
|
||||
open();
|
||||
|
||||
_queue.enqueueNotification(new MessageNotification(msg));
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Base64Encoder.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/Base64Encoder.cpp#14 $
|
||||
// $Id: //poco/Main/Foundation/src/Base64Encoder.cpp#15 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -76,8 +76,6 @@ Base64EncoderBuf::~Base64EncoderBuf()
|
||||
|
||||
void Base64EncoderBuf::setLineLength(int lineLength)
|
||||
{
|
||||
poco_assert (lineLength > 0);
|
||||
|
||||
_lineLength = lineLength;
|
||||
}
|
||||
|
||||
@ -103,7 +101,7 @@ int Base64EncoderBuf::writeToDevice(char c)
|
||||
idx = _group[2] & 0x3F;
|
||||
_ostr.put(OUT_ENCODING[idx]);
|
||||
_pos += 4;
|
||||
if (_pos >= _lineLength)
|
||||
if (_lineLength > 0 && _pos >= _lineLength)
|
||||
{
|
||||
_ostr << "\r\n";
|
||||
_pos = 0;
|
||||
|
76
Foundation/src/Checksum.cpp
Normal file
76
Foundation/src/Checksum.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
//
|
||||
// Checksum.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/Checksum.cpp#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
// Module: Checksum
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Checksum.h"
|
||||
#include "Poco/zlib.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
Checksum::Checksum():
|
||||
_type(TYPE_CRC32),
|
||||
_value(crc32(0L, Z_NULL, 0))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Checksum::Checksum(Type t):
|
||||
_type(t),
|
||||
_value(0)
|
||||
{
|
||||
if (t == TYPE_CRC32)
|
||||
_value = crc32(0L, Z_NULL, 0);
|
||||
else
|
||||
_value = adler32(0L, Z_NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
Checksum::~Checksum()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Checksum::update(const char* data, unsigned length)
|
||||
{
|
||||
if (_type == TYPE_ADLER32)
|
||||
_value = adler32(_value, reinterpret_cast<const Bytef*>(data), length);
|
||||
else
|
||||
_value = crc32(_value, reinterpret_cast<const Bytef*>(data), length);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTime.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DateTime.cpp#15 $
|
||||
// $Id: //poco/Main/Foundation/src/DateTime.cpp#16 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/Timespan.h"
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
@ -305,6 +306,18 @@ DateTime& DateTime::operator -= (const Timespan& span)
|
||||
}
|
||||
|
||||
|
||||
void DateTime::makeUTC(int tzd)
|
||||
{
|
||||
operator -= (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
|
||||
}
|
||||
|
||||
|
||||
void DateTime::makeLocal(int tzd)
|
||||
{
|
||||
operator += (Timespan(((Timestamp::TimeDiff) tzd)*Timespan::SECONDS));
|
||||
}
|
||||
|
||||
|
||||
double DateTime::toJulianDay(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
|
||||
{
|
||||
// lookup table for (153*month - 457)/5 - note that 3 <= month <= 14.
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_UNIX.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DirectoryIterator_UNIX.cpp#11 $
|
||||
// $Id: //poco/Main/Foundation/src/DirectoryIterator_UNIX.cpp#12 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -48,7 +48,7 @@ DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _pDir(0),
|
||||
p.makeFile();
|
||||
|
||||
_pDir = opendir(p.toString().c_str());
|
||||
if (!_pDir) FileImpl::handleError(path);
|
||||
if (!_pDir) File::handleLastError(path);
|
||||
|
||||
next();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_WIN32.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DirectoryIterator_WIN32.cpp#11 $
|
||||
// $Id: //poco/Main/Foundation/src/DirectoryIterator_WIN32.cpp#12 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -53,7 +53,7 @@ DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVAL
|
||||
if (_fh == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (GetLastError() != ERROR_NO_MORE_FILES)
|
||||
FileImpl::handleError(path);
|
||||
File::handleLastError(path);
|
||||
}
|
||||
_current = _fd.cFileName;
|
||||
if (_current == "." || _current == "..")
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DirectoryIterator_WIN32U.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DirectoryIterator_WIN32U.cpp#5 $
|
||||
// $Id: //poco/Main/Foundation/src/DirectoryIterator_WIN32U.cpp#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -57,7 +57,7 @@ DirectoryIteratorImpl::DirectoryIteratorImpl(const std::string& path): _fh(INVAL
|
||||
if (_fh == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (GetLastError() != ERROR_NO_MORE_FILES)
|
||||
FileImpl::handleError(path);
|
||||
File::handleLastError(path);
|
||||
}
|
||||
UnicodeConverter::toUTF8(_fd.cFileName, _current);
|
||||
if (_current == "." || _current == "..")
|
||||
|
81
Foundation/src/DynamicAny.cpp
Normal file
81
Foundation/src/DynamicAny.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// DynamicAny.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DynamicAny.cpp#2 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Core
|
||||
// Module: DynamicAny
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/DynamicAny.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
DynamicAny::DynamicAny():
|
||||
_pHolder(new DynamicAnyHolderImpl<int>(0))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DynamicAny::DynamicAny(const char* pVal):
|
||||
_pHolder(new DynamicAnyHolderImpl<std::string>(pVal))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DynamicAny::DynamicAny(const DynamicAny& other):
|
||||
_pHolder(0)
|
||||
{
|
||||
if (other._pHolder)
|
||||
_pHolder = other._pHolder->clone();
|
||||
}
|
||||
|
||||
|
||||
DynamicAny::~DynamicAny()
|
||||
{
|
||||
delete _pHolder;
|
||||
}
|
||||
|
||||
|
||||
void DynamicAny::swap(DynamicAny& ptr)
|
||||
{
|
||||
std::swap(_pHolder, ptr._pHolder);
|
||||
}
|
||||
|
||||
|
||||
const std::type_info& DynamicAny::type() const
|
||||
{
|
||||
return _pHolder->type();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco::Poco
|
53
Foundation/src/DynamicAnyHolder.cpp
Normal file
53
Foundation/src/DynamicAnyHolder.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// DynamicAnyHolder.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/DynamicAnyHolder.cpp#1 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Core
|
||||
// Module: DynamicAnyHolder
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/DynamicAnyHolder.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
DynamicAnyHolder::DynamicAnyHolder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DynamicAnyHolder::~DynamicAnyHolder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/File.cpp#15 $
|
||||
// $Id: //poco/Main/Foundation/src/File.cpp#17 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -135,7 +135,13 @@ bool File::canWrite() const
|
||||
return canWriteImpl();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool File::canExecute() const
|
||||
{
|
||||
return canExecuteImpl();
|
||||
}
|
||||
|
||||
|
||||
bool File::isFile() const
|
||||
{
|
||||
return isFileImpl();
|
||||
@ -195,6 +201,12 @@ void File::setReadOnly(bool flag)
|
||||
setWriteableImpl(!flag);
|
||||
}
|
||||
|
||||
|
||||
void File::setExecutable(bool flag)
|
||||
{
|
||||
setExecutableImpl(flag);
|
||||
}
|
||||
|
||||
|
||||
void File::copyTo(const std::string& path) const
|
||||
{
|
||||
@ -298,4 +310,10 @@ void File::list(std::vector<File>& files) const
|
||||
}
|
||||
|
||||
|
||||
void File::handleLastError(const std::string& path)
|
||||
{
|
||||
handleLastErrorImpl(path);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
140
Foundation/src/FileStream.cpp
Normal file
140
Foundation/src/FileStream.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
//
|
||||
// FileStream.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/FileStream.cpp#8 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: FileStream
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/Exception.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "FileStream_WIN32.cpp"
|
||||
#else
|
||||
#include "FileStream_POSIX.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
FileIOS::FileIOS(std::ios::openmode defaultMode):
|
||||
_defaultMode(defaultMode)
|
||||
{
|
||||
poco_ios_init(&_buf);
|
||||
}
|
||||
|
||||
|
||||
FileIOS::~FileIOS()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FileIOS::open(const std::string& path, std::ios::openmode mode)
|
||||
{
|
||||
clear();
|
||||
_buf.open(path, mode | _defaultMode);
|
||||
}
|
||||
|
||||
|
||||
void FileIOS::close()
|
||||
{
|
||||
_buf.close();
|
||||
}
|
||||
|
||||
|
||||
FileStreamBuf* FileIOS::rdbuf()
|
||||
{
|
||||
return &_buf;
|
||||
}
|
||||
|
||||
|
||||
FileInputStream::FileInputStream():
|
||||
FileIOS(std::ios::in),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileInputStream::FileInputStream(const std::string& path, std::ios::openmode mode):
|
||||
FileIOS(std::ios::in),
|
||||
std::istream(&_buf)
|
||||
{
|
||||
open(path, mode);
|
||||
}
|
||||
|
||||
|
||||
FileInputStream::~FileInputStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileOutputStream::FileOutputStream():
|
||||
FileIOS(std::ios::out),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileOutputStream::FileOutputStream(const std::string& path, std::ios::openmode mode):
|
||||
FileIOS(std::ios::out),
|
||||
std::ostream(&_buf)
|
||||
{
|
||||
open(path, mode);
|
||||
}
|
||||
|
||||
|
||||
FileOutputStream::~FileOutputStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileStream::FileStream():
|
||||
FileIOS(std::ios::in | std::ios::out),
|
||||
std::iostream(&_buf)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileStream::FileStream(const std::string& path, std::ios::openmode mode):
|
||||
FileIOS(std::ios::in | std::ios::out),
|
||||
std::iostream(&_buf)
|
||||
{
|
||||
open(path, mode);
|
||||
}
|
||||
|
||||
|
||||
FileStream::~FileStream()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FileStreamFactory.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/FileStreamFactory.cpp#8 $
|
||||
// $Id: //poco/Main/Foundation/src/FileStreamFactory.cpp#9 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: URI
|
||||
@ -39,7 +39,7 @@
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <fstream>
|
||||
#include "Poco/FileStream.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -73,7 +73,7 @@ std::istream* FileStreamFactory::open(const Path& path)
|
||||
File file(path);
|
||||
if (!file.exists()) throw FileNotFoundException(path.toString());
|
||||
|
||||
std::ifstream* istr = new std::ifstream(Path::transcode(path.toString()).c_str(), std::ios::binary);
|
||||
FileInputStream* istr = new FileInputStream(path.toString(), std::ios::binary);
|
||||
if (!istr->good())
|
||||
{
|
||||
delete istr;
|
||||
|
183
Foundation/src/FileStream_POSIX.cpp
Normal file
183
Foundation/src/FileStream_POSIX.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
//
|
||||
// FileStream_POSIX.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/FileStream_POSIX.cpp#10 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: FileStream
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
FileStreamBuf::FileStreamBuf():
|
||||
BufferedBidirectionalStreamBuf(BUFFER_SIZE, std::ios::in | std::ios::out),
|
||||
_fd(-1),
|
||||
_pos(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileStreamBuf::~FileStreamBuf()
|
||||
{
|
||||
try
|
||||
{
|
||||
close();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
|
||||
{
|
||||
poco_assert (_fd == -1);
|
||||
|
||||
_path = path;
|
||||
setMode(mode);
|
||||
|
||||
int flags(0);
|
||||
if (mode & std::ios::trunc)
|
||||
flags |= O_TRUNC;
|
||||
if (mode & std::ios::app)
|
||||
flags |= O_APPEND;
|
||||
if (mode & std::ios::out)
|
||||
flags |= O_CREAT;
|
||||
if ((mode & std::ios::in) && (mode & std::ios::out))
|
||||
flags |= O_RDWR;
|
||||
else if (mode & std::ios::in)
|
||||
flags |= O_RDONLY;
|
||||
else
|
||||
flags |= O_WRONLY;
|
||||
|
||||
_fd = ::open(path.c_str(), flags, S_IRUSR | S_IWUSR | S_IRGRP);
|
||||
if (_fd == -1)
|
||||
File::handleLastError(_path);
|
||||
|
||||
if ((mode & std::ios::app) || (mode & std::ios::ate))
|
||||
seekoff(0, std::ios::end, mode);
|
||||
}
|
||||
|
||||
|
||||
int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
{
|
||||
if (_fd == -1) return -1;
|
||||
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
int n = read(_fd, buffer, length);
|
||||
if (n == -1)
|
||||
File::handleLastError(_path);
|
||||
_pos += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
|
||||
{
|
||||
if (_fd == -1) return -1;
|
||||
|
||||
int n = write(_fd, buffer, length);
|
||||
if (n == -1)
|
||||
File::handleLastError(_path);
|
||||
_pos += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void FileStreamBuf::close()
|
||||
{
|
||||
if (_fd != -1)
|
||||
{
|
||||
sync();
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
|
||||
{
|
||||
if (_fd == -1 || !(getMode() & mode))
|
||||
return -1;
|
||||
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
std::streamoff adj;
|
||||
if (mode & std::ios::in)
|
||||
adj = static_cast<std::streamoff>(egptr() - gptr());
|
||||
else
|
||||
adj = 0;
|
||||
|
||||
resetBuffers();
|
||||
|
||||
int whence = SEEK_SET;
|
||||
if (dir == std::ios::cur)
|
||||
{
|
||||
whence = SEEK_CUR;
|
||||
off -= adj;
|
||||
}
|
||||
else if (dir == std::ios::end)
|
||||
{
|
||||
whence = SEEK_END;
|
||||
}
|
||||
_pos = lseek(_fd, off, whence);
|
||||
return _pos;
|
||||
}
|
||||
|
||||
|
||||
std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
|
||||
{
|
||||
if (_fd == -1 || !(getMode() & mode))
|
||||
return -1;
|
||||
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
resetBuffers();
|
||||
|
||||
_pos = lseek(_fd, pos, SEEK_SET);
|
||||
return _pos;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
223
Foundation/src/FileStream_WIN32.cpp
Normal file
223
Foundation/src/FileStream_WIN32.cpp
Normal file
@ -0,0 +1,223 @@
|
||||
//
|
||||
// FileStream.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/FileStream_WIN32.cpp#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
// Module: FileStream
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/Exception.h"
|
||||
#if defined (POCO_WIN32_UTF8)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
FileStreamBuf::FileStreamBuf():
|
||||
BufferedBidirectionalStreamBuf(BUFFER_SIZE, 0),
|
||||
_handle(INVALID_HANDLE_VALUE),
|
||||
_pos(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileStreamBuf::~FileStreamBuf()
|
||||
{
|
||||
try
|
||||
{
|
||||
close();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FileStreamBuf::open(const std::string& path, std::ios::openmode mode)
|
||||
{
|
||||
poco_assert (_handle == INVALID_HANDLE_VALUE);
|
||||
|
||||
_path = path;
|
||||
setMode(mode);
|
||||
|
||||
DWORD access = 0;
|
||||
if (mode & std::ios::in)
|
||||
access |= GENERIC_READ;
|
||||
if (mode & std::ios::out)
|
||||
access |= GENERIC_WRITE;
|
||||
|
||||
DWORD shareMode = FILE_SHARE_READ;
|
||||
DWORD creationDisp = OPEN_EXISTING;
|
||||
if (mode & std::ios::trunc)
|
||||
creationDisp = CREATE_ALWAYS;
|
||||
else if (mode & std::ios::out)
|
||||
creationDisp = OPEN_ALWAYS;
|
||||
|
||||
DWORD flags = FILE_ATTRIBUTE_NORMAL;
|
||||
|
||||
#if defined (POCO_WIN32_UTF8)
|
||||
std::wstring utf16Path;
|
||||
UnicodeConverter::toUTF16(path, utf16Path);
|
||||
_handle = CreateFileW(utf16Path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
|
||||
#else
|
||||
_handle = CreateFileA(path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL);
|
||||
#endif
|
||||
|
||||
if (_handle == INVALID_HANDLE_VALUE)
|
||||
File::handleLastError(_path);
|
||||
|
||||
if ((mode & std::ios::ate) || (mode & std::ios::app))
|
||||
seekoff(0, std::ios::end, mode);
|
||||
}
|
||||
|
||||
|
||||
int FileStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
{
|
||||
if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::in))
|
||||
return -1;
|
||||
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
DWORD bytesRead(0);
|
||||
BOOL rc = ReadFile(_handle, buffer, length, &bytesRead, NULL);
|
||||
if (rc == 0)
|
||||
File::handleLastError(_path);
|
||||
|
||||
_pos += bytesRead;
|
||||
|
||||
return static_cast<int>(bytesRead);
|
||||
}
|
||||
|
||||
|
||||
int FileStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
|
||||
{
|
||||
if (INVALID_HANDLE_VALUE == _handle || !(getMode() & std::ios::out))
|
||||
return -1;
|
||||
|
||||
if (getMode() & std::ios::app)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = 0;
|
||||
li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, FILE_END);
|
||||
if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
|
||||
File::handleLastError(_path);
|
||||
_pos = li.QuadPart;
|
||||
}
|
||||
|
||||
DWORD bytesWritten(0);
|
||||
BOOL rc = WriteFile(_handle, buffer, length, &bytesWritten, NULL);
|
||||
if (rc == 0)
|
||||
File::handleLastError(_path);
|
||||
|
||||
_pos += bytesWritten;
|
||||
|
||||
return static_cast<int>(bytesWritten);
|
||||
}
|
||||
|
||||
|
||||
void FileStreamBuf::close()
|
||||
{
|
||||
if (_handle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
CloseHandle(_handle);
|
||||
_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
|
||||
{
|
||||
if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
|
||||
return -1;
|
||||
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
std::streamoff adj;
|
||||
if (mode & std::ios::in)
|
||||
adj = static_cast<std::streamoff>(egptr() - gptr());
|
||||
else
|
||||
adj = 0;
|
||||
|
||||
resetBuffers();
|
||||
|
||||
DWORD offset = FILE_BEGIN;
|
||||
if (dir == std::ios::cur)
|
||||
{
|
||||
offset = FILE_CURRENT;
|
||||
off -= adj;
|
||||
}
|
||||
else if (dir == std::ios::end)
|
||||
{
|
||||
offset = FILE_END;
|
||||
}
|
||||
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = off;
|
||||
li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, offset);
|
||||
|
||||
if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
|
||||
File::handleLastError(_path);
|
||||
_pos = li.QuadPart;
|
||||
return std::streampos(static_cast<std::streamoff>(_pos));
|
||||
}
|
||||
|
||||
|
||||
std::streampos FileStreamBuf::seekpos(std::streampos pos, std::ios::openmode mode)
|
||||
{
|
||||
if (INVALID_HANDLE_VALUE == _handle || !(getMode() & mode))
|
||||
return -1;
|
||||
|
||||
if (getMode() & std::ios::out)
|
||||
sync();
|
||||
|
||||
resetBuffers();
|
||||
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = pos;
|
||||
li.LowPart = SetFilePointer(_handle, li.LowPart, &li.HighPart, FILE_BEGIN);
|
||||
|
||||
if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
|
||||
File::handleLastError(_path);
|
||||
_pos = li.QuadPart;
|
||||
return std::streampos(static_cast<std::streamoff>(_pos));
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_UNIX.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/File_UNIX.cpp#16 $
|
||||
// $Id: //poco/Main/Foundation/src/File_UNIX.cpp#19 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -107,7 +107,7 @@ bool FileImpl::canReadImpl() const
|
||||
else
|
||||
return (st.st_mode & S_IROTH) != 0;
|
||||
}
|
||||
else handleError(_path);
|
||||
else handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -126,7 +126,26 @@ bool FileImpl::canWriteImpl() const
|
||||
else
|
||||
return (st.st_mode & S_IWOTH) != 0;
|
||||
}
|
||||
else handleError(_path);
|
||||
else handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::canExecuteImpl() const
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
struct stat st;
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
{
|
||||
if (st.st_uid == geteuid())
|
||||
return (st.st_mode & S_IXUSR) != 0;
|
||||
else if (st.st_gid == getegid())
|
||||
return (st.st_mode & S_IXGRP) != 0;
|
||||
else
|
||||
return (st.st_mode & S_IXOTH) != 0;
|
||||
}
|
||||
else handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -139,7 +158,7 @@ bool FileImpl::isFileImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return S_ISREG(st.st_mode);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -152,7 +171,7 @@ bool FileImpl::isDirectoryImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return S_ISDIR(st.st_mode);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -165,7 +184,7 @@ bool FileImpl::isLinkImpl() const
|
||||
if (lstat(_path.c_str(), &st) == 0)
|
||||
return S_ISLNK(st.st_mode);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -178,7 +197,7 @@ Timestamp FileImpl::createdImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return Timestamp::fromEpochTime(st.st_mtime);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -191,7 +210,7 @@ Timestamp FileImpl::getLastModifiedImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return Timestamp::fromEpochTime(st.st_mtime);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -204,7 +223,7 @@ void FileImpl::setLastModifiedImpl(const Timestamp& ts)
|
||||
tb.actime = ts.epochTime();
|
||||
tb.modtime = ts.epochTime();
|
||||
if (utime(_path.c_str(), &tb) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +235,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return st.st_size;
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -226,7 +245,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (truncate(_path.c_str(), size) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +255,7 @@ void FileImpl::setWriteableImpl(bool flag)
|
||||
|
||||
struct stat st;
|
||||
if (stat(_path.c_str(), &st) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
mode_t mode;
|
||||
if (flag)
|
||||
{
|
||||
@ -248,7 +267,29 @@ void FileImpl::setWriteableImpl(bool flag)
|
||||
mode = st.st_mode & ~wmask;
|
||||
}
|
||||
if (chmod(_path.c_str(), mode) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::setExecutableImpl(bool flag)
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
struct stat st;
|
||||
if (stat(_path.c_str(), &st) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
mode_t mode;
|
||||
if (flag)
|
||||
{
|
||||
mode = st.st_mode | S_IXUSR;
|
||||
}
|
||||
else
|
||||
{
|
||||
mode_t wmask = S_IXUSR | S_IXGRP | S_IXOTH;
|
||||
mode = st.st_mode & ~wmask;
|
||||
}
|
||||
if (chmod(_path.c_str(), mode) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -257,13 +298,13 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
int sd = open(_path.c_str(), O_RDONLY);
|
||||
if (sd == -1) handleError(_path);
|
||||
if (sd == -1) handleLastErrorImpl(_path);
|
||||
|
||||
struct stat st;
|
||||
if (fstat(sd, &st) != 0)
|
||||
{
|
||||
close(sd);
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
const long blockSize = st.st_blksize;
|
||||
|
||||
@ -271,7 +312,7 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
if (dd == -1)
|
||||
{
|
||||
close(sd);
|
||||
handleError(path);
|
||||
handleLastErrorImpl(path);
|
||||
}
|
||||
Buffer<char> buffer(blockSize);
|
||||
try
|
||||
@ -280,10 +321,10 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
while ((n = read(sd, buffer.begin(), blockSize)) > 0)
|
||||
{
|
||||
if (write(dd, buffer.begin(), n) != n)
|
||||
handleError(path);
|
||||
handleLastErrorImpl(path);
|
||||
}
|
||||
if (n < 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -295,10 +336,10 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
if (fsync(dd) != 0)
|
||||
{
|
||||
close(dd);
|
||||
handleError(path);
|
||||
handleLastErrorImpl(path);
|
||||
}
|
||||
if (close(dd) != 0)
|
||||
handleError(path);
|
||||
handleLastErrorImpl(path);
|
||||
}
|
||||
|
||||
|
||||
@ -307,7 +348,7 @@ void FileImpl::renameToImpl(const std::string& path)
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (rename(_path.c_str(), path.c_str()) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -320,7 +361,7 @@ void FileImpl::removeImpl()
|
||||
rc = rmdir(_path.c_str());
|
||||
else
|
||||
rc = unlink(_path.c_str());
|
||||
if (rc) handleError(_path);
|
||||
if (rc) handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -337,7 +378,7 @@ bool FileImpl::createFileImpl()
|
||||
if (n == -1 && errno == EEXIST)
|
||||
return false;
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -349,12 +390,12 @@ bool FileImpl::createDirectoryImpl()
|
||||
if (existsImpl() && isDirectoryImpl())
|
||||
return false;
|
||||
if (mkdir(_path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleError(const std::string& path)
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
@ -382,6 +423,9 @@ void FileImpl::handleError(const std::string& path)
|
||||
throw FileException("directory not empty", path);
|
||||
case ENAMETOOLONG:
|
||||
throw PathSyntaxException(path);
|
||||
case ENFILE:
|
||||
case EMFILE:
|
||||
throw FileException("too many open files", path);
|
||||
default:
|
||||
throw FileException(strerror(errno), path);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_VMS.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/File_VMS.cpp#13 $
|
||||
// $Id: //poco/Main/Foundation/src/File_VMS.cpp#15 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -37,6 +37,7 @@
|
||||
#include "Poco/File_VMS.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/String.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <unixio.h>
|
||||
@ -110,7 +111,7 @@ bool FileImpl::canReadImpl() const
|
||||
else
|
||||
return (st.st_mode & S_IROTH) != 0;
|
||||
}
|
||||
else handleError(_path);
|
||||
else handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -129,11 +130,18 @@ bool FileImpl::canWriteImpl() const
|
||||
else
|
||||
return (st.st_mode & S_IWOTH) != 0;
|
||||
}
|
||||
else handleError(_path);
|
||||
else handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::canExecuteImpl() const
|
||||
{
|
||||
Path p(_path);
|
||||
return icompare(p.getExtension(), "exe") == 0;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::isFileImpl() const
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
@ -142,7 +150,7 @@ bool FileImpl::isFileImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return S_ISREG(st.st_mode);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -155,7 +163,7 @@ bool FileImpl::isDirectoryImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return S_ISDIR(st.st_mode);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -174,7 +182,7 @@ Timestamp FileImpl::createdImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return Timestamp(st.st_mtime);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -187,7 +195,7 @@ Timestamp FileImpl::getLastModifiedImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return Timestamp(st.st_mtime);
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -200,7 +208,7 @@ void FileImpl::setLastModifiedImpl(const Timestamp& ts)
|
||||
tb.actime = ts.epochTime();
|
||||
tb.modtime = ts.epochTime();
|
||||
if (utime(_path.c_str(), &tb) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -212,7 +220,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
|
||||
if (stat(_path.c_str(), &st) == 0)
|
||||
return st.st_size;
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -222,7 +230,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (truncate(_path.c_str(), size) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -232,7 +240,7 @@ void FileImpl::setWriteableImpl(bool flag)
|
||||
|
||||
struct stat st;
|
||||
if (stat(_path.c_str(), &st) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
mode_t mode;
|
||||
if (flag)
|
||||
{
|
||||
@ -244,7 +252,13 @@ void FileImpl::setWriteableImpl(bool flag)
|
||||
mode = st.st_mode & ~wmask;
|
||||
}
|
||||
if (chmod(_path.c_str(), mode) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::setExecutableImpl(bool flag)
|
||||
{
|
||||
// not supported
|
||||
}
|
||||
|
||||
|
||||
@ -307,7 +321,7 @@ void FileImpl::removeImpl()
|
||||
{
|
||||
rc = unlink(_path.c_str());
|
||||
}
|
||||
if (rc) handleError(_path);
|
||||
if (rc) handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -325,7 +339,7 @@ bool FileImpl::createFileImpl()
|
||||
if (n == -1 && errno == EEXIST)
|
||||
return false;
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -339,12 +353,12 @@ bool FileImpl::createDirectoryImpl()
|
||||
Path p(_path);
|
||||
p.makeDirectory();
|
||||
if (mkdir(p.toString().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleError(const std::string& path)
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_WIN32.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/File_WIN32.cpp#14 $
|
||||
// $Id: //poco/Main/Foundation/src/File_WIN32.cpp#16 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -36,6 +36,7 @@
|
||||
|
||||
#include "Poco/File_WIN32.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/String.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
@ -48,7 +49,7 @@ public:
|
||||
FileHandle(const std::string& path, DWORD access, DWORD share, DWORD disp)
|
||||
{
|
||||
_h = CreateFile(path.c_str(), access, share, 0, disp, 0, 0);
|
||||
if (!_h) FileImpl::handleError(path);
|
||||
if (!_h) FileImpl::handleLastErrorImpl(path);
|
||||
}
|
||||
|
||||
~FileHandle()
|
||||
@ -118,7 +119,7 @@ bool FileImpl::existsImpl() const
|
||||
case ERROR_INVALID_DRIVE:
|
||||
return false;
|
||||
default:
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -137,7 +138,7 @@ bool FileImpl::canReadImpl() const
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return false;
|
||||
default:
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -150,18 +151,25 @@ bool FileImpl::canWriteImpl() const
|
||||
|
||||
DWORD attr = GetFileAttributes(_path.c_str());
|
||||
if (attr == 0xFFFFFFFF)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::canExecuteImpl() const
|
||||
{
|
||||
Path p(_path);
|
||||
return icompare(p.getExtension(), "exe") == 0;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::isFileImpl() const
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
DWORD attr = GetFileAttributes(_path.c_str());
|
||||
if (attr == 0xFFFFFFFF)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0;
|
||||
}
|
||||
|
||||
@ -172,7 +180,7 @@ bool FileImpl::isDirectoryImpl() const
|
||||
|
||||
DWORD attr = GetFileAttributes(_path.c_str());
|
||||
if (attr == 0xFFFFFFFF)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
@ -189,7 +197,7 @@ Timestamp FileImpl::createdImpl() const
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
|
||||
}
|
||||
|
||||
@ -200,7 +208,7 @@ Timestamp FileImpl::getLastModifiedImpl() const
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
|
||||
}
|
||||
|
||||
@ -217,7 +225,7 @@ void FileImpl::setLastModifiedImpl(const Timestamp& ts)
|
||||
ft.dwHighDateTime = high;
|
||||
FileHandle fh(_path, FILE_ALL_ACCESS, FILE_SHARE_WRITE, OPEN_EXISTING);
|
||||
if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -227,7 +235,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (GetFileAttributesEx(_path.c_str(), GetFileExInfoStandard, &fad) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = fad.nFileSizeLow;
|
||||
li.HighPart = fad.nFileSizeHigh;
|
||||
@ -243,9 +251,9 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = size;
|
||||
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == -1)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
if (SetEndOfFile(fh.get()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -255,13 +263,19 @@ void FileImpl::setWriteableImpl(bool flag)
|
||||
|
||||
DWORD attr = GetFileAttributes(_path.c_str());
|
||||
if (attr == -1)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
if (flag)
|
||||
attr &= ~FILE_ATTRIBUTE_READONLY;
|
||||
else
|
||||
attr |= FILE_ATTRIBUTE_READONLY;
|
||||
if (SetFileAttributes(_path.c_str(), attr) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::setExecutableImpl(bool flag)
|
||||
{
|
||||
// not supported
|
||||
}
|
||||
|
||||
|
||||
@ -270,7 +284,7 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (CopyFile(_path.c_str(), path.c_str(), FALSE) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -279,7 +293,7 @@ void FileImpl::renameToImpl(const std::string& path)
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
if (MoveFile(_path.c_str(), path.c_str()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -290,12 +304,12 @@ void FileImpl::removeImpl()
|
||||
if (isDirectoryImpl())
|
||||
{
|
||||
if (RemoveDirectory(_path.c_str()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DeleteFile(_path.c_str()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +327,7 @@ bool FileImpl::createFileImpl()
|
||||
else if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
return false;
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -325,12 +339,12 @@ bool FileImpl::createDirectoryImpl()
|
||||
if (existsImpl() && isDirectoryImpl())
|
||||
return false;
|
||||
if (CreateDirectory(_path.c_str(), 0) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleError(const std::string& path)
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (GetLastError())
|
||||
{
|
||||
@ -357,6 +371,21 @@ void FileImpl::handleError(const std::string& path)
|
||||
throw CreateFileException(path);
|
||||
case ERROR_DIR_NOT_EMPTY:
|
||||
throw FileException("directory not empty", path);
|
||||
case ERROR_WRITE_FAULT:
|
||||
throw WriteFileException(path);
|
||||
case ERROR_READ_FAULT:
|
||||
throw ReadFileException(path);
|
||||
case ERROR_SHARING_VIOLATION:
|
||||
throw FileException("sharing violation", path);
|
||||
case ERROR_LOCK_VIOLATION:
|
||||
throw FileException("lock violation", path);
|
||||
case ERROR_HANDLE_EOF:
|
||||
throw ReadFileException("EOF reached", path);
|
||||
case ERROR_HANDLE_DISK_FULL:
|
||||
case ERROR_DISK_FULL:
|
||||
throw WriteFileException("disk is full", path);
|
||||
case ERROR_NEGATIVE_SEEK:
|
||||
throw FileException("negative seek", path);
|
||||
default:
|
||||
throw FileException(path);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// File_WIN32U.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/File_WIN32U.cpp#8 $
|
||||
// $Id: //poco/Main/Foundation/src/File_WIN32U.cpp#10 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@ -36,6 +36,7 @@
|
||||
|
||||
#include "Poco/File_WIN32U.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#include <windows.h>
|
||||
|
||||
@ -49,7 +50,7 @@ public:
|
||||
FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
|
||||
{
|
||||
_h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
|
||||
if (!_h) FileImpl::handleError(path);
|
||||
if (!_h) FileImpl::handleLastErrorImpl(path);
|
||||
}
|
||||
|
||||
~FileHandle()
|
||||
@ -122,7 +123,7 @@ bool FileImpl::existsImpl() const
|
||||
case ERROR_INVALID_DRIVE:
|
||||
return false;
|
||||
default:
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -141,7 +142,7 @@ bool FileImpl::canReadImpl() const
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return false;
|
||||
default:
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -154,18 +155,25 @@ bool FileImpl::canWriteImpl() const
|
||||
|
||||
DWORD attr = GetFileAttributesW(_upath.c_str());
|
||||
if (attr == 0xFFFFFFFF)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_READONLY) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::canExecuteImpl() const
|
||||
{
|
||||
Path p(_path);
|
||||
return icompare(p.getExtension(), "exe") == 0;
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::isFileImpl() const
|
||||
{
|
||||
poco_assert (!_path.empty());
|
||||
|
||||
DWORD attr = GetFileAttributesW(_upath.c_str());
|
||||
if (attr == 0xFFFFFFFF)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY) == 0;
|
||||
}
|
||||
|
||||
@ -176,7 +184,7 @@ bool FileImpl::isDirectoryImpl() const
|
||||
|
||||
DWORD attr = GetFileAttributesW(_upath.c_str());
|
||||
if (attr == 0xFFFFFFFF)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
@ -193,7 +201,7 @@ Timestamp FileImpl::createdImpl() const
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return Timestamp::fromFileTimeNP(fad.ftCreationTime.dwLowDateTime, fad.ftCreationTime.dwHighDateTime);
|
||||
}
|
||||
|
||||
@ -204,7 +212,7 @@ Timestamp FileImpl::getLastModifiedImpl() const
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return Timestamp::fromFileTimeNP(fad.ftLastWriteTime.dwLowDateTime, fad.ftLastWriteTime.dwHighDateTime);
|
||||
}
|
||||
|
||||
@ -221,7 +229,7 @@ void FileImpl::setLastModifiedImpl(const Timestamp& ts)
|
||||
ft.dwHighDateTime = high;
|
||||
FileHandle fh(_path, _upath, FILE_ALL_ACCESS, FILE_SHARE_WRITE, OPEN_EXISTING);
|
||||
if (SetFileTime(fh.get(), 0, &ft, &ft) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -231,7 +239,7 @@ FileImpl::FileSizeImpl FileImpl::getSizeImpl() const
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
if (GetFileAttributesExW(_upath.c_str(), GetFileExInfoStandard, &fad) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = fad.nFileSizeLow;
|
||||
li.HighPart = fad.nFileSizeHigh;
|
||||
@ -247,9 +255,9 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
|
||||
LARGE_INTEGER li;
|
||||
li.QuadPart = size;
|
||||
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == -1)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
if (SetEndOfFile(fh.get()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -259,13 +267,19 @@ void FileImpl::setWriteableImpl(bool flag)
|
||||
|
||||
DWORD attr = GetFileAttributesW(_upath.c_str());
|
||||
if (attr == -1)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
if (flag)
|
||||
attr &= ~FILE_ATTRIBUTE_READONLY;
|
||||
else
|
||||
attr |= FILE_ATTRIBUTE_READONLY;
|
||||
if (SetFileAttributesW(_upath.c_str(), attr) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::setExecutableImpl(bool flag)
|
||||
{
|
||||
// not supported
|
||||
}
|
||||
|
||||
|
||||
@ -276,7 +290,7 @@ void FileImpl::copyToImpl(const std::string& path) const
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -287,7 +301,7 @@ void FileImpl::renameToImpl(const std::string& path)
|
||||
std::wstring upath;
|
||||
UnicodeConverter::toUTF16(path, upath);
|
||||
if (MoveFileW(_upath.c_str(), upath.c_str()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
|
||||
|
||||
@ -298,12 +312,12 @@ void FileImpl::removeImpl()
|
||||
if (isDirectoryImpl())
|
||||
{
|
||||
if (RemoveDirectoryW(_upath.c_str()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DeleteFileW(_upath.c_str()) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,7 +335,7 @@ bool FileImpl::createFileImpl()
|
||||
else if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
return false;
|
||||
else
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -333,12 +347,12 @@ bool FileImpl::createDirectoryImpl()
|
||||
if (existsImpl() && isDirectoryImpl())
|
||||
return false;
|
||||
if (CreateDirectoryW(_upath.c_str(), 0) == 0)
|
||||
handleError(_path);
|
||||
handleLastErrorImpl(_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleError(const std::string& path)
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (GetLastError())
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Format.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/Format.cpp#6 $
|
||||
// $Id: //poco/Main/Foundation/src/Format.cpp#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -66,10 +66,10 @@ namespace
|
||||
{
|
||||
switch (*itFmt)
|
||||
{
|
||||
case '-': str.setf(std::ios_base::left); ++itFmt; break;
|
||||
case '+': str.setf(std::ios_base::showpos); ++itFmt; break;
|
||||
case '-': str.setf(std::ios::left); ++itFmt; break;
|
||||
case '+': str.setf(std::ios::showpos); ++itFmt; break;
|
||||
case '0': str.fill('0'); ++itFmt; break;
|
||||
case '#': str.setf(std::ios_base::showpoint | std::ios_base::showbase); ++itFmt; break;
|
||||
case '#': str.setf(std::ios::showpoint | std::ios_base::showbase); ++itFmt; break;
|
||||
default: isFlag = false; break;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HexBinaryEncoder.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/HexBinaryEncoder.cpp#14 $
|
||||
// $Id: //poco/Main/Foundation/src/HexBinaryEncoder.cpp#15 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -63,8 +63,6 @@ HexBinaryEncoderBuf::~HexBinaryEncoderBuf()
|
||||
|
||||
void HexBinaryEncoderBuf::setLineLength(int lineLength)
|
||||
{
|
||||
poco_assert (lineLength > 0);
|
||||
|
||||
_lineLength = lineLength;
|
||||
}
|
||||
|
||||
@ -87,7 +85,7 @@ int HexBinaryEncoderBuf::writeToDevice(char c)
|
||||
_ostr.put(digits[_uppercase + ((c >> 4) & 0xF)]);
|
||||
++_pos;
|
||||
_ostr.put(digits[_uppercase + (c & 0xF)]);
|
||||
if (++_pos >= _lineLength)
|
||||
if (++_pos >= _lineLength && _lineLength > 0)
|
||||
{
|
||||
_ostr << std::endl;
|
||||
_pos = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// InflatingStream.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/InflatingStream.cpp#13 $
|
||||
// $Id: //poco/Main/Foundation/src/InflatingStream.cpp#15 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Streams
|
||||
@ -45,7 +45,8 @@ InflatingStreamBuf::InflatingStreamBuf(std::istream& istr, StreamType type):
|
||||
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in),
|
||||
_pIstr(&istr),
|
||||
_pOstr(0),
|
||||
_eof(false)
|
||||
_eof(false),
|
||||
_check(type != STREAM_ZIP)
|
||||
{
|
||||
_zstr.zalloc = Z_NULL;
|
||||
_zstr.zfree = Z_NULL;
|
||||
@ -66,7 +67,8 @@ InflatingStreamBuf::InflatingStreamBuf(std::ostream& ostr, StreamType type):
|
||||
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::out),
|
||||
_pIstr(0),
|
||||
_pOstr(&ostr),
|
||||
_eof(false)
|
||||
_eof(false),
|
||||
_check(type != STREAM_ZIP)
|
||||
{
|
||||
_zstr.zalloc = Z_NULL;
|
||||
_zstr.zfree = Z_NULL;
|
||||
@ -131,6 +133,16 @@ int InflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
||||
for (;;)
|
||||
{
|
||||
int rc = inflate(&_zstr, Z_NO_FLUSH);
|
||||
if (rc == Z_DATA_ERROR && !_check)
|
||||
{
|
||||
if (_zstr.avail_in == 0)
|
||||
{
|
||||
if (_pIstr->good())
|
||||
rc = Z_OK;
|
||||
else
|
||||
rc = Z_STREAM_END;
|
||||
}
|
||||
}
|
||||
if (rc == Z_STREAM_END)
|
||||
{
|
||||
_eof = true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LocalDateTime.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/LocalDateTime.cpp#11 $
|
||||
// $Id: //poco/Main/Foundation/src/LocalDateTime.cpp#12 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: DateTime
|
||||
@ -96,6 +96,15 @@ LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime):
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime, bool adjust):
|
||||
_dateTime(dateTime),
|
||||
_tzd(tzd)
|
||||
{
|
||||
if (adjust)
|
||||
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime::LocalDateTime(const LocalDateTime& dateTime):
|
||||
_dateTime(dateTime._dateTime),
|
||||
_tzd(dateTime._tzd)
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LogFile_STD.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/LogFile_STD.cpp#8 $
|
||||
// $Id: //poco/Main/Foundation/src/LogFile_STD.cpp#10 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -42,10 +42,10 @@
|
||||
namespace Poco {
|
||||
|
||||
|
||||
LogFileImpl::LogFileImpl(const std::string& path): _path(path)
|
||||
LogFileImpl::LogFileImpl(const std::string& path):
|
||||
_path(path),
|
||||
_str(_path, std::ios::app)
|
||||
{
|
||||
_str.open(path.c_str(), std::ios::app | std::ios::ate);
|
||||
if (!_str.good()) throw OpenFileException(path);
|
||||
if (sizeImpl() == 0)
|
||||
_creationDate = File(path).getLastModified();
|
||||
else
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Mutex_WIN32.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/Mutex_WIN32.cpp#12 $
|
||||
// $Id: //poco/Main/Foundation/src/Mutex_WIN32.cpp#13 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@ -42,8 +42,9 @@ namespace Poco {
|
||||
|
||||
MutexImpl::MutexImpl()
|
||||
{
|
||||
if (!InitializeCriticalSectionAndSpinCount(&_cs, 4000))
|
||||
throw SystemException("cannot create mutex");
|
||||
// the fct has a boolean return value under WInnNt/2000/XP but not on Win98
|
||||
// the return only checks if the input address of &_cs was valid, so it is safe to omit it
|
||||
InitializeCriticalSectionAndSpinCount(&_cs, 4000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// NumberParser.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/NumberParser.cpp#10 $
|
||||
// $Id: //poco/Main/Foundation/src/NumberParser.cpp#11 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -64,7 +64,8 @@ int NumberParser::parse(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParse(const std::string& s, int& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%d", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%d%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +81,8 @@ unsigned NumberParser::parseUnsigned(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseUnsigned(const std::string& s, unsigned& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%u", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%u%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +98,8 @@ unsigned NumberParser::parseHex(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseHex(const std::string& s, unsigned& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%x", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%x%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +118,8 @@ Int64 NumberParser::parse64(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParse64(const std::string& s, Int64& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%"I64_FMT"d", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%"I64_FMT"d%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
@ -131,7 +135,8 @@ UInt64 NumberParser::parseUnsigned64(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseUnsigned64(const std::string& s, UInt64& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%"I64_FMT"u", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%"I64_FMT"u%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
@ -147,7 +152,8 @@ UInt64 NumberParser::parseHex64(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseHex64(const std::string& s, UInt64& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%"I64_FMT"x", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%"I64_FMT"x%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +172,8 @@ double NumberParser::parseFloat(const std::string& s)
|
||||
|
||||
bool NumberParser::tryParseFloat(const std::string& s, double& value)
|
||||
{
|
||||
return sscanf(s.c_str(), "%lf", &value) == 1;
|
||||
char temp;
|
||||
return sscanf(s.c_str(), "%lf%c", &value, &temp) == 1;
|
||||
}
|
||||
|
||||
|
||||
|
110
Foundation/src/SharedMemory.cpp
Normal file
110
Foundation/src/SharedMemory.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
//
|
||||
// SharedMemory.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory.cpp#4 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemory
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/SharedMemory.h"
|
||||
#include "Poco/Exception.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "SharedMemory_WIN32.cpp"
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
#include "SharedMemory_POSIX.cpp"
|
||||
#else
|
||||
#include "SharedMemory_DUMMY.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemory::SharedMemory():
|
||||
_pImpl(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SharedMemory::SharedMemory(const std::string& name, std::size_t size, AccessMode mode, const void* addrHint):
|
||||
_pImpl(new SharedMemoryImpl(name, size, mode, addrHint))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SharedMemory::SharedMemory(const Poco::File& file, AccessMode mode, const void* addrHint):
|
||||
_pImpl(new SharedMemoryImpl(file, mode, addrHint))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SharedMemory::SharedMemory(const SharedMemory& other):
|
||||
_pImpl(other._pImpl)
|
||||
{
|
||||
if (_pImpl)
|
||||
_pImpl->duplicate();
|
||||
}
|
||||
|
||||
|
||||
SharedMemory::~SharedMemory()
|
||||
{
|
||||
if (_pImpl)
|
||||
_pImpl->release();
|
||||
}
|
||||
|
||||
|
||||
SharedMemory& SharedMemory::operator = (const SharedMemory& other)
|
||||
{
|
||||
SharedMemory tmp(other);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
char* SharedMemory::begin() const
|
||||
{
|
||||
if (_pImpl)
|
||||
return _pImpl->begin();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char* SharedMemory::end() const
|
||||
{
|
||||
if (_pImpl)
|
||||
return _pImpl->end();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
58
Foundation/src/SharedMemory_DUMMY.cpp
Normal file
58
Foundation/src/SharedMemory_DUMMY.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
//
|
||||
// SharedMemoryImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_DUMMY.cpp#2 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemoryImpl
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/SharedMemory_DUMMY.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string&, std::size_t, SharedMemory::AccessMode, const void*)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const Poco::File&, SharedMemory::AccessMode, const void*)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryImpl::~SharedMemoryImpl()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
150
Foundation/src/SharedMemory_POSIX.cpp
Normal file
150
Foundation/src/SharedMemory_POSIX.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
//
|
||||
// SharedMemoryImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_POSIX.cpp#7 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemoryImpl
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/SharedMemory_POSIX.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/File.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void* addrHint):
|
||||
_size(size),
|
||||
_fd(-1),
|
||||
_address(0),
|
||||
_access(mode),
|
||||
_name("/"),
|
||||
_fileMapped(false)
|
||||
{
|
||||
_name.append(name);
|
||||
|
||||
int flags = O_CREAT;
|
||||
if (_access == SharedMemory::AM_WRITE)
|
||||
flags |= O_RDWR;
|
||||
else
|
||||
flags |= O_RDONLY;
|
||||
|
||||
// open the shared memory segment
|
||||
_fd = ::shm_open(_name.c_str(), flags, S_IRUSR | S_IWUSR);
|
||||
if (_fd == -1)
|
||||
throw SystemException("Cannot create shared memory object", _name);
|
||||
|
||||
// now set the correct size for the segment
|
||||
if (-1 == ::ftruncate(_fd, size))
|
||||
{
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
::shm_unlink(_name.c_str());
|
||||
throw SystemException("Cannot resize shared memory object", _name);
|
||||
}
|
||||
map(addrHint);
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void* addrHint):
|
||||
_size(0),
|
||||
_fd(-1),
|
||||
_address(0),
|
||||
_access(mode),
|
||||
_name(file.path()),
|
||||
_fileMapped(true)
|
||||
{
|
||||
if (!file.exists() || !file.isFile())
|
||||
throw FileNotFoundException(file.path());
|
||||
|
||||
_size = file.getSize();
|
||||
int flag = O_RDONLY;
|
||||
if (mode == SharedMemory::AM_WRITE)
|
||||
flag = O_RDWR;
|
||||
_fd = ::open(_name.c_str(), flag);
|
||||
if (-1 == _fd)
|
||||
throw OpenFileException("Cannot open memory mapped file", _name);
|
||||
|
||||
map(addrHint);
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryImpl::~SharedMemoryImpl()
|
||||
{
|
||||
unmap();
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryImpl::map(const void* addrHint)
|
||||
{
|
||||
int access = PROT_READ;
|
||||
if (_access == SharedMemory::AM_WRITE)
|
||||
access |= PROT_WRITE;
|
||||
|
||||
void* addr = ::mmap(const_cast<void*>(addrHint), _size, access, MAP_SHARED, _fd, 0);
|
||||
if (addr == MAP_FAILED)
|
||||
throw SystemException("Cannot map file into shared memory", _name);
|
||||
|
||||
_address = static_cast<char*>(addr);
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryImpl::unmap()
|
||||
{
|
||||
if (_address)
|
||||
{
|
||||
::munmap(_address, _size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryImpl::close()
|
||||
{
|
||||
if (_fd != -1)
|
||||
{
|
||||
::close(_fd);
|
||||
_fd = -1;
|
||||
}
|
||||
if (!_fileMapped)
|
||||
{
|
||||
::shm_unlink(_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
166
Foundation/src/SharedMemory_WIN32.cpp
Normal file
166
Foundation/src/SharedMemory_WIN32.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
//
|
||||
// SharedMemoryImpl.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/SharedMemory_WIN32.cpp#4 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Processes
|
||||
// Module: SharedMemoryImpl
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/SharedMemory_WIN32.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/File.h"
|
||||
#if defined (POCO_WIN32_UTF8)
|
||||
#include "Poco/UnicodeConverter.h"
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, SharedMemory::AccessMode mode, const void*):
|
||||
_name(name),
|
||||
_memHandle(INVALID_HANDLE_VALUE),
|
||||
_fileHandle(INVALID_HANDLE_VALUE),
|
||||
_size(static_cast<DWORD>(size)),
|
||||
_mode(PAGE_READONLY),
|
||||
_address(0)
|
||||
{
|
||||
if (mode == SharedMemory::AM_WRITE)
|
||||
_mode = PAGE_READWRITE;
|
||||
|
||||
#if defined (POCO_WIN32_UTF8)
|
||||
std::wstring utf16name;
|
||||
UnicodeConverter::toUTF16(_name, utf16name);
|
||||
_memHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, utf16name.c_str());
|
||||
#else
|
||||
_memHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, _name.c_str());
|
||||
#endif
|
||||
|
||||
if (!_memHandle)
|
||||
throw SystemException("Cannot create shared memory object", _name);
|
||||
|
||||
map();
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessMode mode, const void*):
|
||||
_name(file.path()),
|
||||
_memHandle(INVALID_HANDLE_VALUE),
|
||||
_fileHandle(INVALID_HANDLE_VALUE),
|
||||
_size(0),
|
||||
_mode(PAGE_READONLY),
|
||||
_address(0)
|
||||
{
|
||||
if (!file.exists() || !file.isFile())
|
||||
throw FileNotFoundException(_name);
|
||||
|
||||
_size = static_cast<DWORD>(file.getSize());
|
||||
|
||||
DWORD shareMode = FILE_SHARE_READ;
|
||||
DWORD fileMode = GENERIC_READ;
|
||||
|
||||
if (mode == SharedMemory::AM_WRITE)
|
||||
{
|
||||
_mode = PAGE_READWRITE;
|
||||
fileMode |= GENERIC_WRITE;
|
||||
}
|
||||
|
||||
#if defined (POCO_WIN32_UTF8)
|
||||
std::wstring utf16name;
|
||||
UnicodeConverter::toUTF16(_name, utf16name);
|
||||
_fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#else
|
||||
_fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
#endif
|
||||
|
||||
if (_fileHandle == INVALID_HANDLE_VALUE)
|
||||
throw OpenFileException("Cannot open memory mapped file", _name);
|
||||
|
||||
_memHandle = CreateFileMapping(_fileHandle, NULL, _mode, 0, 0, NULL);
|
||||
if (!_memHandle)
|
||||
{
|
||||
CloseHandle(_fileHandle);
|
||||
_fileHandle = INVALID_HANDLE_VALUE;
|
||||
throw SystemException("Cannot map file into shared memory", _name);
|
||||
}
|
||||
map();
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryImpl::~SharedMemoryImpl()
|
||||
{
|
||||
unmap();
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryImpl::map()
|
||||
{
|
||||
DWORD access = FILE_MAP_READ;
|
||||
if (_mode == PAGE_READWRITE)
|
||||
access = FILE_MAP_WRITE;
|
||||
LPVOID addr = MapViewOfFile(_memHandle, access, 0, 0, _size);
|
||||
if (!addr)
|
||||
throw SystemException("Cannot map shared memory object", _name);
|
||||
|
||||
_address = static_cast<char*>(addr);
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryImpl::unmap()
|
||||
{
|
||||
if (_address)
|
||||
{
|
||||
UnmapViewOfFile(_address);
|
||||
_address = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryImpl::close()
|
||||
{
|
||||
if (_memHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(_memHandle);
|
||||
_memHandle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (_fileHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(_fileHandle);
|
||||
_fileHandle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Poco
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ThreadPool.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/src/ThreadPool.cpp#18 $
|
||||
// $Id: //poco/Main/Foundation/src/ThreadPool.cpp#19 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@ -81,7 +81,8 @@ PooledThread::PooledThread(const std::string& name):
|
||||
_idleTime(0),
|
||||
_pTarget(0),
|
||||
_name(name),
|
||||
_thread(name)
|
||||
_thread(name),
|
||||
_targetCompleted(false)
|
||||
{
|
||||
_idleTime = time(NULL);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# $Id: //poco/Main/Foundation/testsuite/Makefile-Driver#28 $
|
||||
# $Id: //poco/Main/Foundation/testsuite/Makefile-Driver#31 $
|
||||
#
|
||||
# Makefile for Poco Foundation testsuite
|
||||
#
|
||||
@ -35,9 +35,9 @@ objects = ActiveMethodTest ActivityTest ActiveDispatcherTest \
|
||||
TestPlugin DummyDelegate BasicEventTest FIFOEventTest PriorityEventTest EventTestSuite \
|
||||
LRUCacheTest ExpireCacheTest ExpireLRUCacheTest CacheTestSuite AnyTest FormatTest \
|
||||
HashingTestSuite HashTableTest SimpleHashTableTest LinearHashTableTest \
|
||||
HashSetTest HashMapTest \
|
||||
HashSetTest HashMapTest SharedMemoryTest \
|
||||
UniqueExpireCacheTest UniqueExpireLRUCacheTest \
|
||||
TuplesTest TypeListTest
|
||||
TuplesTest TypeListTest DynamicAnyTest FileStreamTest
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
|
@ -274,6 +274,9 @@
|
||||
<File
|
||||
RelativePath=".\src\CoreTestSuite.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicFactoryTest.cpp">
|
||||
</File>
|
||||
@ -335,6 +338,9 @@
|
||||
<File
|
||||
RelativePath=".\src\CoreTestSuite.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicFactoryTest.h">
|
||||
</File>
|
||||
@ -391,6 +397,9 @@
|
||||
<File
|
||||
RelativePath=".\src\CountingStreamTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStreamTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\HexBinaryTest.cpp">
|
||||
</File>
|
||||
@ -428,6 +437,9 @@
|
||||
<File
|
||||
RelativePath=".\src\CountingStreamTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStreamTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\HexBinaryTest.h">
|
||||
</File>
|
||||
@ -981,6 +993,9 @@
|
||||
<File
|
||||
RelativePath=".\src\ProcessTest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemoryTest.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -997,6 +1012,9 @@
|
||||
<File
|
||||
RelativePath=".\src\ProcessTest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemoryTest.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Version="8,00"
|
||||
Name="TestSuite"
|
||||
ProjectGUID="{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
|
||||
Keyword="Win32Proj"
|
||||
@ -402,6 +402,10 @@
|
||||
RelativePath=".\src\CoreTestSuite.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicFactoryTest.cpp"
|
||||
>
|
||||
@ -482,6 +486,10 @@
|
||||
RelativePath=".\src\CoreTestSuite.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicAnyTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\DynamicFactoryTest.h"
|
||||
>
|
||||
@ -554,6 +562,10 @@
|
||||
RelativePath=".\src\CountingStreamTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStreamTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\HexBinaryTest.cpp"
|
||||
>
|
||||
@ -602,6 +614,10 @@
|
||||
RelativePath=".\src\CountingStreamTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStreamTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\HexBinaryTest.h"
|
||||
>
|
||||
@ -1290,6 +1306,10 @@
|
||||
RelativePath=".\src\ProcessTest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemoryTest.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -1310,6 +1330,10 @@
|
||||
RelativePath=".\src\ProcessTest.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SharedMemoryTest.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
26
Foundation/testsuite/data/testdata.txt
Normal file
26
Foundation/testsuite/data/testdata.txt
Normal file
@ -0,0 +1,26 @@
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
|
||||
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
|
||||
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
|
||||
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
|
||||
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
|
||||
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
|
||||
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
|
||||
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
|
||||
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
|
||||
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
|
||||
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
|
||||
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
|
||||
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
|
||||
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
|
||||
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
|
||||
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
|
||||
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
|
||||
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
|
||||
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
|
||||
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
|
||||
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// CoreTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/CoreTestSuite.cpp#19 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/CoreTestSuite.cpp#20 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -46,6 +46,7 @@
|
||||
#include "DynamicFactoryTest.h"
|
||||
#include "MemoryPoolTest.h"
|
||||
#include "AnyTest.h"
|
||||
#include "DynamicAnyTest.h"
|
||||
#include "FormatTest.h"
|
||||
#include "TuplesTest.h"
|
||||
#include "TypeListTest.h"
|
||||
@ -70,6 +71,7 @@ CppUnit::Test* CoreTestSuite::suite()
|
||||
pSuite->addTest(DynamicFactoryTest::suite());
|
||||
pSuite->addTest(MemoryPoolTest::suite());
|
||||
pSuite->addTest(AnyTest::suite());
|
||||
pSuite->addTest(DynamicAnyTest::suite());
|
||||
pSuite->addTest(FormatTest::suite());
|
||||
pSuite->addTest(TuplesTest::suite());
|
||||
pSuite->addTest(TypeListTest::suite());
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DateTimeTest.cpp#14 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DateTimeTest.cpp#15 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -833,6 +833,18 @@ void DateTimeTest::testDayOfWeek()
|
||||
}
|
||||
|
||||
|
||||
void DateTimeTest::testUTC()
|
||||
{
|
||||
DateTime dt(2007, 3, 5, 12, 30, 00);
|
||||
|
||||
assert (dt.hour() == 12);
|
||||
dt.makeUTC(3600);
|
||||
assert (dt.hour() == 11);
|
||||
dt.makeLocal(3600);
|
||||
assert (dt.hour() == 12);
|
||||
}
|
||||
|
||||
|
||||
void DateTimeTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -863,6 +875,7 @@ CppUnit::Test* DateTimeTest::suite()
|
||||
CppUnit_addTest(pSuite, DateTimeTest, testIsValid);
|
||||
CppUnit_addTest(pSuite, DateTimeTest, testDayOfWeek);
|
||||
CppUnit_addTest(pSuite, DateTimeTest, testIncrementDecrement);
|
||||
CppUnit_addTest(pSuite, DateTimeTest, testUTC);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// DateTimeTest.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DateTimeTest.h#12 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DateTimeTest.h#13 $
|
||||
//
|
||||
// Definition of the DateTimeTest class.
|
||||
//
|
||||
@ -61,6 +61,7 @@ public:
|
||||
void testIsValid();
|
||||
void testDayOfWeek();
|
||||
void testIncrementDecrement();
|
||||
void testUTC();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
967
Foundation/testsuite/src/DynamicAnyTest.cpp
Normal file
967
Foundation/testsuite/src/DynamicAnyTest.cpp
Normal file
@ -0,0 +1,967 @@
|
||||
//
|
||||
// DynamicAnyTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "DynamicAnyTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/DynamicAny.h"
|
||||
#include "Poco/Bugcheck.h"
|
||||
|
||||
|
||||
|
||||
using namespace Poco;
|
||||
|
||||
|
||||
DynamicAnyTest::DynamicAnyTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DynamicAnyTest::~DynamicAnyTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testInt8()
|
||||
{
|
||||
Poco::Int8 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::Int8));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testInt16()
|
||||
{
|
||||
Poco::Int16 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::Int16));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testInt32()
|
||||
{
|
||||
Poco::Int32 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::Int32));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testInt64()
|
||||
{
|
||||
Poco::Int64 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::Int64));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testUInt8()
|
||||
{
|
||||
Poco::UInt8 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::UInt8));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testUInt16()
|
||||
{
|
||||
Poco::UInt16 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::UInt16));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testUInt32()
|
||||
{
|
||||
Poco::UInt32 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::UInt32));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testUInt64()
|
||||
{
|
||||
Poco::UInt64 src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(Poco::UInt64));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testBool()
|
||||
{
|
||||
bool src = true;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(bool));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 1);
|
||||
assert (s15 == 1);
|
||||
assert (s1 == "true");
|
||||
assert (s2 == 1);
|
||||
assert (s3 == 1);
|
||||
assert (s4 == 1);
|
||||
assert (s5 == 1);
|
||||
assert (s6 == 1);
|
||||
assert (s7 == 1);
|
||||
assert (s8 == 1);
|
||||
assert (s9 == 1);
|
||||
assert (s10 == 1.0f);
|
||||
assert (s11 == 1.0);
|
||||
assert (s12);
|
||||
assert (s13 == '\x1');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testChar()
|
||||
{
|
||||
char src = ' ';
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(char));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == " ");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testFloat()
|
||||
{
|
||||
float src = 32.0f;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(float));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testDouble()
|
||||
{
|
||||
double src = 32.0;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(double));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testString()
|
||||
{
|
||||
DynamicAny a1("32");
|
||||
|
||||
assert (a1.type() == typeid(std::string));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == '3');
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DynamicAnyTest::testLong()
|
||||
{
|
||||
long src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(long));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::testULong()
|
||||
{
|
||||
unsigned long src = 32;
|
||||
DynamicAny a1 = src;
|
||||
|
||||
assert (a1.type() == typeid(unsigned long));
|
||||
|
||||
std::string s1;
|
||||
Poco::Int8 s2;
|
||||
Poco::Int16 s3;
|
||||
Poco::Int32 s4;
|
||||
Poco::Int64 s5;
|
||||
Poco::UInt8 s6;
|
||||
Poco::UInt16 s7;
|
||||
Poco::UInt32 s8;
|
||||
Poco::UInt64 s9;
|
||||
float s10;
|
||||
double s11;
|
||||
bool s12;
|
||||
char s13;
|
||||
a1.convert(s1);
|
||||
a1.convert(s2);
|
||||
a1.convert(s3);
|
||||
a1.convert(s4);
|
||||
a1.convert(s5);
|
||||
a1.convert(s6);
|
||||
a1.convert(s7);
|
||||
a1.convert(s8);
|
||||
a1.convert(s9);
|
||||
a1.convert(s10);
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
assert (s15 == 32);
|
||||
assert (s1 == "32");
|
||||
assert (s2 == 32);
|
||||
assert (s3 == 32);
|
||||
assert (s4 == 32);
|
||||
assert (s5 == 32);
|
||||
assert (s6 == 32);
|
||||
assert (s7 == 32);
|
||||
assert (s8 == 32);
|
||||
assert (s9 == 32);
|
||||
assert (s10 == 32.0f);
|
||||
assert (s11 == 32.0);
|
||||
assert (s12);
|
||||
assert (s13 == ' ');
|
||||
DynamicAny a2(a1);
|
||||
std::string t2;
|
||||
a2.convert(t2);
|
||||
assert (s1 == t2);
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DynamicAnyTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* DynamicAnyTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DynamicAnyTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testInt8);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testInt16);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testInt32);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testInt64);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testUInt8);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testUInt16);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testUInt32);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testUInt64);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testBool);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testChar);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testFloat);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testDouble);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testString);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testLong);
|
||||
CppUnit_addTest(pSuite, DynamicAnyTest, testULong);
|
||||
|
||||
return pSuite;
|
||||
}
|
70
Foundation/testsuite/src/DynamicAnyTest.h
Normal file
70
Foundation/testsuite/src/DynamicAnyTest.h
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// DynamicAnyTest.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/DynamicAnyTest.h#1 $
|
||||
//
|
||||
// Tests for Any types
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef DynamicAnyTest_INCLUDED
|
||||
#define DynamicAnyTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class DynamicAnyTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
DynamicAnyTest(const std::string& name);
|
||||
~DynamicAnyTest();
|
||||
|
||||
void testInt8();
|
||||
void testInt16();
|
||||
void testInt32();
|
||||
void testInt64();
|
||||
void testUInt8();
|
||||
void testUInt16();
|
||||
void testUInt32();
|
||||
void testUInt64();
|
||||
void testBool();
|
||||
void testChar();
|
||||
void testFloat();
|
||||
void testDouble();
|
||||
void testLong();
|
||||
void testULong();
|
||||
void testString();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
static CppUnit::Test* suite();
|
||||
};
|
||||
|
||||
|
||||
#endif // DynamicAnyTest_INCLUDED
|
@ -480,7 +480,7 @@ std::string FileChannelTest::filename() const
|
||||
}
|
||||
|
||||
|
||||
template<class DT>
|
||||
template <class DT>
|
||||
std::string FileChannelTest::rotation(TimeRotation rtype) const
|
||||
{
|
||||
DT now;
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
template<class D> std::string rotation(TimeRotation rtype) const;
|
||||
template <class D> std::string rotation(TimeRotation rtype) const;
|
||||
void remove(const std::string& baseName);
|
||||
std::string filename() const;
|
||||
};
|
||||
|
333
Foundation/testsuite/src/FileStreamTest.cpp
Normal file
333
Foundation/testsuite/src/FileStreamTest.cpp
Normal file
@ -0,0 +1,333 @@
|
||||
//
|
||||
// FileStreamTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/FileStreamTest.cpp#8 $
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "FileStreamTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/FileStream.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/TemporaryFile.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
FileStreamTest::FileStreamTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
FileStreamTest::~FileStreamTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testRead()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_WIN32_UTF8)
|
||||
char tmp[]={'\xc4', '\xd6', '\xdc', '\xe4', '\xf6', '\xfc', '\0'};
|
||||
std::string file(tmp);
|
||||
file.append(".txt");
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
char tmp[]={'\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\0'};
|
||||
std::string file(tmp);
|
||||
file.append(".txt");
|
||||
#else
|
||||
std::string file("testfile.txt");
|
||||
#endif
|
||||
|
||||
Poco::TemporaryFile::registerForDeletion(file);
|
||||
|
||||
Poco::FileOutputStream fos(file, std::ios::binary);
|
||||
fos << "sometestdata";
|
||||
fos.close();
|
||||
|
||||
Poco::FileInputStream fis(file);
|
||||
assert (fis.good());
|
||||
std::string read;
|
||||
fis >> read;
|
||||
assert (!read.empty());
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testWrite()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_WIN32_UTF8)
|
||||
char tmp[]={'\xdf', '\xc4', '\xd6', '\xdc', '\xe4', '\xf6', '\xfc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + (".txt");
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
char tmp[]={'\xc3', '\x9f', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + ".txt";
|
||||
#else
|
||||
std::string file("dummy_file.txt");
|
||||
#endif
|
||||
|
||||
Poco::TemporaryFile::registerForDeletion(file);
|
||||
|
||||
Poco::FileOutputStream fos(file);
|
||||
assert (fos.good());
|
||||
fos << "hiho";
|
||||
fos.close();
|
||||
|
||||
Poco::FileInputStream fis(file);
|
||||
assert (fis.good());
|
||||
std::string read;
|
||||
fis >> read;
|
||||
assert (read == "hiho");
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testReadWrite()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_WIN32_UTF8)
|
||||
char tmp[]={'\xdf', '\xc4', '\xd6', '\xdc', '\xe4', '\xf6', '\xfc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + (".txt");
|
||||
#else
|
||||
char tmp[]={'\xc3', '\x9f', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + ".txt";
|
||||
#endif
|
||||
|
||||
Poco::TemporaryFile::registerForDeletion(file);
|
||||
|
||||
Poco::FileStream fos(file);
|
||||
assert (fos.good());
|
||||
fos << "hiho";
|
||||
fos.seekg(0, std::ios::beg);
|
||||
std::string read;
|
||||
fos >> read;
|
||||
assert (read == "hiho");
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testOpen()
|
||||
{
|
||||
Poco::FileOutputStream ostr;
|
||||
ostr.open("test.txt", std::ios::out);
|
||||
assert (ostr.good());
|
||||
ostr.close();
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testOpenModeIn()
|
||||
{
|
||||
Poco::File f("nonexistent.txt");
|
||||
if (f.exists())
|
||||
f.remove();
|
||||
|
||||
try
|
||||
{
|
||||
Poco::FileInputStream istr("nonexistent.txt");
|
||||
fail("nonexistent file - must throw");
|
||||
}
|
||||
catch (Poco::Exception&)
|
||||
{
|
||||
}
|
||||
|
||||
f.createFile();
|
||||
Poco::FileInputStream istr("nonexistent.txt");
|
||||
assert (istr.good());
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testOpenModeOut()
|
||||
{
|
||||
Poco::File f("test.txt");
|
||||
if (f.exists())
|
||||
f.remove();
|
||||
|
||||
Poco::FileOutputStream ostr1("test.txt");
|
||||
ostr1 << "Hello, world!";
|
||||
ostr1.close();
|
||||
|
||||
assert (f.exists());
|
||||
assert (f.getSize() != 0);
|
||||
|
||||
Poco::FileStream str1("test.txt");
|
||||
str1.close();
|
||||
|
||||
assert (f.exists());
|
||||
assert (f.getSize() != 0);
|
||||
|
||||
Poco::FileOutputStream ostr2("test.txt");
|
||||
ostr2.close();
|
||||
|
||||
assert (f.exists());
|
||||
assert (f.getSize() == 0);
|
||||
|
||||
f.remove();
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testOpenModeTrunc()
|
||||
{
|
||||
Poco::File f("test.txt");
|
||||
if (f.exists())
|
||||
f.remove();
|
||||
|
||||
Poco::FileOutputStream ostr1("test.txt");
|
||||
ostr1 << "Hello, world!";
|
||||
ostr1.close();
|
||||
|
||||
assert (f.exists());
|
||||
assert (f.getSize() != 0);
|
||||
|
||||
Poco::FileStream str1("test.txt", std::ios::trunc);
|
||||
str1.close();
|
||||
|
||||
assert (f.exists());
|
||||
assert (f.getSize() == 0);
|
||||
|
||||
f.remove();
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testOpenModeAte()
|
||||
{
|
||||
Poco::FileOutputStream ostr("test.txt");
|
||||
ostr << "0123456789";
|
||||
ostr.close();
|
||||
|
||||
Poco::FileStream str1("test.txt", std::ios::ate);
|
||||
int c = str1.get();
|
||||
assert (str1.eof());
|
||||
|
||||
str1.clear();
|
||||
str1.seekg(0);
|
||||
c = str1.get();
|
||||
assert (c == '0');
|
||||
|
||||
str1.close();
|
||||
|
||||
Poco::FileStream str2("test.txt", std::ios::ate);
|
||||
str2 << "abcdef";
|
||||
str2.seekg(0);
|
||||
std::string s;
|
||||
str2 >> s;
|
||||
assert (s == "0123456789abcdef");
|
||||
str2.close();
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testOpenModeApp()
|
||||
{
|
||||
Poco::FileOutputStream ostr("test.txt");
|
||||
ostr << "0123456789";
|
||||
ostr.close();
|
||||
|
||||
Poco::FileStream str1("test.txt", std::ios::app);
|
||||
|
||||
str1 << "abc";
|
||||
|
||||
str1.seekp(0);
|
||||
|
||||
str1 << "def";
|
||||
|
||||
str1.close();
|
||||
|
||||
Poco::FileInputStream istr("test.txt");
|
||||
std::string s;
|
||||
istr >> s;
|
||||
assert (s == "0123456789abcdef");
|
||||
istr.close();
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::testSeek()
|
||||
{
|
||||
Poco::FileStream str("test.txt", std::ios::trunc);
|
||||
str << "0123456789abcdef";
|
||||
|
||||
str.seekg(0);
|
||||
int c = str.get();
|
||||
assert (c == '0');
|
||||
|
||||
str.seekg(10);
|
||||
assert (str.tellg() == std::streampos(10));
|
||||
c = str.get();
|
||||
assert (c == 'a');
|
||||
assert (str.tellg() == std::streampos(11));
|
||||
|
||||
str.seekg(-1, std::ios::end);
|
||||
assert (str.tellg() == std::streampos(15));
|
||||
c = str.get();
|
||||
assert (c == 'f');
|
||||
assert (str.tellg() == std::streampos(16));
|
||||
|
||||
str.seekg(-1, std::ios::cur);
|
||||
assert (str.tellg() == std::streampos(15));
|
||||
c = str.get();
|
||||
assert (c == 'f');
|
||||
assert (str.tellg() == std::streampos(16));
|
||||
|
||||
str.seekg(-4, std::ios::cur);
|
||||
assert (str.tellg() == std::streampos(12));
|
||||
c = str.get();
|
||||
assert (c == 'c');
|
||||
assert (str.tellg() == std::streampos(13));
|
||||
|
||||
str.seekg(1, std::ios::cur);
|
||||
assert (str.tellg() == std::streampos(14));
|
||||
c = str.get();
|
||||
assert (c == 'e');
|
||||
assert (str.tellg() == std::streampos(15));
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void FileStreamTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* FileStreamTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FileStreamTest");
|
||||
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testRead);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testWrite);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testReadWrite);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testOpen);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeIn);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeOut);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeTrunc);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeAte);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testOpenModeApp);
|
||||
CppUnit_addTest(pSuite, FileStreamTest, testSeek);
|
||||
|
||||
return pSuite;
|
||||
}
|
69
Foundation/testsuite/src/FileStreamTest.h
Normal file
69
Foundation/testsuite/src/FileStreamTest.h
Normal file
@ -0,0 +1,69 @@
|
||||
//
|
||||
// FileStreamTest.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/FileStreamTest.h#3 $
|
||||
//
|
||||
// Definition of the FileStreamTest class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef FileStreamTest_INCLUDED
|
||||
#define FileStreamTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class FileStreamTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
FileStreamTest(const std::string& name);
|
||||
~FileStreamTest();
|
||||
|
||||
void testRead();
|
||||
void testWrite();
|
||||
void testReadWrite();
|
||||
void testOpen();
|
||||
void testOpenModeIn();
|
||||
void testOpenModeOut();
|
||||
void testOpenModeTrunc();
|
||||
void testOpenModeAte();
|
||||
void testOpenModeApp();
|
||||
void testSeek();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // FileStreamTest_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// LocalDateTimeTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/LocalDateTimeTest.cpp#6 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/LocalDateTimeTest.cpp#7 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -139,6 +139,15 @@ void LocalDateTimeTest::testConversions()
|
||||
assert (dt5.millisecond() == 234);
|
||||
assert (dt5.dayOfWeek() == 5);
|
||||
assert (dt5.tzd() == -4*3600);
|
||||
|
||||
DateTime dt6(2005, 1, 28, 14, 24, 44, 234, 0);
|
||||
LocalDateTime dt7(3600, dt6);
|
||||
LocalDateTime dt8(3600, dt6, false);
|
||||
LocalDateTime dt9(3600, dt6, true);
|
||||
|
||||
assert (dt7.hour() == 15);
|
||||
assert (dt8.hour() == 14);
|
||||
assert (dt9.hour() == 15);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// NumberParserTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/NumberParserTest.cpp#9 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/NumberParserTest.cpp#10 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -105,6 +105,15 @@ void NumberParserTest::testParseError()
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex("23z");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
@ -134,6 +143,15 @@ void NumberParserTest::testParseError()
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseHex64("12345z");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -145,6 +163,15 @@ void NumberParserTest::testParseError()
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NumberParser::parseFloat("12.3aa");
|
||||
failmsg("must throw SyntaxException");
|
||||
}
|
||||
catch (SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// ProcessesTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/ProcessesTestSuite.cpp#5 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/ProcessesTestSuite.cpp#6 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -34,6 +34,7 @@
|
||||
#include "ProcessTest.h"
|
||||
#include "NamedMutexTest.h"
|
||||
#include "NamedEventTest.h"
|
||||
#include "SharedMemoryTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* ProcessesTestSuite::suite()
|
||||
@ -43,6 +44,7 @@ CppUnit::Test* ProcessesTestSuite::suite()
|
||||
pSuite->addTest(ProcessTest::suite());
|
||||
pSuite->addTest(NamedMutexTest::suite());
|
||||
pSuite->addTest(NamedEventTest::suite());
|
||||
pSuite->addTest(SharedMemoryTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
116
Foundation/testsuite/src/SharedMemoryTest.cpp
Normal file
116
Foundation/testsuite/src/SharedMemoryTest.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
//
|
||||
// SharedMemoryTest.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/SharedMemoryTest.cpp#6 $
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#include "SharedMemoryTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/SharedMemory.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
using Poco::SharedMemory;
|
||||
|
||||
|
||||
SharedMemoryTest::SharedMemoryTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SharedMemoryTest::~SharedMemoryTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryTest::testCreate()
|
||||
{
|
||||
SharedMemory mem("hi", 4096, SharedMemory::AM_WRITE);
|
||||
assert (mem.end()-mem.begin() == 4096);
|
||||
mem.begin()[0] = 'A';
|
||||
mem.end()[-1] = 'Z';
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryTest::testCreateFromFile()
|
||||
{
|
||||
Poco::Path p = findDataFile("testdata.txt");
|
||||
Poco::File f(p);
|
||||
assert (f.exists() && f.isFile());
|
||||
SharedMemory mem(f, SharedMemory::AM_READ);
|
||||
assert (mem.end() > mem.begin()); // valid?
|
||||
assert (mem.end() - mem.begin() == f.getSize());
|
||||
assert (mem.begin()[0] == 'A');
|
||||
assert (mem.end()[-5] == 'Z');
|
||||
}
|
||||
|
||||
|
||||
Poco::Path SharedMemoryTest::findDataFile(const std::string& afile)
|
||||
{
|
||||
Poco::Path root;
|
||||
root.makeAbsolute();
|
||||
Poco::Path result;
|
||||
while (!Poco::Path::find(root.toString(), "data", result))
|
||||
{
|
||||
root.makeParent();
|
||||
if (root.toString().empty() || root.toString() == "/")
|
||||
throw Poco::FileNotFoundException("Didn't find data subdir");
|
||||
}
|
||||
result.makeDirectory();
|
||||
result.setFileName(afile);
|
||||
Poco::File aFile(result.toString());
|
||||
if (!aFile.exists() || (aFile.exists() && !aFile.isFile()))
|
||||
throw Poco::FileNotFoundException("Didn't find file " + afile);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SharedMemoryTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* SharedMemoryTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SharedMemoryTest");
|
||||
|
||||
CppUnit_addTest(pSuite, SharedMemoryTest, testCreate);
|
||||
CppUnit_addTest(pSuite, SharedMemoryTest, testCreateFromFile);
|
||||
|
||||
return pSuite;
|
||||
}
|
64
Foundation/testsuite/src/SharedMemoryTest.h
Normal file
64
Foundation/testsuite/src/SharedMemoryTest.h
Normal file
@ -0,0 +1,64 @@
|
||||
//
|
||||
// SharedMemoryTest.h
|
||||
//
|
||||
// $Id: //poco/Main/template/test.h#7 $
|
||||
//
|
||||
// Definition of the SharedMemoryTest class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef SharedMemoryTest_INCLUDED
|
||||
#define SharedMemoryTest_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
class SharedMemoryTest: public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
SharedMemoryTest(const std::string& name);
|
||||
~SharedMemoryTest();
|
||||
|
||||
void testCreate();
|
||||
void testCreateFromFile();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
||||
static CppUnit::Test* suite();
|
||||
|
||||
static Poco::Path findDataFile(const std::string& afile);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
#endif // SharedMemoryTest_INCLUDED
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// StreamsTestSuite.cpp
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/StreamsTestSuite.cpp#10 $
|
||||
// $Id: //poco/Main/Foundation/testsuite/src/StreamsTestSuite.cpp#11 $
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
@ -41,6 +41,7 @@
|
||||
#include "BinaryReaderWriterTest.h"
|
||||
#include "LineEndingConverterTest.h"
|
||||
#include "TeeStreamTest.h"
|
||||
#include "FileStreamTest.h"
|
||||
|
||||
|
||||
CppUnit::Test* StreamsTestSuite::suite()
|
||||
@ -57,6 +58,7 @@ CppUnit::Test* StreamsTestSuite::suite()
|
||||
pSuite->addTest(BinaryReaderWriterTest::suite());
|
||||
pSuite->addTest(LineEndingConverterTest::suite());
|
||||
pSuite->addTest(TeeStreamTest::suite());
|
||||
pSuite->addTest(FileStreamTest::suite());
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ namespace
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
class CustomNotificationTask: public Task
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user