XBase.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #include "XBase.h"
00016 #include "CStringUtil.h"
00017 #include <cerrno>
00018 #include <cstdarg>
00019 
00020 //
00021 // XBase
00022 //
00023 
00024 XBase::XBase() :
00025     m_what()
00026 {
00027     // do nothing
00028 }
00029 
00030 XBase::XBase(const CString& msg) :
00031     m_what(msg)
00032 {
00033     // do nothing
00034 }
00035 
00036 XBase::~XBase()
00037 {
00038     // do nothing
00039 }
00040 
00041 const char*
00042 XBase::what() const
00043 {
00044     if (m_what.empty()) {
00045         m_what = getWhat();
00046     }
00047     return m_what.c_str();
00048 }
00049 
00050 CString
00051 XBase::format(const char* /*id*/, const char* fmt, ...) const throw()
00052 {
00053     // FIXME -- lookup message string using id as an index.  set
00054     // fmt to that string if it exists.
00055 
00056     // format
00057     CString result;
00058     va_list args;
00059     va_start(args, fmt);
00060     try {
00061         result = CStringUtil::vformat(fmt, args);
00062     }
00063     catch (...) {
00064         // ignore
00065     }
00066     va_end(args);
00067 
00068     return result;
00069 }

Generated on Fri Nov 6 00:18:46 2009 for synergy-plus by  doxygen 1.4.7