trunk/branch integration: adding new files

This commit is contained in:
Marian Krivos 2011-08-22 16:17:57 +00:00
parent 25eaadca7b
commit c8321f8857
10 changed files with 1400 additions and 0 deletions

View File

@ -0,0 +1,242 @@
//
// Ascii.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Ascii.h#1 $
//
// Library: Foundation
// Package: Core
// Module: Ascii
//
// Definition of the Ascii class.
//
// Copyright (c) 2010, 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_Ascii_INCLUDED
#define Foundation_Ascii_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
class Foundation_API Ascii
/// This class contains enumerations and static
/// utility functions for dealing with ASCII characters
/// and their properties.
///
/// The classification functions will also work if
/// non-ASCII character codes are passed to them,
/// but classification will only check for
/// ASCII characters.
///
/// This allows the classification methods to be used
/// on the single bytes of a UTF-8 string, without
/// causing assertions or inconsistent results (depending
/// upon the current locale) on bytes outside the ASCII range,
/// as may be produced by Ascii::isSpace(), etc.
{
public:
enum CharacterProperties
/// ASCII character properties.
{
ACP_CONTROL = 0x0001,
ACP_SPACE = 0x0002,
ACP_PUNCT = 0x0004,
ACP_DIGIT = 0x0008,
ACP_HEXDIGIT = 0x0010,
ACP_ALPHA = 0x0020,
ACP_LOWER = 0x0040,
ACP_UPPER = 0x0080,
ACP_GRAPH = 0x0100,
ACP_PRINT = 0x0200
};
static int properties(int ch);
/// Return the ASCII character properties for the
/// character with the given ASCII value.
///
/// If the character is outside the ASCII range
/// (0 .. 127), 0 is returned.
static bool hasSomeProperties(int ch, int properties);
/// Returns true if the given character is
/// within the ASCII range and has at least one of
/// the given properties.
static bool hasProperties(int ch, int properties);
/// Returns true if the given character is
/// within the ASCII range and has all of
/// the given properties.
static bool isAscii(int ch);
/// Returns true iff the given character code is within
/// the ASCII range (0 .. 127).
static bool isSpace(int ch);
/// Returns true iff the given character is a whitespace.
static bool isDigit(int ch);
/// Returns true iff the given character is a digit.
static bool isHexDigit(int ch);
/// Returns true iff the given character is a hexadecimal digit.
static bool isPunct(int ch);
/// Returns true iff the given character is a punctuation character.
static bool isAlpha(int ch);
/// Returns true iff the given character is an alphabetic character.
static bool isAlphaNumeric(int ch);
/// Returns true iff the given character is an alphabetic character.
static bool isLower(int ch);
/// Returns true iff the given character is a lowercase alphabetic
/// character.
static bool isUpper(int ch);
/// Returns true iff the given character is an uppercase alphabetic
/// character.
static int toLower(int ch);
/// If the given character is an uppercase character,
/// return its lowercase counterpart, otherwise return
/// the character.
static int toUpper(int ch);
/// If the given character is a lowercase character,
/// return its uppercase counterpart, otherwise return
/// the character.
private:
static const int CHARACTER_PROPERTIES[128];
};
//
// inlines
//
inline int Ascii::properties(int ch)
{
if (isAscii(ch))
return CHARACTER_PROPERTIES[ch];
else
return 0;
}
inline bool Ascii::isAscii(int ch)
{
return (static_cast<UInt32>(ch) & 0xFFFFFF80) == 0;
}
inline bool Ascii::hasProperties(int ch, int props)
{
return (properties(ch) & props) == props;
}
inline bool Ascii::hasSomeProperties(int ch, int props)
{
return (properties(ch) & props) != 0;
}
inline bool Ascii::isSpace(int ch)
{
return hasProperties(ch, ACP_SPACE);
}
inline bool Ascii::isDigit(int ch)
{
return hasProperties(ch, ACP_DIGIT);
}
inline bool Ascii::isHexDigit(int ch)
{
return hasProperties(ch, ACP_HEXDIGIT);
}
inline bool Ascii::isPunct(int ch)
{
return hasProperties(ch, ACP_PUNCT);
}
inline bool Ascii::isAlpha(int ch)
{
return hasProperties(ch, ACP_ALPHA);
}
inline bool Ascii::isAlphaNumeric(int ch)
{
return hasSomeProperties(ch, ACP_ALPHA | ACP_DIGIT);
}
inline bool Ascii::isLower(int ch)
{
return hasProperties(ch, ACP_LOWER);
}
inline bool Ascii::isUpper(int ch)
{
return hasProperties(ch, ACP_UPPER);
}
inline int Ascii::toLower(int ch)
{
if (isUpper(ch))
return ch + 32;
else
return ch;
}
inline int Ascii::toUpper(int ch)
{
if (isLower(ch))
return ch - 32;
else
return ch;
}
} // namespace Poco
#endif // Foundation_Ascii_INCLUDED

