std::string ActiveMQStreamMessage::readString()

in activemq-cpp/src/main/activemq/commands/ActiveMQStreamMessage.cpp [805:871]


std::string ActiveMQStreamMessage::readString() const {

    initializeReading();
    try {

        this->dataIn->mark(65);
        int type = this->dataIn->read();

        if (type == -1) {
            throw MessageEOFException("reached end of data", NULL);
        }
        if (type == PrimitiveValueNode::NULL_TYPE) {
            return "";
        }
        if (type == PrimitiveValueNode::BIG_STRING_TYPE) {
            return MarshallingSupport::readString32(*this->dataIn);
        }
        if (type == PrimitiveValueNode::STRING_TYPE) {
            return MarshallingSupport::readString16(*this->dataIn);
        }
        if (type == PrimitiveValueNode::LONG_TYPE) {
            return Long(this->dataIn->readLong()).toString();
        }
        if (type == PrimitiveValueNode::INTEGER_TYPE) {
            return Integer(this->dataIn->readInt()).toString();
        }
        if (type == PrimitiveValueNode::SHORT_TYPE) {
            return Short(this->dataIn->readShort()).toString();
        }
        if (type == PrimitiveValueNode::BYTE_TYPE) {
            return Byte((unsigned char) this->dataIn->readByte()).toString();
        }
        if (type == PrimitiveValueNode::FLOAT_TYPE) {
            return Float(this->dataIn->readFloat()).toString();
        }
        if (type == PrimitiveValueNode::DOUBLE_TYPE) {
            return Double(this->dataIn->readDouble()).toString();
        }
        if (type == PrimitiveValueNode::BOOLEAN_TYPE) {
            return (this->dataIn->readBoolean() ? Boolean::_TRUE : Boolean::_FALSE).toString();
        }

        if (type == PrimitiveValueNode::CHAR_TYPE) {
            return Character(this->dataIn->readChar()).toString();
        } else {
            this->dataIn->reset();
            throw MessageFormatException(" not a String type", NULL);
        }

    } catch (NumberFormatException& ex) {

        try {
            this->dataIn->reset();
        } catch (IOException& ioe) {
            throw CMSExceptionSupport::create(ioe);
        }

        throw CMSExceptionSupport::create(ex);

    } catch (EOFException& e) {
        throw CMSExceptionSupport::createMessageEOFException(e);
    } catch (IOException& e) {
        throw CMSExceptionSupport::createMessageFormatException(e);
    } catch (Exception& e) {
        throw CMSExceptionSupport::create(e);
    }
}