Ejemplo n.º 1
0
    const AxisChar* WhiteSpace::processWhiteSpace(const AxisChar* valueToProcess)
    {
	#ifdef ENABLE_AXISTRACE
		if (axiscpp::AxisTrace::isTraceOn())
			axiscpp::AxisTrace::traceEntry("WhiteSpace", "processWhiteSpace", this, 1,
					TRACETYPE_STRING, 0, ((void*)&valueToProcess));	  /* AUTOINSERTED TRACE */
	#endif

        AxisString valueAsString = valueToProcess;
        AxisChar* returnValue = NULL;
     
        switch (m_WhiteSpace)
        {
            case PRESERVE:
                	{
		#ifdef ENABLE_AXISTRACE
			const AxisChar* traceRet = (valueToProcess);
			if (axiscpp::AxisTrace::isTraceOn())
				axiscpp::AxisTrace::traceExit("WhiteSpace", "processWhiteSpace", this, 1,
					TRACETYPE_STRING, 0, ((void*)&traceRet));	  /* AUTOINSERTED TRACE */
			return traceRet;
		#else
			return valueToProcess;
		#endif
	}

            case REPLACE:
                {
                    returnValue = (AxisChar*) replaceWhiteSpace(valueAsString).c_str();
                }
                break;
            case COLLAPSE:
                {
                    returnValue = (AxisChar*) collapseWhiteSpace(valueAsString).c_str();               
                }
                break;
        }
        
        if (m_Buf)
        {
            delete [] m_Buf;
            m_Buf = NULL;
        }
        m_Buf = new char[strlen (returnValue) + 1];
        strcpy (m_Buf, returnValue);
        	{
		#ifdef ENABLE_AXISTRACE
			const AxisChar* traceRet = (m_Buf);
			if (axiscpp::AxisTrace::isTraceOn())
				axiscpp::AxisTrace::traceExit("WhiteSpace", "processWhiteSpace", this, 2,
					TRACETYPE_STRING, 0, ((void*)&traceRet));	  /* AUTOINSERTED TRACE */
			return traceRet;
		#else
			return m_Buf;
		#endif
	}

    }
Ejemplo n.º 2
0
void Client::on_actionConnect_triggered()
{
	QDataStream in(tcpSocket);

	if (promptConnect->exec())
	{
		QString hostname = promptConnect->hostnameEdit->text();
		quint16 port = promptConnect->portEdit->text().toInt();
		promptConnect->usernameEdit->setText(replaceWhiteSpace(promptConnect->usernameEdit->text()));

		QString status = tr("-> Connecting to %1 on port %2.").arg(hostname).arg(port);
		new QListWidgetItem(status, ui.messageList);
		ui.messageList->scrollToBottom();

		tcpSocket->abort();
		tcpSocket->connectToHost(hostname, port);

	}
}
Ejemplo n.º 3
0
    /**
     * Collapses all white space in a string.
     * All occurances of tab, line feed and carriage return are replaced with
     * space, after which all sequences of spaces are collapsed to a single space.
     * 
     * @param value The string to have all white space collapsed
     * @return AxisString The string with all white space collapsed.
     */
    const AxisString& WhiteSpace::collapseWhiteSpace(AxisString& value)
    {
	#ifdef ENABLE_AXISTRACE
		if (axiscpp::AxisTrace::isTraceOn())
			axiscpp::AxisTrace::traceEntry("WhiteSpace", "collapseWhiteSpace", this, 1,
					TRACETYPE_STLSTRING, 0, ((void*)&value));	  /* AUTOINSERTED TRACE */
	#endif

        if (value.empty ())
        {
            	{
		#ifdef ENABLE_AXISTRACE
			const AxisString& traceRet = (value);
			if (axiscpp::AxisTrace::isTraceOn())
				axiscpp::AxisTrace::traceExit("WhiteSpace", "collapseWhiteSpace", this, 1,
					TRACETYPE_STLSTRING, 0, ((void*)&traceRet));	  /* AUTOINSERTED TRACE */
			return traceRet;
		#else
			return value;
		#endif
	}

        }
        AxisString replacedValue = replaceWhiteSpace(value);
        /*
         * Strip leading and trailing space
         */
        AxisString leadingStripped = stripLeadingWhiteSpace(replacedValue);
        replacedValue = stripTrailingWhiteSpace(leadingStripped);
        // Initialize return value to empty string
        m_strReturnVal = "";
        /*
         * Find space character and returns the first any of chars find
         * position
         */ 
        unsigned long nPos = replacedValue.find_first_of (' ');
    
        /* Check for position validity */
        if (AxisString::npos == nPos)
        {
            m_strReturnVal.assign (replacedValue);
            	{
		#ifdef ENABLE_AXISTRACE
			const AxisString& traceRet = (m_strReturnVal);
			if (axiscpp::AxisTrace::isTraceOn())
				axiscpp::AxisTrace::traceExit("WhiteSpace", "collapseWhiteSpace", this, 2,
					TRACETYPE_STLSTRING, 0, ((void*)&traceRet));	  /* AUTOINSERTED TRACE */
			return traceRet;
		#else
			return m_strReturnVal;
		#endif
	}

        }
    
        unsigned long nOldIdx = 0;            // Counter value
        while (AxisString::npos != nPos)
        {
            m_strReturnVal.append (replacedValue.substr (nOldIdx, nPos - nOldIdx));
            /**
             * Only copy space character across if it's NOT followed by             
             * another space character
             */
            if ( replacedValue.at(nPos+1) != ' ')
            {
               m_strReturnVal.append (" ");
            }
            nOldIdx = ++nPos;     // Get old position
            /* 
             * Find the next entity reference characters from previous found 
             * position,
             */ 
            nPos = replacedValue.find_first_of (' ', nPos);
        }
    
        unsigned long nDataLen = replacedValue.length ();    // Get the length of the field value
        unsigned long nLen = nDataLen - nOldIdx;      // Get remaining number of characters   
        if (nLen > 0)
        {
            /*
             * Append the remaining data
             */
            m_strReturnVal += replacedValue.substr (nOldIdx, nLen); 
        }
        	{
		#ifdef ENABLE_AXISTRACE
			const AxisString& traceRet = (m_strReturnVal);
			if (axiscpp::AxisTrace::isTraceOn())
				axiscpp::AxisTrace::traceExit("WhiteSpace", "collapseWhiteSpace", this, 3,
					TRACETYPE_STLSTRING, 0, ((void*)&traceRet));	  /* AUTOINSERTED TRACE */
			return traceRet;
		#else
			return m_strReturnVal;
		#endif
	}

    }