Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions

ConstPointer Tools_DynamicUTF8String::StrPtr (  )  [inline]

------------------------------------------------------------------------- function: StrPtr() description: Returns string contents as a pointer to a null-terminated memory block

  • Attention: By default, strings are not null-terminated.
  • StrPtr() performs three checks to guarantee that a null-terminated string be returned:
  • If the string is unassigned, a pointer to a static, null-terminated memory block with zero length is returned.
  • If the string is assigned, it is checked if the last buffer element is a null terminator. If so, we're done. If not, a null-terminator is appended behind the actual end of the string. This may result in reallocation of the whole string. If reallocation fails, a pointer to a static, null-terminated memory block with zero length is returned.
  • see also: Data() arguments: none return value: (ConstPointer) pointer to null-terminated string --------------------------------------------------------------------------

Definition at line 967 of file Tools_DynamicUTF8String.hpp.

References Begin(), Tools_DynamicUTF8StringBuffer::ElementCount(), Tools_DynamicUTF8StringBuffer::End(), Tools_DynamicUTF8StringBuffer::IsEmpty(), Tools_UTF8StringElement::NullTerminator(), and Tools_DynamicUTF8StringBuffer::ProvideCapacity().

Referenced by CharPtr(), Studio_DBFSObject::copyItem(), Studio_DBFSObject::createFile(), Studio_DBFSObject::createFolder(), Studio_Connection::dbLogOn(), DBMCli_EventDispatcher::DBMCli_EventDispatcher(), Studio_DBFSObject::deleteFile(), Studio_DBFSObject::deleteFolder(), StudioWeb_StoredQueryTree::doService(), StudioTD_TableDef::findIncompleteDefs(), StudioWeb_Result::getError(), Studio_DBFSObject::getValidDBFS(), StudioWeb_Result::handleError(), ls05ConvertFromUCS2Simple(), ls05ConvertFromUTF8(), ls05StrToUpr(), ls26ExtractTablePages(), ls28LoadTablePages(), Studio_DBFSObject::moveItem(), Studio_DBFSObject::openDir(), Studio_DBFSObject::openFile(), Studio_DBFSObject::readFile(), StudioWeb_WebQuery::reloadFrame(), Studio_DBFSObject::renameItem(), Studio_DBFSObject::status(), StudioWeb_StoredQueryTree::storeDSQLObject(), and Tools_Template::writePage().

    {
        if (!IsAssigned())
            return EmptyString();
            
        if (m_Buffer.IsEmpty())
            return EmptyString();
        
        // m_Buffer has no reverse iterator. Using End() to obtain iterator.
        ReverseIterator iter = m_Buffer.End();
        if (*iter != ElementType::NullTerminator())
        {
            if (m_Buffer.ProvideCapacity(m_Buffer.ElementCount() + 1) == false)
            {
                return EmptyString();
            }
            *(m_Buffer.End()) = ElementType::NullTerminator();            
        }
        return ToPtr(Begin());
    }


Generated by  Doxygen 1.6.0   Back to index