View File

@ -0,0 +1,327 @@
//
// AtomicCounter.h
//
// $Id: //poco/1.4/Foundation/include/Poco/AtomicCounter.h#1 $
//
// Library: Foundation
// Package: Core
// Module: AtomicCounter
//
// Definition of the AtomicCounter class.
//
// Copyright (c) 2009, 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_AtomicCounter_INCLUDED
#define Foundation_AtomicCounter_INCLUDED
#include "Poco/Foundation.h"
#if POCO_OS == POCO_OS_WINDOWS_NT
#include "Poco/UnWindows.h"
#elif POCO_OS == POCO_OS_MAC_OS_X
#include <libkern/OSAtomic.h>
#else
#include "Poco/Mutex.h"
#endif // POCO_OS
namespace Poco {
class Foundation_API AtomicCounter
/// This class implements a simple counter, which
/// provides atomic operations that are safe to
/// use in a multithreaded environment.
///
/// Typical usage of AtomicCounter is for implementing
/// reference counting and similar things.
///
/// On some platforms, the implementation of AtomicCounter
/// is based on atomic primitives specific to the platform
/// (such as InterlockedIncrement, etc. on Windows), and
/// thus very efficient. On platforms that do not support
/// atomic primitives, operations are guarded by a FastMutex.
///
/// The following platforms currently have atomic
/// primitives:
/// - Windows
/// - Mac OS X
{
public:
typedef int ValueType; /// The underlying integer type.
AtomicCounter();
/// Creates a new AtomicCounter and initializes it to zero.
explicit AtomicCounter(ValueType initialValue);
/// Creates a new AtomicCounter and initializes it with
/// the given value.
AtomicCounter(const AtomicCounter& counter);
/// Creates the counter by copying another one.
~AtomicCounter();
/// Destroys the AtomicCounter.
AtomicCounter& operator = (const AtomicCounter& counter);
/// Assigns the value of another AtomicCounter.
AtomicCounter& operator = (ValueType value);
/// Assigns a value to the counter.
operator ValueType () const;
/// Returns the value of the counter.
ValueType value() const;
/// Returns the value of the counter.
ValueType operator ++ (); // prefix
/// Increments the counter and returns the result.
ValueType operator ++ (int); // postfix
/// Increments the counter and returns the previous value.
ValueType operator -- (); // prefix
/// Decrements the counter and returns the result.
ValueType operator -- (int); // postfix
/// Decrements the counter and returns the previous value.
bool operator ! () const;
/// Returns true if the counter is zero, false otherwise.
private:
#if POCO_OS == POCO_OS_WINDOWS_NT
typedef volatile LONG ImplType;
#elif POCO_OS == POCO_OS_MAC_OS_X
typedef int32_t ImplType;
#else // generic implementation based on FastMutex
struct ImplType
{
mutable FastMutex mutex;
volatile int value;
};
#endif // POCO_OS
ImplType _counter;
};
//
// inlines
//
#if POCO_OS == POCO_OS_WINDOWS_NT
//
// Windows
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
return InterlockedIncrement(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
ValueType result(_counter);
InterlockedIncrement(&_counter);
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
return InterlockedDecrement(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
ValueType result(_counter);
InterlockedDecrement(&_counter);
return result;
}
inline bool AtomicCounter::operator ! () const
{
return _counter == 0;
}
#elif POCO_OS == POCO_OS_MAC_OS_X
//
// Mac OS X
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
return _counter;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
return OSAtomicIncrement32(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
ValueType result(_counter);
OSAtomicIncrement32(&_counter);
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
return OSAtomicDecrement32(&_counter);
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
ValueType result(_counter);
OSAtomicDecrement32(&_counter);
return result;
}
inline bool AtomicCounter::operator ! () const
{
return _counter == 0;
}
#else
//
// Generic implementation based on FastMutex
//
inline AtomicCounter::operator AtomicCounter::ValueType () const
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::value() const
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = ++_counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value++;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = --_counter.value;
}
return result;
}
inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix
{
ValueType result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value--;
}
return result;
}
inline bool AtomicCounter::operator ! () const
{
bool result;
{
FastMutex::ScopedLock lock(_counter.mutex);
result = _counter.value == 0;
}
return result;
}
#endif // POCO_OS
} // namespace Poco
#endif // Foundation_AtomicCounter_INCLUDED

View File

@ -0,0 +1,77 @@
//
// Environment_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Environment_VX.h#1 $
//
// Library: Foundation
// Package: Core
// Module: Environment
//
// Definition of the EnvironmentImpl class for VxWorks.
//
// Copyright (c) 2004-2011, 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_Environment_VX_INCLUDED
#define Foundation_Environment_VX_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Mutex.h"
#include <map>
namespace Poco {
class Foundation_API EnvironmentImpl
{
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static void setImpl(const std::string& name, const std::string& value);
static std::string osNameImpl();
static std::string osVersionImpl();
static std::string osArchitectureImpl();
static std::string nodeNameImpl();
static void nodeIdImpl(NodeId& id);
static unsigned processorCountImpl();
private:
typedef std::map<std::string, std::string> StringMap;
static StringMap _map;
static FastMutex _mutex;
};
} // namespace Poco
#endif // Foundation_Environment_VX_INCLUDED

View File

@ -0,0 +1,80 @@
//
// Environment_WINCE.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Environment_WINCE.h#1 $
//
// Library: Foundation
// Package: Core
// Module: Environment
//
// Definition of the EnvironmentImpl class for WINCE.
//
// Copyright (c) 2009-2010, 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_Environment_WINCE_INCLUDED
#define Foundation_Environment_WINCE_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
class Foundation_API EnvironmentImpl
{
public:
typedef UInt8 NodeId[6]; /// Ethernet address.
static std::string getImpl(const std::string& name);
static bool hasImpl(const std::string& name);
static void setImpl(const std::string& name, const std::string& value);
static std::string osNameImpl();
static std::string osVersionImpl();
static std::string osArchitectureImpl();
static std::string nodeNameImpl();
static void nodeIdImpl(NodeId& id);
static unsigned processorCountImpl();
private:
static bool envVar(const std::string& name, std::string* value);
static const std::string TEMP;
static const std::string TMP;
static const std::string HOMEPATH;
static const std::string COMPUTERNAME;
static const std::string OS;
static const std::string NUMBER_OF_PROCESSORS;
static const std::string PROCESSOR_ARCHITECTURE;
};
} // namespace Poco
#endif // Foundation_Environment_WINCE_INCLUDED

View File

@ -0,0 +1,102 @@
//
// File_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/File_VX.h#1 $
//
// Library: Foundation
// Package: Filesystem
// Module: File
//
// Definition of the FileImpl class for VxWorks.
//
// Copyright (c) 2004-2011, 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_File_VX_INCLUDED
#define Foundation_File_VX_INCLUDED
#include "Poco/Foundation.h"
namespace Poco {
class FileImpl
{
protected:
typedef UInt64 FileSizeImpl;
FileImpl();
FileImpl(const std::string& path);
virtual ~FileImpl();
void swapImpl(FileImpl& file);
void setPathImpl(const std::string& path);
const std::string& getPathImpl() const;
bool existsImpl() const;
bool canReadImpl() const;
bool canWriteImpl() const;
bool canExecuteImpl() const;
bool isFileImpl() const;
bool isDirectoryImpl() const;
bool isLinkImpl() const;
bool isDeviceImpl() const;
bool isHiddenImpl() const;
Timestamp createdImpl() const;
Timestamp getLastModifiedImpl() const;
void setLastModifiedImpl(const Timestamp& ts);
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 handleLastErrorImpl(const std::string& path);
private:
std::string _path;
friend class DirectoryIteratorImpl;
};
//
// inlines
//
inline const std::string& FileImpl::getPathImpl() const
{
return _path;
}
} // namespace Poco
#endif // Foundation_File_VX_INCLUDED

View File

