/** * This file is part of the KDE project * Copyright (C) 2008 Kevin Ottens * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef QTJOLIE_SODEPHELPERS_P_H #define QTJOLIE_SODEPHELPERS_P_H #include #include #include #include "value.h" #include "fault.h" #include "message.h" namespace Jolie { inline void sodepWrite(QIODevice &io, double value) { const char *in = (const char*)&value; char out[8]; for (int i=0; i<8; ++i) { out[i] = in[7-i]; } io.write(out, 8); } inline void sodepWrite(QIODevice &io, qint32 value) { const char *in = (const char*)&value; char out[4]; for (int i=0; i<4; ++i) { out[i] = in[3-i]; } io.write(out, 4); } inline void sodepWrite(QIODevice &io, qint64 value) { const char *in = (const char*)&value; char out[8]; for (int i=0; i<8; ++i) { out[i] = in[7-i]; } io.write(out, 8); } inline void sodepWrite(QIODevice &io, const QString &value) { QByteArray data = value.toUtf8(); sodepWrite(io, data.size()); io.write(data); } inline void sodepWrite(QIODevice &io, const Value &value) { if (value.isDouble()) { io.putChar(3); sodepWrite(io, value.toDouble()); } else if (value.isInt()) { io.putChar(2); sodepWrite(io, value.toInt()); } else if (value.isString()) { io.putChar(1); sodepWrite(io, value.toString()); } else { io.putChar(0); } sodepWrite(io, value.childrenNames().size()); foreach (const QString &name, value.childrenNames()) { sodepWrite(io, name); QList values = value.children(name); qint32 valueCount = values.size(); sodepWrite(io, valueCount); for (int j=0; j