More const ref for passing complex types

parent add6f769
......@@ -120,7 +120,7 @@ Q_DECLARE_METATYPE(Okteta::AbstractByteArrayModel*)
Q_DECLARE_METATYPE(TopLevelDataInformation*)
static inline void addRow(const char* tag, TopLevelDataInformation* structure, Okteta::Address addr,
Okteta::AbstractByteArrayModel* model, Okteta::ArrayChangeMetricsList changes, bool expected)
Okteta::AbstractByteArrayModel* model, const Okteta::ArrayChangeMetricsList& changes, bool expected)
{
QTest::newRow(tag) << structure << addr << model << changes << expected;
}
......
......@@ -72,7 +72,7 @@ public:
virtual int indexOf(const DataInformation* data) const = 0;
virtual BitCount64 offset(const DataInformation* child) const = 0;
virtual qint64 readData(Okteta::AbstractByteArrayModel* input, Okteta::Address address, BitCount64 bitsRemaining) = 0;
virtual bool setChildData(uint row, QVariant value, Okteta::AbstractByteArrayModel* out,
virtual bool setChildData(uint row, const QVariant& value, Okteta::AbstractByteArrayModel* out,
Okteta::Address address, BitCount64 bitsRemaining) = 0;
virtual BitCount32 sizeAt(uint index) = 0;
virtual Qt::ItemFlags childFlags(int row, int column, bool fileLoaded) = 0;
......
......@@ -84,7 +84,7 @@ public:
QScriptValue childType() const;
QScriptValue lengthFunction() const;
void setLengthFunction(QScriptValue newFunc);
void setLengthFunction(const QScriptValue& newFunc);
QScriptValue childToScriptValue(uint index, QScriptEngine* engine, ScriptHandlerInfo* handlerInfo) const;
virtual BitCount64 childPosition(const DataInformation* child, Okteta::Address start) const;
private:
......@@ -175,7 +175,7 @@ inline QScriptValue ArrayDataInformation::lengthFunction() const
return mAdditionalData.get(AdditionalData::ArrayLengthFunction).value<QScriptValue>();
}
inline void ArrayDataInformation::setLengthFunction(QScriptValue newFunc)
inline void ArrayDataInformation::setLengthFunction(const QScriptValue& newFunc)
{
setAdditionalFunction(AdditionalData::ArrayLengthFunction, newFunc, "array length function");
}
......
......@@ -155,7 +155,7 @@ qint64 ComplexArrayData::readData(Okteta::AbstractByteArrayModel* input, Okteta:
return readBits;
}
bool ComplexArrayData::setChildData(uint row, QVariant value, Okteta::AbstractByteArrayModel* out,
bool ComplexArrayData::setChildData(uint row, const QVariant& value, Okteta::AbstractByteArrayModel* out,
Okteta::Address address, BitCount64 bitsRemaining)
{
Q_ASSERT(row < unsigned(mChildren.size()));
......
......@@ -59,7 +59,7 @@ public:
virtual QScriptValue toScriptValue(uint index, QScriptEngine* engine, ScriptHandlerInfo* handlerInfo);
virtual qint64 readData(Okteta::AbstractByteArrayModel* input, Okteta::Address address, BitCount64 bitsRemaining);
virtual bool setChildData(uint row, QVariant value, Okteta::AbstractByteArrayModel* out,
virtual bool setChildData(uint row, const QVariant& value, Okteta::AbstractByteArrayModel* out,
Okteta::Address address, BitCount64 bitsRemaining);
virtual QWidget* createChildEditWidget(uint index, QWidget* parent) const;
......
......@@ -102,7 +102,7 @@ void PrimitiveArrayData<type>::readDataNonNativeOrder(uint numItems, Okteta::Abs
}
template<PrimitiveDataTypeEnum type>
bool PrimitiveArrayData<type>::setChildData(uint row, QVariant value, Okteta::AbstractByteArrayModel* out,
bool PrimitiveArrayData<type>::setChildData(uint row, const QVariant& value, Okteta::AbstractByteArrayModel* out,
Okteta::Address address, BitCount64 bitsRemaining)
{
Q_ASSERT(row < length());
......
......@@ -42,7 +42,7 @@ public:
virtual qint64 readData(Okteta::AbstractByteArrayModel* input, Okteta::Address address,
BitCount64 bitsRemaining);
virtual bool setChildData(uint row, QVariant value, Okteta::AbstractByteArrayModel* out,
virtual bool setChildData(uint row, const QVariant& value, Okteta::AbstractByteArrayModel* out,
Okteta::Address address, BitCount64 bitsRemaining);
virtual DataInformation* childAt(unsigned int idx);
......
......@@ -92,7 +92,7 @@ DataInformation* DataInformation::mainStructure()
}
void DataInformation::setValidationError(QString errorMessage)
void DataInformation::setValidationError(const QString& errorMessage)
{
if (errorMessage.isEmpty())
mAdditionalData.remove(AdditionalData::ValidationError);
......
......@@ -230,7 +230,7 @@ private:
/** So that this object can be wrapped by the correct javascript object*/
virtual QScriptClass* scriptClass(ScriptHandlerInfo* handlerInfo) const = 0;
private:
void setValidationError(QString errorMessage); //only called by ScriptHandler
void setValidationError(const QString& errorMessage); //only called by ScriptHandler
QSysInfo::Endian byteOrderFromSettings() const; //so there is no need to include structviewpreferences.h here
QString customToString(const QScriptValue& func) const;
protected:
......
......@@ -149,7 +149,7 @@ void DataInformationWithChildren::setChildren(const QVector<DataInformation*>& n
topLevelDataInformation()->_childCountChanged(this, 0, count);
}
void DataInformationWithChildren::setChildren(QScriptValue children)
void DataInformationWithChildren::setChildren(const QScriptValue& children)
{
if (children.isNull() || children.isUndefined())
{
......
......@@ -69,7 +69,7 @@ public:
/** Takes ownership of all elements */
void appendChildren(const QVector<DataInformation*>& newChildren, bool emitSignal = true);
void setChildren(const QVector<DataInformation*>& newChildren);
void setChildren(QScriptValue newChildren);
void setChildren(const QScriptValue& newChildren);
static QVector<DataInformation*> cloneList(const QVector<DataInformation*>& other, DataInformation* parent);
protected:
......
......@@ -38,7 +38,7 @@ public:
virtual bool isEnum() const;
EnumDefinition::Ptr enumValues() const;
void setEnumValues(QMap<AllPrimitiveTypes, QString> newValues);
void setEnumValues(const QMap<AllPrimitiveTypes, QString>& newValues);
private:
virtual QScriptClass* scriptClass(ScriptHandlerInfo* handlerInfo) const;
virtual QString valueStringImpl() const;
......@@ -57,7 +57,7 @@ inline EnumDefinition::Ptr EnumDataInformation::enumValues() const
return mEnum;
}
inline void EnumDataInformation::setEnumValues(QMap<AllPrimitiveTypes, QString> newValues)
inline void EnumDataInformation::setEnumValues(const QMap<AllPrimitiveTypes, QString>& newValues)
{
mEnum->setValues(newValues);
}
......
......@@ -38,7 +38,7 @@ class EnumDefinition: public QSharedData
{
public:
typedef QSharedDataPointer<EnumDefinition> Ptr;
EnumDefinition(const QMap<AllPrimitiveTypes, QString> values, const QString& name,
EnumDefinition(const QMap<AllPrimitiveTypes, QString>& values, const QString& name,
PrimitiveDataType type) :
QSharedData(), mName(name), mValues(values), mType(type) {}
EnumDefinition(const EnumDefinition& e) :
......@@ -49,7 +49,7 @@ public:
const QString value(AllPrimitiveTypes key) const;
PrimitiveDataType type() const;
const QString& name() const;
void setValues(QMap< AllPrimitiveTypes, QString > newValues);
void setValues(const QMap<AllPrimitiveTypes, QString>& newValues);
static QMap<AllPrimitiveTypes, QString> parseEnumValues(const QScriptValue& val,
const LoggerWithContext& logger, PrimitiveDataType type = Type_UInt64);
......@@ -88,7 +88,7 @@ inline const QString& EnumDefinition::name() const
return mName;
}
inline void EnumDefinition::setValues(QMap<AllPrimitiveTypes, QString> newValues)
inline void EnumDefinition::setValues(const QMap<AllPrimitiveTypes, QString>& newValues)
{
mValues = newValues; //causes the QSharedPointer to detach and copy
}
......
......@@ -34,7 +34,7 @@
#include <limits>
PointerDataInformation::PointerDataInformation(QString name, DataInformation* childType,
PointerDataInformation::PointerDataInformation(const QString& name, DataInformation* childType,
PrimitiveDataInformation* valueType, DataInformation* parent)
: PrimitiveDataInformationWrapper(name, valueType, parent), mPointerTarget(childType)
{
......
......@@ -34,7 +34,7 @@ public:
/** creates a new pointer
* takes ownership over @p childType and @p valueType
*/
PointerDataInformation(QString name, DataInformation* childType,
PointerDataInformation(const QString& name, DataInformation* childType,
PrimitiveDataInformation* valueType, DataInformation* parent);
virtual ~PointerDataInformation();
......
......@@ -68,7 +68,7 @@ BitCount64 StructureDataInformation::childPosition(const DataInformation* child,
return mParent->asDataInformation()->childPosition(this, start) + offset;
}
bool StructureDataInformation::readChildren(const QVector<DataInformation*> children,
bool StructureDataInformation::readChildren(const QVector<DataInformation*>& children,
Okteta::AbstractByteArrayModel* input, Okteta::Address address, BitCount64 bitsRemaining,
quint8* bitOffset, qint64* readBitsPtr, TopLevelDataInformation* top)
{
......
......@@ -39,7 +39,7 @@ public:
virtual BitCount64 childPosition(const DataInformation* child, Okteta::Address start) const;
static bool readChildren(const QVector<DataInformation*> children, Okteta::AbstractByteArrayModel *input,
static bool readChildren(const QVector<DataInformation*>& children, Okteta::AbstractByteArrayModel *input,
Okteta::Address address, BitCount64 bitsRemaining, quint8* bitOffset, qint64* readBitsPtr,
TopLevelDataInformation* top);
private:
......
......@@ -145,8 +145,8 @@ T* newStructOrUnion(const StructOrUnionParsedData& supd)
return structOrUnion;
}
QString generateLengthFunction(DataInformation* current, DataInformation* last, QString elemName,
QString currentString, const ParserInfo& info)
QString generateLengthFunction(DataInformation* current, DataInformation* last, const QString& elemName,
const QString& currentString, const ParserInfo& info)
{
if (!current) //reached top
return QString();
......
......@@ -554,7 +554,7 @@ TaggedUnionDataInformation* OsdParser::taggedUnionFromXML(const QDomElement& xml
return DataInformationFactory::newTaggedUnion(tpd);
}
OsdChildrenParser::OsdChildrenParser(const OsdParserInfo& info, QDomElement firstChild)
OsdChildrenParser::OsdChildrenParser(const OsdParserInfo& info, const QDomElement& firstChild)
: mInfo(info), mElem(firstChild)
{
}
......@@ -595,7 +595,7 @@ void OsdChildrenParser::setParent(DataInformation* newParent)
mInfo.parent = newParent;
}
SingleElementOsdChildrenParser::SingleElementOsdChildrenParser(const OsdParserInfo& info, QDomElement element)
SingleElementOsdChildrenParser::SingleElementOsdChildrenParser(const OsdParserInfo& info, const QDomElement& element)
: OsdChildrenParser(info, element), mParsed(false)
{
if (mElem.isNull())
......
......@@ -43,7 +43,7 @@ class ScriptLogger;
struct OsdParserInfo : public ParserInfo {
inline OsdParserInfo(const QString& name, ScriptLogger* logger, DataInformation* parent,
QScriptEngine* engine, QVector<EnumDefinition::Ptr> enums)
QScriptEngine* engine, const QVector<EnumDefinition::Ptr>& enums)
: ParserInfo(name, logger, parent, engine), enums(enums) {}
inline OsdParserInfo(const OsdParserInfo& i) : ParserInfo(i), enums(i.enums) {}
inline ~OsdParserInfo() {}
......@@ -99,7 +99,7 @@ private:
class OsdChildrenParser : public ChildrenParser {
public:
OsdChildrenParser(const OsdParserInfo& info, QDomElement firstChild);
OsdChildrenParser(const OsdParserInfo& info, const QDomElement& firstChild);
virtual ~OsdChildrenParser();
virtual DataInformation* next();
virtual bool hasNext();
......@@ -111,7 +111,7 @@ protected:
class SingleElementOsdChildrenParser : public OsdChildrenParser {
public:
SingleElementOsdChildrenParser(const OsdParserInfo& info, QDomElement element);
SingleElementOsdChildrenParser(const OsdParserInfo& info, const QDomElement& element);
virtual ~SingleElementOsdChildrenParser();
virtual DataInformation* next();
virtual bool hasNext();
......
......@@ -35,7 +35,7 @@
namespace Kasten
{
StructureDefinitionFile::StructureDefinitionFile(KPluginInfo info)
StructureDefinitionFile::StructureDefinitionFile(const KPluginInfo& info)
: mPluginInfo(info)
{
const QFileInfo tmp(info.entryPath());
......
......@@ -49,7 +49,7 @@ public:
* @param info the information about this structure definition
* (passed by value so nothing bad can happen)
*/
explicit StructureDefinitionFile(KPluginInfo info);
explicit StructureDefinitionFile(const KPluginInfo& info);
virtual ~StructureDefinitionFile();
QVector<TopLevelDataInformation*> structures() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment