示例#1
0
bool XMLElement::RemoveChildren(const char* name)
{
    if ((!file_ || !node_) && !xpathNode_)
        return false;

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    if (!CStringLength(name))
    {
        for (;;)
        {
            pugi::xml_node child = node.last_child();
            if (child.empty())
                break;
            const_cast<pugi::xml_node&>(node).remove_child(child);
        }
    }
    else
    {
        for (;;)
        {
            pugi::xml_node child = node.child(name);
            if (child.empty())
                break;
            const_cast<pugi::xml_node&>(node).remove_child(child);
        }
    }

    return true;
}
示例#2
0
TSharableString<T>::TSharableString(
	const char* inCString)

: GSharableString(sizeof (mString), mString)
{
	Assign(inCString, CStringLength(inCString));
}	
示例#3
0
void String::Replace(unsigned pos, unsigned length, const char* replaceWith)
{
    // If substring is illegal, do nothing
    if (pos + length > length_)
        return;

    Replace(pos, length, replaceWith, CStringLength(replaceWith));
}
示例#4
0
文件: String.cpp 项目: joewan/turso3d
void String::Replace(size_t pos, size_t numChars, const char* replaceWith)
{
    // If substring is illegal, do nothing
    if (pos + numChars > Length())
        return;
    
    Replace(pos, numChars, replaceWith, CStringLength(replaceWith));
}
示例#5
0
文件: String.cpp 项目: joewan/turso3d
String& String::operator = (char* rhs)
{
    size_t rhsLength = CStringLength(rhs);
    Resize(rhsLength);
    CopyChars(Buffer(), rhs, rhsLength);
    
    return *this;
}
示例#6
0
文件: String.cpp 项目: joewan/turso3d
String& String::operator += (char* rhs)
{
    size_t rhsLength = CStringLength(rhs);
    size_t oldLength = Length();
    Resize(Length() + rhsLength);
    CopyChars(Buffer() + oldLength, rhs, rhsLength);
    
    return *this;
}
示例#7
0
文件: String.cpp 项目: joewan/turso3d
String String::operator + (const char* rhs) const
{
    size_t rhsLength = CStringLength(rhs);
    String ret;
    ret.Resize(Length() + rhsLength);
    CopyChars(ret.Buffer(), Buffer(), Length());
    CopyChars(ret.Buffer() + Length(), rhs, rhsLength);
    
    return ret;
}
示例#8
0
XMLElement XMLElement::GetNext(const char* name) const
{
    if (!file_ || (!node_ && !xpathNode_))
        return XMLElement();

    const pugi::xml_node& node = xpathNode_ ? xpathNode_->node() : pugi::xml_node(node_);
    if (!CStringLength(name))
        return XMLElement(file_, node.next_sibling().internal_object());
    else
        return XMLElement(file_, node.next_sibling(name).internal_object());
}
示例#9
0
文件: String.cpp 项目: joewan/turso3d
bool String::ToBool(const char* str)
{
    size_t length = CStringLength(str);
    
    for (size_t i = 0; i < length; ++i)
    {
        char c = Turso3D::ToLower(str[i]);
        if (c == 't' || c == 'y' || c == '1')
            return true;
        else if (c != ' ' && c != '\t')
            break;
    }
    
    return false;
}
示例#10
0
文件: String.cpp 项目: joewan/turso3d
Vector<String> String::Split(const char* str, char separator)
{
    Vector<String> ret;
    size_t pos = 0;
    size_t length = CStringLength(str);
    
    while (pos < length)
    {
        if (str[pos] != separator)
            break;
        ++pos;
    }
    
    while (pos < length)
    {
        size_t start = pos;
        
        while (start < length)
        {
            if (str[start] == separator)
                break;
            
            ++start;
        }
        
        if (start == length)
        {
            ret.Push(String(&str[pos]));
            break;
        }
        
        size_t end = start;
        
        while (end < length)
        {
            if (str[end] != separator)
                break;
            
            ++end;
        }
        
        ret.Push(String(&str[pos], start - pos));
        pos = end;
    }
    
    return ret;
}
示例#11
0
文件: String.cpp 项目: joewan/turso3d
String& String::AppendWithFormatArgs(const char* formatStr, va_list args)
{
    size_t pos = 0, lastPos = 0;
    size_t length = CStringLength(formatStr);

    for (;;)
    {
        // Scan the format string and find %a argument where a is one of d, f, s ...
        while (pos < length && formatStr[pos] != '%')
            pos++;
        Append(formatStr + lastPos, pos - lastPos);
        if (pos >= length)
            break;
        
        char arg = formatStr[pos + 1];
        pos += 2;
        lastPos = pos;
        
        switch (arg)
        {
        // Integer
        case 'd':
        case 'i':
            {
                int arg = va_arg(args, int);
                Append(String(arg));
                break;
            }
            
        // Unsigned
        case 'u':
            {
                unsigned arg = va_arg(args, unsigned);
                Append(String(arg));
                break;
            }
            
        // Real
        case 'f':
            {
                double arg = va_arg(args, double);
                Append(String(arg));
                break;
            }
            
        // Character
        case 'c':
            {
                int arg = va_arg(args, int);
                Append((char)arg);
                break;
            }
            
        // C string
        case 's':
            {
                char* arg = va_arg(args, char*);
                Append(arg);
                break;
            }
            
        // Hex
        case 'x':
            {
                char buf[CONVERSION_BUFFER_LENGTH];
                int arg = va_arg(args, int);
                int arglen = sprintf(buf, "%x", arg);
                Append(buf, arglen);
                break;
            }
            
        // Pointer
        case 'p':
            {
                char buf[CONVERSION_BUFFER_LENGTH];
                int arg = va_arg(args, int);
                int arglen = sprintf(buf, "%p", reinterpret_cast<void*>(arg));
                Append(buf, arglen);
                break;
            }
            
        case '%':
            {
                Append("%", 1);
                break;
            }
        }
    }

    return *this;
}