223 lines
No EOL
14 KiB
MQL5
223 lines
No EOL
14 KiB
MQL5
#ifndef LIB_MQLPLUS_MQL4_COMPATIBILITY_PRINTF_MQH_INCLUDED
|
|
#define LIB_MQLPLUS_MQL4_COMPATIBILITY_PRINTF_MQH_INCLUDED
|
|
#property version "1.0";
|
|
#property strict
|
|
/**********************************************************************************
|
|
* Copyright (C) 2010-2022 Dominik Egert <info@freie-netze.de>
|
|
*
|
|
* This file is the MQL4 backward compatibility include file.
|
|
*
|
|
* MQLplus, including this file may not be copied and/or distributed
|
|
* without explecit permit by the author.
|
|
* Author Dominik Egert / Freie Netze UG.
|
|
**********************************************************************************
|
|
*
|
|
* Version: 1.0
|
|
* State: development
|
|
*
|
|
* File information
|
|
* ================
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
#ifdef DBG_MSG_TRACE_FILE_LOADER
|
|
DBG_MSG_TRACE_FILE_LOADER;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//*********************************************************************************************************************************************************/
|
|
//
|
|
// BEGIN MQL4 compatibility additions
|
|
//
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| MQL4: MQL5-compatible printf() |
|
|
//+------------------------------------------------------------------+
|
|
#define MQLPLUS_PRINTF _printf
|
|
|
|
void MQLPLUS_PRINTF(const string p1)
|
|
{ printf_wrapper(p1); }
|
|
|
|
// params: A-B
|
|
template < typename B>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2)
|
|
{ printf_wrapper(StringFormat(p1, p2)); }
|
|
|
|
// params: A-C
|
|
template < typename B, typename C>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3)); }
|
|
|
|
// params: A-D
|
|
template < typename B, typename C, typename D>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4)); }
|
|
|
|
// params: A-E
|
|
template < typename B, typename C, typename D, typename E>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5)); }
|
|
|
|
// params: A-F
|
|
template < typename B, typename C, typename D, typename E, typename F>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6)); }
|
|
|
|
// params: A-G
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7)); }
|
|
|
|
// params: A-H
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8)); }
|
|
|
|
// params: A-I
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9)); }
|
|
|
|
// params: A-J
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)); }
|
|
|
|
// params: A-K
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)); }
|
|
|
|
// params: A-L
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12)); }
|
|
|
|
// params: A-M
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)); }
|
|
|
|
// params: A-N
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14)); }
|
|
|
|
// params: A-O
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)); }
|
|
|
|
// params: A-P
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16)); }
|
|
|
|
// params: A-Q
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17)); }
|
|
|
|
// params: A-R
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18)); }
|
|
|
|
// params: A-S
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19)); }
|
|
|
|
// params: A-T
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20); }
|
|
|
|
// params: A-U
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T, typename U>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20, const U p21)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21); }
|
|
|
|
// params: A-V
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T, typename U, typename V>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20, const U p21, const V p22)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22); }
|
|
|
|
// params: A-W
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T, typename U, typename V, typename W>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20, const U p21, const V p22, const W p23)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23); }
|
|
|
|
// params: A-X
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T, typename U, typename V, typename W, typename X>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20, const U p21, const V p22, const W p23, const X p24)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24); }
|
|
|
|
// params: A-Y
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T, typename U, typename V, typename W, typename X, typename Y>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20, const U p21, const V p22, const W p23, const X p24, const Y p25)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25); }
|
|
|
|
// params: A-Z
|
|
template < typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M,
|
|
typename N, typename O, typename P, typename Q, typename R, typename S, typename T, typename U, typename V, typename W, typename X, typename Y, typename Z>
|
|
void MQLPLUS_PRINTF( const string p1, const B p2, const C p3, const D p4, const E p5, const F p6, const G p7, const H p8, const I p9, const J p10, const K p11, const L p12, const M p13,
|
|
const N p14, const O p15, const P p16, const Q p17, const R p18, const S p19, const T p20, const U p21, const V p22, const W p23, const X p24, const Y p25, const Z p26)
|
|
{ printf_wrapper(StringFormat(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26)); }
|
|
|
|
// Primary printf wrapper
|
|
void printf_wrapper(string out)
|
|
{
|
|
// Local init
|
|
|
|
string multipart[];
|
|
StringReplace(out, "\r", "");
|
|
const int lines = StringSplit(out, 0x0A, multipart);
|
|
|
|
// Multiline journal output support
|
|
|
|
for(int cnt = lines - 1; (cnt >= NULL) && !_StopFlag; cnt--)
|
|
{ printf("%s", multipart[cnt]); };
|
|
|
|
// Return
|
|
return;
|
|
}
|
|
|
|
|
|
// Overwrite systemfunction by macro definition
|
|
#define printf _printf
|
|
|
|
|
|
|
|
//
|
|
// END MQL compatibility */
|
|
//*********************************************************************************************************************************************************/
|
|
#endif // LIB_MQLPLUS_MQL4_COMPATIBILITY_PRINTF_MQH_INCLUDED |