VirtualBox

Changeset 16538 in vbox


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

Main: replace redundant xml::FmtStr with com::Utf8StrFmt

Location:
trunk
Files:
5 edited

Legend:

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

    r16188 r16538  
    4747#include <VBox/xml.h>
    4848
    49 #include <stdarg.h>
     49// #include <stdarg.h>
    5050
    5151
     
    592592        catch (const ENoValue &)
    593593        {
    594             throw ENoValue(xml::FmtStr("No such attribute '%s'", aName));
     594            throw ENoValue(com::Utf8StrFmt("No such attribute '%s'", aName));
    595595        }
    596596    }
     
    647647        catch (const ENoValue &)
    648648        {
    649             throw ENoValue(xml::FmtStr("No value for attribute '%s'", aName));
     649            throw ENoValue(com::Utf8StrFmt("No value for attribute '%s'", aName));
    650650        }
    651651    }
     
    761761        if (key.isNull())
    762762        {
    763             throw ENoKey(xml::FmtStr("No such key '%s'", aName));
     763            throw ENoKey(com::Utf8StrFmt("No such key '%s'", aName));
    764764        }
    765765        return key;
  • trunk/include/VBox/xml.h

    r16325 r16538  
    101101{
    102102
    103 // Helpers
    104 //////////////////////////////////////////////////////////////////////////////
    105 
    106 /**
    107  * Temporary holder for the formatted string.
    108  *
    109  * Instances of this class are used for passing the formatted string as an
    110  * argument to an Error constructor or to another function that takes
    111  * <tr>const char *</tr> and makes a copy of the string it points to.
    112  */
    113 class VBOXXML_CLASS FmtStr
    114 {
    115 public:
    116 
    117     /**
    118      * Creates a formatted string using the format string and a set of
    119      * printf-like arguments.
    120      */
    121     FmtStr(const char *aFmt, ...)
    122     {
    123         va_list args;
    124         va_start(args, aFmt);
    125         RTStrAPrintfV(&mStr, aFmt, args);
    126         va_end(args);
    127     }
    128 
    129     ~FmtStr() { RTStrFree (mStr); }
    130 
    131     operator const char *() { return mStr; }
    132 
    133 private:
    134 
    135     DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (FmtStr)
    136 
    137     char *mStr;
    138 };
    139 
    140 
    141103// Exceptions
    142104//////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/VirtualBoxBase.cpp

    r16188 r16538  
    2121 * additional information or have any questions.
    2222 */
     23
     24#include <iprt/semaphore.h>
     25#include <iprt/asm.h>
    2326
    2427#if !defined (VBOX_WITH_XPCOM)
     
    3437#include "VirtualBoxErrorInfoImpl.h"
    3538#include "Logging.h"
    36 
    37 #include <iprt/semaphore.h>
    38 #include <iprt/asm.h>
    3939
    4040// VirtualBoxBaseProto methods
     
    12701270        strlen (aValue) != RTUUID_STR_LENGTH + 1 ||
    12711271        aValue [RTUUID_STR_LENGTH] != '}')
    1272         throw ENoConversion(xml::FmtStr("'%s' is not Guid", aValue));
     1272        throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid", aValue));
    12731273
    12741274    /* strip { and } */
     
    12801280    int vrc = RTUuidFromStr (&uuid, buf);
    12811281    if (RT_FAILURE (vrc))
    1282         throw ENoConversion(xml::FmtStr("'%s' is not Guid (%Rrc)", aValue, vrc));
     1282        throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid (%Rrc)", aValue, vrc));
    12831283
    12841284    return com::Guid (uuid);
  • trunk/src/VBox/Main/xml/Settings.cpp

    r16188 r16538  
    1919 */
    2020
    21 #include "VBox/settings.h"
    22 
    23 #include "Logging.h"
    24 
    2521#include <iprt/err.h>
    2622#include <iprt/file.h>
     
    4036#include <libxslt/xsltutils.h>
    4137
    42 #include <string.h>
    43 
     38#include <list>
     39
     40// #include <string.h>
     41
     42#include "VBox/settings.h"
     43
     44#include "Logging.h"
    4445
    4546namespace settings
     
    5859        return aChar - 'a' + 0xA;
    5960
    60     throw ENoConversion(xml::FmtStr ("'%c' (0x%02X) is not hex", aChar, aChar));
     61    throw ENoConversion(com::Utf8StrFmt("'%c' (0x%02X) is not hex", aChar, aChar));
    6162}
    6263
     
    121122    }
    122123
    123     throw ENoConversion(xml::FmtStr("'%s' is not integer", aValue));
     124    throw ENoConversion(com::Utf8StrFmt("'%s' is not integer", aValue));
    124125}
    125126
     
    142143        return false;
    143144
    144     throw ENoConversion(xml::FmtStr("'%s' is not bool", aValue));
     145    throw ENoConversion(com::Utf8StrFmt("'%s' is not bool", aValue));
    145146}
    146147
     
    176177        }
    177178        else
    178             throw ENoConversion(xml::FmtStr("'%s' is not UTC date", aValue));
    179     }
    180 
    181     throw ENoConversion(xml::FmtStr("'%s' is not ISO date", aValue));
     179            throw ENoConversion(com::Utf8StrFmt("'%s' is not UTC date", aValue));
     180    }
     181
     182    throw ENoConversion(com::Utf8StrFmt("'%s' is not ISO date", aValue));
    182183}
    183184
     
    192193    /* therefore, the original length must be even */
    193194    if (len % 2 != 0)
    194         throw ENoConversion(xml::FmtStr("'%.*s' is not binary data",
    195                                         aLen, aValue));
     195        throw ENoConversion(com::Utf8StrFmt("'%.*s' is not binary data",
     196                                            aLen, aValue));
    196197
    197198    stdx::char_auto_ptr result (new char [len]);
     
    265266    RTTIME time;
    266267    if (!RTTimeExplode (&time, &aValue))
    267         throw ENoConversion(xml::FmtStr("timespec %lld ms is invalid",
    268                                         RTTimeSpecGetMilli (&aValue)));
     268        throw ENoConversion(com::Utf8StrFmt("timespec %lld ms is invalid",
     269                                            RTTimeSpecGetMilli (&aValue)));
    269270
    270271    /* Store ISO date (xsd:dateTime). The format is:
  • trunk/src/VBox/Main/xml/xml.cpp

    r16325 r16538  
    2121#include "Logging.h"
    2222
    23 #include <boost/shared_ptr.hpp>
    24 
     23#include <iprt/cdefs.h>
    2524#include <iprt/err.h>
    2625#include <iprt/file.h>
     
    3938#include <list>
    4039#include <map>
     40#include <boost/shared_ptr.hpp>
    4141
    4242#include "VBox/xml.h"
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