VirtualBox

Changeset 35128 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Dec 15, 2010 12:38:41 PM (14 years ago)
Author:
vboxsync
Message:

Main: more backslash conversion in settings read/write, so add generic methods to XML classes

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/ministring.cpp

    r33605 r35128  
    212212
    213213    return npos;
     214}
     215
     216void MiniString::findReplace(char cFind, char cReplace)
     217{
     218    for (size_t i = 0; i < length(); ++i)
     219    {
     220        char *p = &m_psz[i];
     221        if (*p == cFind)
     222            *p = cReplace;
     223    }
    214224}
    215225
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r33835 r35128  
    831831    {
    832832        str = pAttr->getValue();
     833        return true;
     834    }
     835
     836    return false;
     837}
     838
     839/**
     840 * Like getAttributeValue (ministring variant), but makes sure that all backslashes
     841 * are converted to forward slashes.
     842 * @param pcszMatch
     843 * @param str
     844 * @return
     845 */
     846bool ElementNode::getAttributeValuePath(const char *pcszMatch, iprt::MiniString &str) const
     847{
     848    if (getAttributeValue(pcszMatch, str))
     849    {
     850        str.findReplace('\\', '/');
    833851        return true;
    834852    }
     
    10541072
    10551073/**
     1074 * Like setAttribute (ministring variant), but replaces all backslashes with forward slashes
     1075 * before calling that one.
     1076 * @param pcszName
     1077 * @param strValue
     1078 * @return
     1079 */
     1080AttributeNode* ElementNode::setAttributePath(const char *pcszName, const iprt::MiniString &strValue)
     1081{
     1082    iprt::MiniString strTemp(strValue);
     1083    strTemp.findReplace('\\', '/');
     1084    return setAttribute(pcszName, strTemp.c_str());
     1085}
     1086
     1087/**
    10561088 * Sets the given attribute; overloaded version for int32_t.
    10571089 *
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