VirtualBox

Changeset 30746 in vbox for trunk/include/iprt/cpp


Ignore:
Timestamp:
Jul 8, 2010 4:42:49 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63518
Message:

Main: clean up spaghetti code in Console::configConstructor(): remove RC_CHECK() macro and delegate error handling to a few shared functions; move XML exceptions to separate header in IPRT to allow for reuse

Location:
trunk/include/iprt/cpp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/utils.h

    r30681 r30746  
    6464namespace iprt
    6565{
     66
    6667/**
    6768 * A simple class used to prevent copying and assignment.  Inherit from this
  • trunk/include/iprt/cpp/xml.h

    r28800 r30746  
    3434#include <memory>
    3535
    36 #include <iprt/cpp/ministring.h>
     36#include <iprt/cpp/exception.h>
    3737
    3838/* Forwards */
     
    5353//////////////////////////////////////////////////////////////////////////////
    5454
    55 /**
    56  * Base exception class.
    57  */
    58 class RT_DECL_CLASS Error : public std::exception
    59 {
    60 public:
    61 
    62     Error(const char *pcszMessage)
    63         : m_s(pcszMessage)
    64     {
    65     }
    66 
    67     Error(const Error &s)
    68         : std::exception(s),
    69           m_s(s.what())
    70     {
    71     }
    72 
    73     virtual ~Error() throw()
    74     {
    75     }
    76 
    77     void operator=(const Error &s)
    78     {
    79         m_s = s.what();
    80     }
    81 
    82     void setWhat(const char *pcszMessage)
    83     {
    84         m_s = pcszMessage;
    85     }
    86 
    87     virtual const char* what() const throw()
    88     {
    89         return m_s.c_str();
    90     }
    91 
    92 private:
    93     // hide the default constructor to make sure the extended one above is always used
    94     Error();
    95 
    96     iprt::MiniString m_s;
    97 };
    98 
    99 class RT_DECL_CLASS LogicError : public Error
     55class RT_DECL_CLASS LogicError : public iprt::Error
    10056{
    10157public:
    10258
    10359    LogicError(const char *aMsg = NULL)
    104         : xml::Error(aMsg)
     60        : iprt::Error(aMsg)
    10561    {}
    10662
     
    10864};
    10965
    110 class RT_DECL_CLASS RuntimeError : public Error
     66class RT_DECL_CLASS RuntimeError : public iprt::Error
    11167{
    11268public:
    11369
    11470    RuntimeError(const char *aMsg = NULL)
    115         : xml::Error(aMsg)
     71        : iprt::Error(aMsg)
    11672    {}
    11773};
     
    173129    int mRC;
    174130};
    175 
    176131
    177132/**
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette