VirtualBox

Changeset 16539 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Feb 5, 2009 11:31:33 PM (16 years ago)
Author:
vboxsync
Message:

Main: remove special string class in XML exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/xml.h

    r16538 r16539  
    3131#define ___VBox_vboxxml_h
    3232
    33 #include <iprt/cdefs.h>
    34 #include <iprt/cpputils.h>
    35 
    36 /* these conflict with numeric_digits<>::min and max */
    37 #undef min
    38 #undef max
    39 
    40 #include <iprt/mem.h>
    41 
    4233#ifndef IN_RING3
    4334# error "There are no XML APIs available in Ring-0 Context!"
     
    112103
    113104    Error(const char *aMsg = NULL)
    114         : m (aMsg ? Str::New (aMsg) : NULL) {}
     105        : m(aMsg) {}
    115106
    116107    virtual ~Error() throw() {}
    117108
    118     void setWhat (const char *aMsg) { m = aMsg ? Str::New (aMsg) : NULL; }
    119 
    120     const char *what() const throw() { return m.is_null() ? NULL : m->str; }
     109    void setWhat (const char *aMsg) { m = aMsg; }
     110
     111    const char* what() const throw() { return m.c_str(); }
    121112
    122113private:
     
    124115//     Error() {};     // hide the default constructor to make sure the extended one above is always used
    125116
    126     /** smart string with support for reference counting */
    127     struct Str
    128     {
    129         size_t ref() { return ++ refs; }
    130         size_t unref() { return -- refs; }
    131 
    132         size_t refs;
    133         char str [1];
    134 
    135         static Str *New (const char *aStr)
    136         {
    137             Str *that = (Str *) RTMemAllocZ (sizeof (Str) + strlen (aStr));
    138             AssertReturn (that, NULL);
    139             strcpy (that->str, aStr);
    140             return that;
    141         }
    142 
    143         void operator delete (void *that, size_t) { RTMemFree (that); }
    144     };
    145 
    146     stdx::auto_ref_ptr <Str> m;
     117    com::Utf8Str m;
    147118};
    148119
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