Moved CPrimaryScreen and CSecondaryScreen to the lib/synergy

and the platform specific implementations to lib/platform.
Added an lib/arch method to query the platform's native wide
character encoding and changed CUnicode to use it.  All
platform dependent code is now in lib/arch, lib/platform,
and the programs under cmd.  Also added more documentation.
This commit is contained in:
crs
2003-01-05 21:48:54 +00:00
parent f65921bc3f
commit e9cc0b434e
70 changed files with 672 additions and 156 deletions

View File

@@ -54,12 +54,7 @@ static const int g_prioritySuffixLength = 2;
static const int g_priorityPad = g_maxPriorityLength +
g_prioritySuffixLength;
//
// CLogLock
//
// Convenience object to lock/unlock a mutex.
//
//! Convenience object to lock/unlock a mutex
class CLogLock {
public:
CLogLock(CArchMutex mutex) : m_mutex(mutex) { ARCH->lockMutex(m_mutex); }

View File

@@ -414,13 +414,31 @@ wchar_t*
CUnicode::UTF8ToWideChar(const CString& src, UInt32& size, bool* errors)
{
// convert to platform's wide character encoding
#if WINDOWS_LIKE
CString tmp = UTF8ToUTF16(src, errors);
size = tmp.size() >> 1;
#elif UNIX_LIKE
CString tmp = UTF8ToUCS4(src, errors);
size = tmp.size() >> 2;
#endif
CString tmp;
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
tmp = UTF8ToUCS2(src, errors);
size = tmp.size() >> 1;
break;
case IArchString::kUCS4:
tmp = UTF8ToUCS4(src, errors);
size = tmp.size() >> 2;
break;
case IArchString::kUTF16:
tmp = UTF8ToUTF16(src, errors);
size = tmp.size() >> 1;
break;
case IArchString::kUTF32:
tmp = UTF8ToUTF32(src, errors);
size = tmp.size() >> 2;
break;
default:
assert(0 && "unknown wide character encoding");
}
// copy to a wchar_t array
wchar_t* dst = new wchar_t[size];
@@ -434,11 +452,23 @@ CUnicode::wideCharToUTF8(const wchar_t* src, UInt32 size, bool* errors)
// convert from platform's wide character encoding.
// note -- this must include a wide nul character (independent of
// the CString's nul character).
#if WINDOWS_LIKE
return doUTF16ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
#elif UNIX_LIKE
return doUCS4ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
#endif
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
return doUCS2ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
case IArchString::kUCS4:
return doUCS4ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
case IArchString::kUTF16:
return doUTF16ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
case IArchString::kUTF32:
return doUTF32ToUTF8(reinterpret_cast<const UInt8*>(src), size, errors);
default:
assert(0 && "unknown wide character encoding");
return CString();
}
}
CString

View File

@@ -17,30 +17,17 @@
#include <cerrno>
#include <cstdarg>
// win32 wants a const char* argument to std::exception c'tor
#if WINDOWS_LIKE
#include <windows.h>
#define STDEXCEPTARG ""
#endif
// default to no argument
#ifndef STDEXCEPTARG
#define STDEXCEPTARG
#endif
//
// XBase
//
XBase::XBase() :
// exception(STDEXCEPTARG),
m_what()
{
// do nothing
}
XBase::XBase(const CString& msg) :
// exception(STDEXCEPTARG),
m_what(msg)
{
// do nothing

View File

@@ -16,17 +16,12 @@
#define XBASE_H
#include "CString.h"
/*
#include "stdpre.h"
#include <exception>
#include "stdpost.h"
*/
//! Exception base class
/*!
This is the base class of most exception types.
*/
class XBase /*: public std::exception*/ {
class XBase {
public:
//! Use getWhat() as the result of what()
XBase();
@@ -34,7 +29,7 @@ public:
XBase(const CString& msg);
virtual ~XBase();
// std::exception overrides
//! Reason for exception
virtual const char* what() const;
protected: