VirtualBox

Changeset 30949 in vbox


Ignore:
Timestamp:
Jul 21, 2010 11:35:03 AM (15 years ago)
Author:
vboxsync
Message:

cpp/exception.h: cleanups.

File:
1 edited

Legend:

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

    r30833 r30949  
    11/** @file
    2  * IPRT - C++ Utilities (useful templates, defines and such).
     2 * IPRT - C++ Base Exceptions.
    33 */
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2010 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424 */
    2525
    26 #ifndef ___iprt_exception_h
    27 #define ___iprt_exception_h
     26#ifndef ___iprt_cpp_exception_h
     27#define ___iprt_cpp_exception_h
    2828
    2929#include <iprt/cpp/ministring.h>
    3030
    31 /** @defgroup grp_rt_cpputils   C++ Exceptions
     31/** @defgroup grp_rt_cppxcpt    C++ Exceptions
    3232 * @ingroup grp_rt
    3333 * @{
     
    8282
    8383private:
    84     // hide the default constructor to make sure the extended one above is always used
     84    /* Hide the default constructor to make sure the extended one above is
     85       always used. */
    8586    Error();
    8687
     
    8889};
    8990
    90 } // namespace iprt
     91} /* namespace iprt */
    9192
    9293/** @} */
    9394
    94 #endif // ___iprt_cpputils_h
     95#endif
    9596
    96 /** @file
    97  * IPRT - C++ Utilities (useful templates, defines and such).
    98  */
    99 
    100 /*
    101  * Copyright (C) 2006-2007 Oracle Corporation
    102  *
    103  * This file is part of VirtualBox Open Source Edition (OSE), as
    104  * available from http://www.virtualbox.org. This file is free software;
    105  * you can redistribute it and/or modify it under the terms of the GNU
    106  * General Public License (GPL) as published by the Free Software
    107  * Foundation, in version 2 as it comes in the "COPYING" file of the
    108  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    109  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    110  *
    111  * The contents of this file may alternatively be used under the terms
    112  * of the Common Development and Distribution License Version 1.0
    113  * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
    114  * VirtualBox OSE distribution, in which case the provisions of the
    115  * CDDL are applicable instead of those of the GPL.
    116  *
    117  * You may elect to license modified versions of this file under the
    118  * terms and conditions of either the GPL or the CDDL or both.
    119  */
    120 
    121 #ifndef ___iprt_exception_h
    122 #define ___iprt_exception_h
    123 
    124 #include <iprt/cpp/ministring.h>
    125 
    126 /** @defgroup grp_rt_cpputils   C++ Exceptions
    127  * @ingroup grp_rt
    128  * @{
    129  */
    130 
    131 namespace iprt
    132 {
    133 
    134 /**
    135  * Base exception class for IPRT, derived from std::exception.
    136  * The XML exceptions are based on this.
    137  */
    138 class RT_DECL_CLASS Error
    139     : public std::exception
    140 {
    141 public:
    142 
    143     Error(const char *pcszMessage)
    144         : m_s(pcszMessage)
    145     {
    146     }
    147 
    148     Error(const iprt::MiniString &s)
    149         : m_s(s)
    150     {
    151     }
    152 
    153     Error(const Error &s)
    154         : std::exception(s),
    155           m_s(s.what())
    156     {
    157     }
    158 
    159     virtual ~Error() throw()
    160     {
    161     }
    162 
    163     void operator=(const Error &s)
    164     {
    165         m_s = s.what();
    166     }
    167 
    168     void setWhat(const char *pcszMessage)
    169     {
    170         m_s = pcszMessage;
    171     }
    172 
    173     virtual const char* what() const throw()
    174     {
    175         return m_s.c_str();
    176     }
    177 
    178 private:
    179     // hide the default constructor to make sure the extended one above is always used
    180     Error();
    181 
    182     iprt::MiniString m_s;
    183 };
    184 
    185 } // namespace iprt
    186 
    187 /** @} */
    188 
    189 #endif // ___iprt_cpputils_h
    190 
Note: See TracChangeset for help on using the changeset viewer.

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