@ -0,0 +1,199 @@
//
// MemoryStream.h
//
// $Id: //poco/1.4/Foundation/include/Poco/MemoryStream.h#1 $
//
// Library: Foundation
// Package: Streams
// Module: MemoryStream
//
// Definition of MemoryStreamBuf, MemoryInputStream, MemoryOutputStream
//
// Copyright (c) 2009, 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_MemoryStream_INCLUDED
#define Foundation_MemoryStream_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/StreamUtil.h"
#include <streambuf>
#include <iosfwd>
#include <ios>
#include <istream>
#include <ostream>
namespace Poco {
template <typename ch, typename tr>
class BasicMemoryStreamBuf: public std::basic_streambuf<ch, tr>
/// BasicMemoryStreamBuf is a simple implementation of a
/// stream buffer for reading and writing from a memory area.
///
/// This streambuf only supports unidirectional streams.
/// In other words, the BasicBufferedStreamBuf can be
/// used for the implementation of an istream or an
/// ostream, but not for an iostream.
{
protected:
typedef std::basic_streambuf<ch, tr> Base;
typedef std::basic_ios<ch, tr> IOS;
typedef ch char_type;
typedef tr char_traits;
typedef typename Base::int_type int_type;
typedef typename Base::pos_type pos_type;
typedef typename Base::off_type off_type;
public:
BasicMemoryStreamBuf(char_type* pBuffer, std::streamsize bufferSize):
_pBuffer(pBuffer),
_bufferSize(bufferSize)
{
this->setg(_pBuffer, _pBuffer, _pBuffer + _bufferSize);
this->setp(_pBuffer, _pBuffer + _bufferSize);
}
~BasicMemoryStreamBuf()
{
}
virtual int_type overflow(int_type c)
{
return char_traits::eof();
}
virtual int_type underflow()
{
return char_traits::eof();
}
virtual int sync()
{
return 0;
}
std::streamsize charsWritten() const
{
return static_cast<std::streamsize>(this->pptr() - this->pbase());
}
void reset()
/// Resets the buffer so that current read and write positions
/// will be set to the beginning of the buffer.
{
this->setg(_pBuffer, _pBuffer, _pBuffer + _bufferSize);
this->setp(_pBuffer, _pBuffer + _bufferSize);
}
private:
char_type* _pBuffer;
std::streamsize _bufferSize;
BasicMemoryStreamBuf();
BasicMemoryStreamBuf(const BasicMemoryStreamBuf&);
BasicMemoryStreamBuf& operator = (const BasicMemoryStreamBuf&);
};
//
// We provide an instantiation for char
//
typedef BasicMemoryStreamBuf<char, std::char_traits<char> > MemoryStreamBuf;
class Foundation_API MemoryIOS: public virtual std::ios
/// The base class for MemoryInputStream and MemoryOutputStream.
///
/// This class is needed to ensure the correct initialization
/// order of the stream buffer and base classes.
{
public:
MemoryIOS(char* pBuffer, std::streamsize bufferSize);
/// Creates the basic stream.
~MemoryIOS();
/// Destroys the stream.
MemoryStreamBuf* rdbuf();
/// Returns a pointer to the underlying streambuf.
protected:
MemoryStreamBuf _buf;
};
class Foundation_API MemoryInputStream: public MemoryIOS, public std::istream
/// An input stream for reading from a memory area.
{
public:
MemoryInputStream(const char* pBuffer, std::streamsize bufferSize);
/// Creates a MemoryInputStream for the given memory area,
/// ready for reading.
~MemoryInputStream();
/// Destroys the MemoryInputStream.
};
class Foundation_API MemoryOutputStream: public MemoryIOS, public std::ostream
/// An input stream for reading from a memory area.
{
public:
MemoryOutputStream(char* pBuffer, std::streamsize bufferSize);
/// Creates a MemoryOutputStream for the given memory area,
/// ready for writing.
~MemoryOutputStream();
/// Destroys the MemoryInputStream.
std::streamsize charsWritten() const;
/// Returns the number of chars written to the buffer.
};
//
// inlines
//
inline MemoryStreamBuf* MemoryIOS::rdbuf()
{
return &_buf;
}
inline std::streamsize MemoryOutputStream::charsWritten() const
{
return _buf.charsWritten();
}
} // namespace Poco
#endif // Foundation_MemoryStream_INCLUDED

View File

@ -0,0 +1,72 @@
//
// Mutex_WIN32.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Mutex_WINCE.h#1 $
//
// Library: Foundation
// Package: Threading
// Module: Mutex
//
// Definition of the MutexImpl and FastMutexImpl classes for WIN32.
//
// Copyright (c) 2004-2010, 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_Mutex_WINCE_INCLUDED
#define Foundation_Mutex_WINCE_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/UnWindows.h"
namespace Poco {
class Foundation_API MutexImpl
{
protected:
MutexImpl();
~MutexImpl();
void lockImpl();
bool tryLockImpl();
bool tryLockImpl(long milliseconds);
void unlockImpl();
private:
HANDLE _mutex;
};
typedef MutexImpl FastMutexImpl;
} // namespace Poco
#endif // Foundation_Mutex_WINCE_INCLUDED

