latest changes from main repository

This commit is contained in:
Guenter Obiltschnig
2007-04-25 08:39:02 +00:00
parent f29f7cda53
commit 3e46ab332b
60 changed files with 1619 additions and 163 deletions

View File

@@ -1,13 +1,13 @@
//
// ASCIIEncoding.cpp
//
// $Id: //poco/Main/Foundation/src/ASCIIEncoding.cpp#11 $
// $Id: //poco/Main/Foundation/src/ASCIIEncoding.cpp#12 $
//
// Library: Foundation
// Package: Text
// Module: ASCIIEncoding
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -35,11 +35,19 @@
#include "Poco/ASCIIEncoding.h"
#include "Poco/String.h"
namespace Poco {
const char* ASCIIEncoding::_names[] =
{
"ASCII",
NULL
};
const TextEncoding::CharacterMap ASCIIEncoding::_charMap =
{
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -71,6 +79,23 @@ ASCIIEncoding::~ASCIIEncoding()
}
const char* ASCIIEncoding::canonicalName() const
{
return _names[0];
}
bool ASCIIEncoding::isA(const std::string& encodingName) const
{
for (const char** name = _names; *name; ++name)
{
if (Poco::icompare(encodingName, *name) == 0)
return true;
}
return false;
}
const TextEncoding::CharacterMap& ASCIIEncoding::characterMap() const
{
return _charMap;

View File

@@ -0,0 +1,101 @@
//
// Condition.cpp
//
// $Id: //poco/Main/Foundation/src/Condition.cpp#1 $
//
// Library: Foundation
// Package: Threading
// Module: Condition
//
// 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/Condition.h"
namespace Poco {
Condition::Condition()
{
}
Condition::~Condition()
{
}
void Condition::signal()
{
FastMutex::ScopedLock lock(_mutex);
if (!_waitQueue.empty())
{
_waitQueue.front()->set();
dequeue();
}
}
void Condition::broadcast()
{
FastMutex::ScopedLock lock(_mutex);
for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
{
(*it)->set();
}
_waitQueue.clear();
}
void Condition::enqueue(Event& event)
{
_waitQueue.push_back(&event);
}
void Condition::dequeue()
{
_waitQueue.pop_front();
}
void Condition::dequeue(Event& event)
{
for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it)
{
if (*it == &event)
{
_waitQueue.erase(it);
break;
}
}
}
} // namespace Poco

View File

@@ -1,7 +1,7 @@
//
// File.cpp
//
// $Id: //poco/Main/Foundation/src/File.cpp#17 $
// $Id: //poco/Main/Foundation/src/File.cpp#19 $
//
// Library: Foundation
// Package: Filesystem
@@ -211,24 +211,40 @@ void File::setExecutable(bool flag)
void File::copyTo(const std::string& path) const
{
Path src(getPathImpl());
File srcFile(src);
if (srcFile.isDirectory())
throw OpenFileException("cannot copy directory", src.toString());
Path dest(path);
if (dest.isDirectory())
File destFile(path);
if (destFile.exists() && destFile.isDirectory() || dest.isDirectory())
{
dest.makeDirectory();
dest.setFileName(src.getFileName());
}
copyToImpl(dest.toString());
if (isDirectory())
copyDirectory(dest.toString());
else
copyToImpl(dest.toString());
}
void File::copyDirectory(const std::string& path) const
{
File target(path);
target.createDirectories();
Path src(getPathImpl());
src.makeFile();
DirectoryIterator it(src);
DirectoryIterator end;
for (; it != end; ++it)
{
it->copyTo(path);
}
}
void File::moveTo(const std::string& path)
{
copyToImpl(path);
removeImpl();
copyTo(path);
remove(true);
setPathImpl(path);
}

View File

@@ -1,7 +1,7 @@
//
// File_WIN32.cpp
//
// $Id: //poco/Main/Foundation/src/File_WIN32.cpp#16 $
// $Id: //poco/Main/Foundation/src/File_WIN32.cpp#17 $
//
// Library: Foundation
// Package: Filesystem
@@ -319,7 +319,7 @@ bool FileImpl::createFileImpl()
poco_assert (!_path.empty());
HANDLE hFile = CreateFile(_path.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
if (hFile)
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return true;

View File

@@ -1,7 +1,7 @@
//
// File_WIN32U.cpp
//
// $Id: //poco/Main/Foundation/src/File_WIN32U.cpp#10 $
// $Id: //poco/Main/Foundation/src/File_WIN32U.cpp#11 $
//
// Library: Foundation
// Package: Filesystem
@@ -327,7 +327,7 @@ bool FileImpl::createFileImpl()
poco_assert (!_path.empty());
HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
if (hFile)
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return true;

View File

@@ -1,13 +1,13 @@
//
// Latin1Encoding.cpp
//
// $Id: //poco/Main/Foundation/src/Latin1Encoding.cpp#11 $
// $Id: //poco/Main/Foundation/src/Latin1Encoding.cpp#12 $
//
// Library: Foundation
// Package: Text
// Module: Latin1Encoding
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -35,11 +35,21 @@
#include "Poco/Latin1Encoding.h"
#include "Poco/String.h"
namespace Poco {
const char* Latin1Encoding::_names[] =
{
"ISO-8859-1",
"Latin1",
"Latin-1",
NULL
};
const TextEncoding::CharacterMap Latin1Encoding::_charMap =
{
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -71,6 +81,23 @@ Latin1Encoding::~Latin1Encoding()
}
const char* Latin1Encoding::canonicalName() const
{
return _names[0];
}
bool Latin1Encoding::isA(const std::string& encodingName) const
{
for (const char** name = _names; *name; ++name)
{
if (Poco::icompare(encodingName, *name) == 0)
return true;
}
return false;
}
const TextEncoding::CharacterMap& Latin1Encoding::characterMap() const
{
return _charMap;

View File

@@ -1,13 +1,13 @@
//
// Latin9Encoding.cpp
//
// $Id: //poco/Main/Foundation/src/Latin9Encoding.cpp#11 $
// $Id: //poco/Main/Foundation/src/Latin9Encoding.cpp#12 $
//
// Library: Foundation
// Package: Text
// Module: Latin9Encoding
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -35,11 +35,21 @@
#include "Poco/Latin9Encoding.h"
#include "Poco/String.h"
namespace Poco {
const char* Latin9Encoding::_names[] =
{
"ISO-8859-15",
"Latin9",
"Latin-9",
NULL
};
const TextEncoding::CharacterMap Latin9Encoding::_charMap =
{
/* 00 */ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
@@ -71,6 +81,23 @@ Latin9Encoding::~Latin9Encoding()
}
const char* Latin9Encoding::canonicalName() const
{
return _names[0];
}
bool Latin9Encoding::isA(const std::string& encodingName) const
{
for (const char** name = _names; *name; ++name)
{
if (Poco::icompare(encodingName, *name) == 0)
return true;
}
return false;
}
const TextEncoding::CharacterMap& Latin9Encoding::characterMap() const
{
return _charMap;

View File

@@ -1,7 +1,7 @@
//
// Path.cpp
//
// $Id: //poco/Main/Foundation/src/Path.cpp#20 $
// $Id: //poco/Main/Foundation/src/Path.cpp#21 $
//
// Library: Foundation
// Package: Filesystem
@@ -119,6 +119,19 @@ Path::Path(const Path& parent, const std::string& fileName):
}
Path::Path(const Path& parent, const char* fileName):
_node(parent._node),
_device(parent._device),
_name(parent._name),
_version(parent._version),
_dirs(parent._dirs),
_absolute(parent._absolute)
{
makeDirectory();
_name = fileName;
}
Path::Path(const Path& parent, const Path& relative):
_node(parent._node),
_device(parent._device),

View File

@@ -1,7 +1,7 @@
//
// SharedMemory.cpp
//
// $Id: //poco/Main/Foundation/src/SharedMemory.cpp#4 $
// $Id: //poco/Main/Foundation/src/SharedMemory.cpp#5 $
//
// Library: Poco
// Package: Processes
@@ -34,6 +34,12 @@
//
#if POCO_OS == POCO_OS_SOLARIS
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
#include "Poco/SharedMemory.h"
#include "Poco/Exception.h"
#if defined(POCO_OS_FAMILY_WINDOWS)

View File

@@ -1,7 +1,7 @@
//
// TextEncoding.cpp
//
// $Id: //poco/Main/Foundation/src/TextEncoding.cpp#10 $
// $Id: //poco/Main/Foundation/src/TextEncoding.cpp#13 $
//
// Library: Foundation
// Package: Text
@@ -35,16 +35,114 @@
#include "Poco/TextEncoding.h"
#include "Poco/Exception.h"
#include "Poco/String.h"
#include "Poco/ASCIIEncoding.h"
#include "Poco/Latin1Encoding.h"
#include "Poco/Latin9Encoding.h"
#include "Poco/UTF16Encoding.h"
#include "Poco/UTF8Encoding.h"
#include "Poco/Windows1252Encoding.h"
#include "Poco/RWLock.h"
#include "Poco/SingletonHolder.h"
#include <map>
namespace Poco {
//
// TextEncodingManager
//
class TextEncodingManager
{
public:
TextEncodingManager()
{
TextEncoding::Ptr pUtf8Encoding(new UTF8Encoding);
add(pUtf8Encoding, TextEncoding::GLOBAL);
add(new ASCIIEncoding);
add(new Latin1Encoding);
add(new Latin9Encoding);
add(pUtf8Encoding);
add(new UTF16Encoding);
add(new Windows1252Encoding);
}
~TextEncodingManager()
{
}
void add(TextEncoding::Ptr pEncoding)
{
add(pEncoding, pEncoding->canonicalName());
}
void add(TextEncoding::Ptr pEncoding, const std::string& name)
{
RWLock::ScopedLock lock(_lock, true);
_encodings[name] = pEncoding;
}
void remove(const std::string& name)
{
RWLock::ScopedLock lock(_lock, true);
_encodings.erase(name);
}
TextEncoding::Ptr find(const std::string& name) const
{
RWLock::ScopedLock lock(_lock);
EncodingMap::const_iterator it = _encodings.find(name);
if (it != _encodings.end())
return it->second;
for (it = _encodings.begin(); it != _encodings.end(); ++it)
{
if (it->second->isA(name))
return it->second;
}
return TextEncoding::Ptr();
}
private:
TextEncodingManager(const TextEncodingManager&);
TextEncodingManager& operator = (const TextEncodingManager&);
struct ILT
{
bool operator() (const std::string& s1, const std::string& s2) const
{
return Poco::icompare(s1, s2) < 0;
}
};
typedef std::map<std::string, TextEncoding::Ptr, ILT> EncodingMap;
EncodingMap _encodings;
mutable RWLock _lock;
};
//
// TextEncoding
//
const std::string TextEncoding::GLOBAL;
TextEncoding::~TextEncoding()
{
}
int TextEncoding::convert(const unsigned char* bytes) const
{
return (int) *bytes;
@@ -57,5 +155,59 @@ int TextEncoding::convert(int ch, unsigned char* bytes, int length) const
}
} // namespace Poco
TextEncoding& TextEncoding::byName(const std::string& encodingName)
{
TextEncoding* pEncoding = manager().find(encodingName);
if (pEncoding)
return *pEncoding;
else
throw NotFoundException(encodingName);
}
TextEncoding::Ptr TextEncoding::find(const std::string& encodingName)
{
return manager().find(encodingName);
}
void TextEncoding::add(TextEncoding::Ptr pEncoding)
{
manager().add(pEncoding, pEncoding->canonicalName());
}
void TextEncoding::add(TextEncoding::Ptr pEncoding, const std::string& name)
{
manager().add(pEncoding, name);
}
void TextEncoding::remove(const std::string& encodingName)
{
manager().remove(encodingName);
}
TextEncoding::Ptr TextEncoding::global(TextEncoding::Ptr encoding)
{
TextEncoding::Ptr prev = find(GLOBAL);
add(encoding, GLOBAL);
return prev;
}
TextEncoding& TextEncoding::global()
{
return byName(GLOBAL);
}
TextEncodingManager& TextEncoding::manager()
{
static SingletonHolder<TextEncodingManager> sh;
return *sh.get();
}
} // namespace Poco

View File

@@ -1,7 +1,7 @@
//
// Thread.cpp
//
// $Id: //poco/Main/Foundation/src/Thread.cpp#12 $
// $Id: //poco/Main/Foundation/src/Thread.cpp#13 $
//
// Library: Foundation
// Package: Threading
@@ -97,6 +97,19 @@ void Thread::join()
}
void Thread::join(long milliseconds)
{
if (!joinImpl(milliseconds))
throw TimeoutException();
}
bool Thread::tryJoin(long milliseconds)
{
return joinImpl(milliseconds);
}
ThreadLocalStorage& Thread::tls()
{
if (!_pTLS)

View File

@@ -1,13 +1,13 @@
//
// Thread_POSIX.cpp
//
// $Id: //poco/Main/Foundation/src/Thread_POSIX.cpp#13 $
// $Id: //poco/Main/Foundation/src/Thread_POSIX.cpp#15 $
//
// Library: Foundation
// Package: Threading
// Module: Thread
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -73,10 +73,8 @@ pthread_key_t ThreadImpl::_currentKey;
bool ThreadImpl::_haveCurrentKey = false;
ThreadImpl::ThreadImpl():
_pTarget(0),
_thread(0),
_prio(PRIO_NORMAL_IMPL)
ThreadImpl::ThreadImpl():
_pData(new ThreadData)
{
if (!_haveCurrentKey)
{
@@ -89,21 +87,21 @@ ThreadImpl::ThreadImpl():
ThreadImpl::~ThreadImpl()
{
if (_pTarget)
pthread_detach(_thread);
if (_pData->pTarget)
pthread_detach(_pData->thread);
}
void ThreadImpl::setPriorityImpl(int prio)
{
if (prio != _prio)
if (prio != _pData->prio)
{
_prio = prio;
if (_pTarget)
_pData->prio = prio;
if (_pData->pTarget)
{
struct sched_param par;
par.sched_priority = mapPrio(_prio);
if (pthread_setschedparam(_thread, SCHED_OTHER, &par))
par.sched_priority = mapPrio(_pData->prio);
if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
throw SystemException("cannot set thread priority");
}
}
@@ -112,20 +110,20 @@ void ThreadImpl::setPriorityImpl(int prio)
void ThreadImpl::startImpl(Runnable& target)
{
if (_pTarget) throw SystemException("thread already running");
if (_pData->pTarget) throw SystemException("thread already running");
_pTarget = &target;
if (pthread_create(&_thread, NULL, entry, this))
_pData->pTarget = &target;
if (pthread_create(&_pData->thread, NULL, entry, this))
{
_pTarget = 0;
_pData->pTarget = 0;
throw SystemException("cannot start thread");
}
if (_prio != PRIO_NORMAL_IMPL)
if (_pData->prio != PRIO_NORMAL_IMPL)
{
struct sched_param par;
par.sched_priority = mapPrio(_prio);
if (pthread_setschedparam(_thread, SCHED_OTHER, &par))
par.sched_priority = mapPrio(_pData->prio);
if (pthread_setschedparam(_pData->thread, SCHED_OTHER, &par))
throw SystemException("cannot set thread priority");
}
}
@@ -133,24 +131,36 @@ void ThreadImpl::startImpl(Runnable& target)
void ThreadImpl::joinImpl()
{
if (!_pTarget) return;
_pData->done.wait();
void* result;
if (pthread_join(_thread, &result))
if (pthread_join(_pData->thread, &result))
throw SystemException("cannot join thread");
_pTarget = 0;
}
bool ThreadImpl::joinImpl(long milliseconds)
{
if (_pData->done.tryWait(milliseconds))
{
void* result;
if (pthread_join(_pData->thread, &result))
throw SystemException("cannot join thread");
return true;
}
else return false;
}
bool ThreadImpl::isRunningImpl() const
{
return _pTarget != 0;
return _pData->pTarget != 0;
}
ThreadImpl* ThreadImpl::currentImpl()
{
if (_haveCurrentKey)
return (ThreadImpl*) pthread_getspecific(_currentKey);
return reinterpret_cast<ThreadImpl*>(pthread_getspecific(_currentKey));
else
return 0;
}
@@ -169,9 +179,11 @@ void* ThreadImpl::entry(void* pThread)
pthread_sigmask(SIG_BLOCK, &sset, 0);
#endif
ThreadImpl* pThreadImpl = reinterpret_cast<ThreadImpl*>(pThread);
AutoPtr<ThreadData> pData = pThreadImpl->_pData;
try
{
reinterpret_cast<ThreadImpl*>(pThread)->_pTarget->run();
pData->pTarget->run();
}
catch (Exception& exc)
{
@@ -185,6 +197,8 @@ void* ThreadImpl::entry(void* pThread)
{
ErrorHandler::handle();
}
pData->pTarget = 0;
pData->done.set();
return 0;
}

View File

@@ -1,7 +1,7 @@
//
// Thread_WIN32.h
//
// $Id: //poco/Main/Foundation/src/Thread_WIN32.cpp#12 $
// $Id: //poco/Main/Foundation/src/Thread_WIN32.cpp#13 $
//
// Library: Foundation
// Package: Threading
@@ -110,6 +110,22 @@ void ThreadImpl::joinImpl()
}
bool ThreadImpl::joinImpl(long milliseconds)
{
if (!_thread) return true;
switch (WaitForSingleObject(_thread, milliseconds + 1))
{
case WAIT_TIMEOUT:
return false;
case WAIT_OBJECT_0:
return true;
default:
throw SystemException("cannot join thread");
}
}
bool ThreadImpl::isRunningImpl() const
{
if (_thread)

View File

@@ -1,13 +1,13 @@
//
// UTF16Encoding.cpp
//
// $Id: //poco/Main/Foundation/src/UTF16Encoding.cpp#12 $
// $Id: //poco/Main/Foundation/src/UTF16Encoding.cpp#13 $
//
// Library: Foundation
// Package: Text
// Module: UTF16Encoding
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -36,11 +36,20 @@
#include "Poco/UTF16Encoding.h"
#include "Poco/ByteOrder.h"
#include "Poco/String.h"
namespace Poco {
const char* UTF16Encoding::_names[] =
{
"UTF-16",
"UTF16",
NULL
};
const TextEncoding::CharacterMap UTF16Encoding::_charMap =
{
/* 00 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
@@ -105,6 +114,23 @@ void UTF16Encoding::setByteOrder(int byteOrderMark)
}
const char* UTF16Encoding::canonicalName() const
{
return _names[0];
}
bool UTF16Encoding::isA(const std::string& encodingName) const
{
for (const char** name = _names; *name; ++name)
{
if (Poco::icompare(encodingName, *name) == 0)
return true;
}
return false;
}
const TextEncoding::CharacterMap& UTF16Encoding::characterMap() const
{
return _charMap;

View File

@@ -1,13 +1,13 @@
//
// UTF8Encoding.cpp
//
// $Id: //poco/Main/Foundation/src/UTF8Encoding.cpp#12 $
// $Id: //poco/Main/Foundation/src/UTF8Encoding.cpp#13 $
//
// Library: Foundation
// Package: Text
// Module: UTF8Encoding
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -35,11 +35,20 @@
#include "Poco/UTF8Encoding.h"
#include "Poco/String.h"
namespace Poco {
const char* UTF8Encoding::_names[] =
{
"UTF-8",
"UTF8",
NULL
};
const TextEncoding::CharacterMap UTF8Encoding::_charMap =
{
/* 00 */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -71,6 +80,23 @@ UTF8Encoding::~UTF8Encoding()
}
const char* UTF8Encoding::canonicalName() const
{
return _names[0];
}
bool UTF8Encoding::isA(const std::string& encodingName) const
{
for (const char** name = _names; *name; ++name)
{
if (Poco::icompare(encodingName, *name) == 0)
return true;
}
return false;
}
const TextEncoding::CharacterMap& UTF8Encoding::characterMap() const
{
return _charMap;

View File

@@ -1,13 +1,13 @@
//
// Windows1252Encoding.cpp
//
// $Id: //poco/Main/Foundation/src/Windows1252Encoding.cpp#6 $
// $Id: //poco/Main/Foundation/src/Windows1252Encoding.cpp#7 $
//
// Library: Foundation
// Package: Text
// Module: Windows1252Encoding
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@@ -35,11 +35,20 @@
#include "Poco/Windows1252Encoding.h"
#include "Poco/String.h"
namespace Poco {
const char* Windows1252Encoding::_names[] =
{
"Windows-1252",
"CP1252",
NULL
};
const TextEncoding::CharacterMap Windows1252Encoding::_charMap =
{
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f */
@@ -72,6 +81,23 @@ Windows1252Encoding::~Windows1252Encoding()
}
const char* Windows1252Encoding::canonicalName() const
{
return _names[0];
}
bool Windows1252Encoding::isA(const std::string& encodingName) const
{
for (const char** name = _names; *name; ++name)
{
if (Poco::icompare(encodingName, *name) == 0)
return true;
}
return false;
}
const TextEncoding::CharacterMap& Windows1252Encoding::characterMap() const
{
return _charMap;