Skip to content

Commit

Permalink
WIP. Fixing C++ include loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
nseam committed Nov 11, 2022
1 parent 0a6aade commit 4cdd0d2
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Array.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) {
* - https://www.mql5.com/en/docs/array/arraymaximum
*/
template <typename X>
static int ArrayMinimum(const ARRAY_REF(X, _array), int _start = 0, int _count = WHOLE_ARRAY) {
static int ArrayMinimum(ARRAY_REF(X, _array), int _start = 0, int _count = WHOLE_ARRAY) {
#ifdef __MQL__
return ::ArrayMinimum(_array);
#else
Expand Down Expand Up @@ -724,7 +724,7 @@ static int GetLowestArrDoubleValue(double& arr[][], int key) {
* - https://www.mql5.com/en/docs/array/arraymaximum
*/
template <typename X>
static int ArrayMaximum(const ARRAY_REF(X, _array), int start = 0, int count = WHOLE_ARRAY) {
static int ArrayMaximum(ARRAY_REF(X, _array), int start = 0, int count = WHOLE_ARRAY) {
#ifdef __MQL__
return ::ArrayMaximum(_array);
#else
Expand Down
44 changes: 0 additions & 44 deletions Data.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct MqlRates;
#include "Serializer/Serializer.enum.h"
#include "Serializer/SerializerNode.enum.h"
#include "Std.h"
#include "Serializer/Serializer.h"

#ifndef __MQL__
/**
Expand Down Expand Up @@ -330,46 +329,3 @@ struct DataParamEntry : public MqlParam {
}
SerializerNodeType Serialize(Serializer &s);
};

/* Method to serialize DataParamEntry struct. */
SerializerNodeType DataParamEntry::Serialize(Serializer &s) {
s.PassEnum(THIS_REF, "type", type, SERIALIZER_FIELD_FLAG_HIDDEN);
string aux_string;

switch (type) {
case TYPE_BOOL:
case TYPE_UCHAR:
case TYPE_CHAR:
case TYPE_USHORT:
case TYPE_SHORT:
case TYPE_UINT:
case TYPE_INT:
case TYPE_ULONG:
case TYPE_LONG:
s.Pass(THIS_REF, "value", integer_value);
break;

case TYPE_DOUBLE:
s.Pass(THIS_REF, "value", double_value);
break;

case TYPE_STRING:
s.Pass(THIS_REF, "value", string_value);
break;

case TYPE_DATETIME:
if (s.IsWriting()) {
aux_string = TimeToString(integer_value);
s.Pass(THIS_REF, "value", aux_string);
} else {
s.Pass(THIS_REF, "value", aux_string);
integer_value = StringToTime(aux_string);
}
break;

default:
// Unknown type. Serializing anyway.
s.Pass(THIS_REF, "value", aux_string);
}
return SerializerNodeObject;
}
78 changes: 78 additions & 0 deletions Data.struct.serialize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @file
* Includes Data struct serialization methods.
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
#include "Data.struct.h"
#include "Serializer/Serializer.h"

/* Method to serialize DataParamEntry struct. */
SerializerNodeType DataParamEntry::Serialize(Serializer &s) {
s.PassEnum(THIS_REF, "type", type, SERIALIZER_FIELD_FLAG_HIDDEN);
string aux_string;

switch (type) {
case TYPE_BOOL:
case TYPE_UCHAR:
case TYPE_CHAR:
case TYPE_USHORT:
case TYPE_SHORT:
case TYPE_UINT:
case TYPE_INT:
case TYPE_ULONG:
case TYPE_LONG:
s.Pass(THIS_REF, "value", integer_value);
break;

case TYPE_DOUBLE:
s.Pass(THIS_REF, "value", double_value);
break;

case TYPE_STRING:
s.Pass(THIS_REF, "value", string_value);
break;

case TYPE_DATETIME:
if (s.IsWriting()) {
aux_string = TimeToString(integer_value);
s.Pass(THIS_REF, "value", aux_string);
} else {
s.Pass(THIS_REF, "value", aux_string);
integer_value = StringToTime(aux_string);
}
break;

default:
// Unknown type. Serializing anyway.
s.Pass(THIS_REF, "value", aux_string);
}
return SerializerNodeObject;
}
16 changes: 6 additions & 10 deletions Task/TaskCondition.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@

// Includes.
#include "../Data.struct.h"
#include "../Serializer/Serializer.define.h"
#include "../Serializer/Serializer.enum.h"
#include "../Std.h"
#include "../Terminal.define.h"
#include "Task.enum.h"

// Forward declarations.
class Serializer;

struct TaskConditionEntry {
public:
/* Enumerations */
Expand Down Expand Up @@ -198,16 +203,7 @@ struct TaskConditionEntry {

public:
// Serializers
SerializerNodeType Serialize(Serializer &s) {
s.Pass(THIS_REF, "flags", flags);
s.Pass(THIS_REF, "id", id);
s.Pass(THIS_REF, "last_check", last_check);
s.Pass(THIS_REF, "last_success", last_success);
s.Pass(THIS_REF, "tries", tries);
s.PassEnum(THIS_REF, "freq", freq);
s.PassArray(THIS_REF, "args", args);
return SerializerNodeObject;
}
SerializerNodeType Serialize(Serializer &s);

SERIALIZER_EMPTY_STUB;
};
44 changes: 44 additions & 0 deletions Task/TaskCondition.struct.serialize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2021, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

/*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @file
* Includes TaskCondition's structures serialization methods.
*/

#ifndef __MQL__
// Allows the preprocessor to include a header file when it is needed.
#pragma once
#endif

// Includes.
#include "TaskCondition.struct.h"

SerializerNodeType TaskConditionEntry::Serialize(Serializer &s) {
s.Pass(THIS_REF, "flags", flags);
s.Pass(THIS_REF, "id", id);
s.Pass(THIS_REF, "last_check", last_check);
s.Pass(THIS_REF, "last_success", last_success);
s.Pass(THIS_REF, "tries", tries);
s.PassEnum(THIS_REF, "freq", freq);
s.PassArray(THIS_REF, "args", args);
return SerializerNodeObject;
}

0 comments on commit 4cdd0d2

Please sign in to comment.