View File

@ -0,0 +1,179 @@
//
// Nullable.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Nullable.h#1 $
//
// Library: Foundation
// Package: Core
// Module: Nullable
//
// Definition of the Nullable template class.
//
// Copyright (c) 2010, 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_Nullable_INCLUDED
#define Foundation_Nullable_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include <algorithm>
namespace Poco {
template <typename C>
class Nullable
/// Nullable is a simple wrapper class for value types
/// that allows to introduce a "null" value or state
/// to value objects.
///
/// The class is useful for passing parameters to functions
/// when parameters are optional and no default values
/// should be used.
///
/// A Nullable can be default constructed. In this case,
/// the Nullable will have a Null value and isNull() will
/// return true. Calling value() (without default value) on
/// a Null object will throw a NullValueException.
///
/// A Nullable can also be constructed from a value.
/// It is possible to assign a value to a Nullable, and
/// to reset a Nullable to contain a Null value by calling
/// clear().
///
/// For use with Nullable, the value type should support
/// default construction.
{
public:
Nullable():
/// Creates an empty Nullable.
_value(),
_isNull(true)
{
}
Nullable(const C& value):
/// Creates a Nullable with the given value.
_value(value),
_isNull(false)
{
}
Nullable(const Nullable& other):
/// Creates a Nullable by copying another one.
_value(other._value),
_isNull(other._isNull)
{
}
~Nullable()
/// Destroys the Nullable.
{
}
Nullable& assign(const C& value)
/// Assigns a value to the Nullable.
{
_value = value;
_isNull = false;
return *this;
}
Nullable& assign(const Nullable& other)
/// Assigns another Nullable.
{
Nullable tmp(other);
swap(tmp);
return *this;
}
Nullable& operator = (const C& value)
{
return assign(value);
}
Nullable& operator = (const Nullable& other)
{
return assign(other);
}
void swap(Nullable& other)
{
std::swap(_value, other._value);
std::swap(_isNull, other._isNull);
}
const C& value() const
/// Returns the Nullable's value.
///
/// Throws a NullValueException if the Nullable is empty.
{
if (!_isNull)
return _value;
else
throw NullValueException();
}
const C& value(const C& deflt) const
/// Returns the Nullable's value, or the
/// given default value if the Nullable is empty.
{
return _isNull ? deflt : _value;
}
bool isNull() const
/// Returns true iff the Nullable is empty.
{
return _isNull;
}
void clear()
/// Clears the Nullable.
{
_isNull = true;
}
private:
C _value;
bool _isNull;
};
template <typename C>
inline void swap(Nullable<C>& n1, Nullable<C>& n2)
{
n1.swap(n2);
}
} // namespace Poco
#endif // Foundation_Nullable_INCLUDED

View File

@ -0,0 +1,71 @@
//
// Path_WINCE.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Path_WINCE.h#1 $
//
// Library: Foundation
// Package: Filesystem
// Module: Path
//
// Definition of the PathImpl class for WIN32.
//
// Copyright (c) 2006-2010, 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_Path_WINCE_INCLUDED
#define Foundation_Path_WINCE_INCLUDED
#include "Poco/Foundation.h"
#include <vector>
namespace Poco {
class Foundation_API PathImpl
{
public:
static std::string currentImpl();
// Returns the root directory
static std::string homeImpl();
static std::string tempImpl();
static std::string nullImpl();
static std::string expandImpl(const std::string& path);
static void listRootsImpl(std::vector<std::string>& roots);
enum
{
MAX_PATH_LEN = 32767
};
};
} // namespace Poco
#endif // Foundation_Path_WINCE_INCLUDED

View File

@ -0,0 +1,51 @@
//
// Platform_VX.h
//
// $Id: //poco/1.4/Foundation/include/Poco/Platform_VX.h#1 $
//
// Library: Foundation
// Package: Core
// Module: Platform
//
// Platform and architecture identification macros
// and platform-specific definitions for VxWorks
//
// Copyright (c) 2004-2011, 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_Platform_VX_INCLUDED
#define Foundation_Platform_VX_INCLUDED
#define POCO_NO_SYS_SELECT_H
#define POCO_NO_FPENVIRONMENT
#define POCO_NO_WSTRING
#define POCO_NO_SHAREDMEMORY
#define POCO_NO_SYSLOGCHANNEL
#endif // Foundation_Platform_VX_INCLUDED