Skip to content

Commit 991462e

Browse files
committed
feat(mql5): add initial MQL5 headers and enable parsing
1 parent 592cd97 commit 991462e

19 files changed

+514
-352
lines changed

Doxyfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = "Time Shield Library"
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER =
51+
PROJECT_NUMBER = 1.0.0
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a
@@ -61,13 +61,13 @@ PROJECT_BRIEF = "C++ library for working with time"
6161
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
6262
# the logo to the output directory.
6363

64-
PROJECT_LOGO =
64+
PROJECT_LOGO = E:/_repoz/time-shield-cpp/docs/icon-64x64.png
6565

6666
# With the PROJECT_ICON tag one can specify an icon that is included in the tabs
6767
# when the HTML document is shown. Doxygen will copy the logo to the output
6868
# directory.
6969

70-
PROJECT_ICON =
70+
PROJECT_ICON = docs/icon-64x64.png
7171

7272
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
7373
# into which the generated documentation will be written. If a relative path is
@@ -348,7 +348,7 @@ OPTIMIZE_OUTPUT_SLICE = NO
348348
#
349349
# Note see also the list of default file extension mappings.
350350

351-
EXTENSION_MAPPING =
351+
EXTENSION_MAPPING = mqh=C++
352352

353353
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
354354
# according to the Markdown format, which allows for more readable
@@ -949,7 +949,8 @@ WARN_LOGFILE =
949949
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
950950
# Note: If this tag is empty the current directory is searched.
951951

952-
INPUT = ./include
952+
INPUT = ./include \
953+
./MQL5/Include
953954

954955
# This tag can be used to specify the character encoding of the source files
955956
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1039,7 +1040,8 @@ FILE_PATTERNS = *.c \
10391040
*.vhdl \
10401041
*.ucf \
10411042
*.qsf \
1042-
*.ice
1043+
*.ice \
1044+
*.mqh
10431045

10441046
# The RECURSIVE tag can be used to specify whether or not subdirectories should
10451047
# be searched for input files as well.

MQL5/Include/TimeShield.mqh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//+------------------------------------------------------------------+
2+
//| TimeShield.mqh |
3+
//| MQL5 Facade for TimeShield C++ Library |
4+
//| Copyright 2025, NewYaroslav |
5+
//| https://github.com/NewYaroslav/time-shield-cpp |
6+
//+------------------------------------------------------------------+
7+
#ifndef __TIME_SHIELD_FACADE_MQH__
8+
#define __TIME_SHIELD_FACADE_MQH__
9+
10+
/// \file TimeShield.mqh
11+
/// \brief MQL5-style facade header for the Time Shield library.
12+
///
13+
/// This is a thin wrapper over the internal `time_shield.mqh` header, designed
14+
/// to provide a user-friendly PascalCase interface for MQL5 users.
15+
/// Prefer `#include <TimeShield.mqh>` when using the library in MQL5.
16+
17+
#property copyright "Copyright 2025, NewYaroslav"
18+
#property link "https://github.com/NewYaroslav/time-shield-cpp"
19+
#property strict
20+
21+
/// \defgroup mql5 MQL5 TimeShield API
22+
/// \brief Components of the Time Shield library adapted for MetaTrader 5.
23+
/// @{
24+
///
25+
/// This group includes all functions, structures, and utilities that are part of the MQL5-compatible version
26+
/// of the Time Shield library.
27+
///
28+
/// Example usage:
29+
/// \code
30+
/// #include <TimeShield.mqh>
31+
/// time_shield::DateStruct d = time_shield::create_date_struct(2025, 6, 21);
32+
/// \endcode
33+
///
34+
/// @}
35+
36+
#include <time_shield.mqh>
37+
38+
#endif // __TIME_SHIELD_FACADE_MQH__

MQL5/Include/time_shield.mqh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//+------------------------------------------------------------------+
2+
//| TimeShield.mqh |
3+
//| Copyright 2025, NewYaroslav |
4+
//| https://github.com/NewYaroslav/time-shield-cpp |
5+
//+------------------------------------------------------------------+
6+
#ifndef __TIME_SHIELD_MQH__
7+
#define __TIME_SHIELD_MQH__
8+
9+
/// \file time_shield.mqh
10+
/// \ingroup mql5
11+
/// \brief Main header file for the Time Shield library.
12+
///
13+
/// This header file includes all the components of the Time Shield library,
14+
/// making it easy to include the entire library in your projects with a single
15+
/// include directive.
16+
17+
#property copyright "Copyright 2025, NewYaroslav"
18+
#property link "https://github.com/NewYaroslav/time-shield-cpp"
19+
#property strict
20+
21+
// Configuration settings for the Time Shield library
22+
#include <time_shield/config.mqh>
23+
24+
// Type definitions used throughout the library
25+
#include <time_shield/types.mqh>
26+
27+
// Constants used in time calculations
28+
#include <time_shield/constants.mqh>
29+
30+
// Enumerations used in time representations
31+
#include <time_shield/enums.mqh>
32+
33+
// Structures representing time components
34+
#include <time_shield/time_struct.mqh>
35+
36+
// Structures representing date components
37+
#include <time_shield/date_struct.mqh>
38+
39+
// Structure representing a time zone
40+
#include <time_shield/time_zone_struct.mqh>
41+
42+
// Structure representing date and time combinations
43+
#include <time_shield/date_time_struct.mqh>
44+
45+
// Functions for validation of time-related values
46+
#include <time_shield/validation.mqh>
47+
48+
// Utility functions for time manipulation
49+
#include <time_shield/time_utils.mqh>
50+
51+
// Functions for converting between different time representations
52+
#include <time_shield/time_conversions.mqh>
53+
54+
// Functions for formatting time in various standard formats
55+
#include <time_shield/time_formatting.mqh>
56+
57+
// Functions for parsing time in various standard formats
58+
#include <time_shield/time_parser.mqh>
59+
60+
#endif // __TIME_SHIELD_MQH__
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//+------------------------------------------------------------------+
2+
//| date_struct.mqh |
3+
//| Time Shield - MQL5 Date Structure |
4+
//| Copyright 2025, NewYaroslav |
5+
//| https://github.com/NewYaroslav/time-shield-cpp |
6+
//+------------------------------------------------------------------+
7+
#ifndef __TIME_SHIELD_DATE_STRUCT_MQH__
8+
#define __TIME_SHIELD_DATE_STRUCT_MQH__
9+
10+
/// \file date_struct.mqh
11+
/// \ingroup mql5
12+
/// \brief Header for date structure and related functions (MQL5).
13+
///
14+
/// This file contains the definition of the `DateStruct` structure and a function
15+
/// to create `DateStruct` instances for working with calendar dates in MQL5.
16+
17+
#property copyright "Copyright 2025, NewYaroslav"
18+
#property link "https://github.com/NewYaroslav/time-shield-cpp"
19+
#property strict
20+
21+
namespace time_shield {
22+
23+
/// \ingroup time_structures
24+
/// \brief Structure to represent a date in MQL5.
25+
struct DateStruct {
26+
long year; ///< Year component of the date.
27+
int mon; ///< Month component of the date (1–12).
28+
int day; ///< Day component of the date (1–31).
29+
};
30+
31+
/// \ingroup time_structures
32+
/// \brief Creates a `DateStruct` instance.
33+
/// \param year The year component of the date.
34+
/// \param mon The month component of the date, defaults to 1 (January).
35+
/// \param day The day component of the date, defaults to 1.
36+
/// \return A `DateStruct` instance with the provided date components.
37+
DateStruct create_date_struct(const long year, const int mon = 1, const int day = 1) {
38+
DateStruct result;
39+
result.year = year;
40+
result.mon = mon;
41+
result.day = day;
42+
return result;
43+
}
44+
45+
}; // namespace time_shield
46+
47+
#endif // __TIME_SHIELD_DATE_STRUCT_MQH__

docs/icon-64x64.png

5.31 KB
Loading

include/time_shield_cpp/time_shield.hpp

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#pragma once
2+
#ifndef _TIME_SHIELD_HPP_INCLUDED
3+
#define _TIME_SHIELD_HPP_INCLUDED
4+
25
/// \file time_shield.hpp
36
/// \brief Main header file for the Time Shield library.
47
///
58
/// This header file includes all the components of the Time Shield library,
69
/// making it easy to include the entire library in your projects with a single
710
/// include directive.
8-
///
9-
#ifndef _TIME_SHIELD_HPP_INCLUDED
10-
#define _TIME_SHIELD_HPP_INCLUDED
1111

1212
#include "time_shield/config.hpp" ///< Configuration settings for the Time Shield library.
1313
#include "time_shield/types.hpp" ///< Type definitions used throughout the library.
@@ -38,25 +38,27 @@ namespace tshield = time_shield;
3838
/// It includes various utilities for working with time and dates, their formatting, conversion, and validation.
3939
namespace time_shield {};
4040

41-
/// \defgroup time_structures Time Structures
42-
/// \brief Structures for representing and working with time and date components.
43-
///
44-
/// This group includes various structures used for representing time, date, and date-time combinations,
45-
/// along with related utility functions for creating and manipulating these structures.
46-
///
47-
/// ### Included Structures:
48-
/// - `TimeStruct`: Represents time components (hour, minute, second, millisecond).
49-
/// - `DateStruct`: Represents date components (year, month, day).
50-
/// - `DateTimeStruct`: Represents combined date and time components.
51-
/// - `TimeZoneStruct`: Represents time zone offsets.
52-
///
53-
/// ### Example Usage:
54-
/// ```cpp
55-
/// auto time = time_shield::create_time_struct(12, 30, 45); // 12:30:45
56-
/// auto date = time_shield::create_date_struct(2024, 11, 25); // 2024-11-25
57-
/// auto date_time = time_shield::create_date_time_struct(2024, 11, 25, 12, 30, 45);
58-
/// auto tz = time_shield::to_time_zone_struct(3600); // +01:00
59-
/// ```
41+
/*!
42+
\defgroup time_structures Time Structures
43+
\brief Structures for representing and working with time and date components.
44+
45+
This group includes various structures used for representing time, date, and date-time combinations,
46+
along with related utility functions for creating and manipulating these structures.
47+
48+
### Included Structures:
49+
- `TimeStruct`: Represents time components (hour, minute, second, millisecond).
50+
- `DateStruct`: Represents date components (year, month, day).
51+
- `DateTimeStruct`: Represents combined date and time components.
52+
- `TimeZoneStruct`: Represents time zone offsets.
53+
54+
### Example Usage:
55+
```cpp
56+
auto time = time_shield::create_time_struct(12, 30, 45); // 12:30:45
57+
auto date = time_shield::create_date_struct(2024, 11, 25); // 2024-11-25
58+
auto date_time = time_shield::create_date_time_struct(2024, 11, 25, 12, 30, 45);
59+
auto tz = time_shield::to_time_zone_struct(3600); // +01:00
60+
```
61+
*/
6062

6163
/*!
6264
\mainpage Time Shield Library
@@ -77,7 +79,7 @@ The Time Shield Library is a comprehensive C++ library designed for time manipul
7779
7880
\code{.cpp}
7981
#include <iostream>
80-
#include "time_shield.hpp"
82+
#include <time_shield.hpp>
8183
8284
int main() {
8385
// Get the current timestamp

include/time_shield_cpp/time_shield/config.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#pragma once
2+
#ifndef _TIME_SHIELD_CONFIG_HPP_INCLUDED
3+
#define _TIME_SHIELD_CONFIG_HPP_INCLUDED
4+
25
/// \file config.hpp
36
/// \brief Header file with preprocessor definitions for C++ standards and `constexpr` usage.
47
///
58
/// This file defines macros to check the C++ standard version being used and configure
69
/// `constexpr` and `if constexpr` support accordingly.
7-
#ifndef _TIME_SHIELD_CONFIG_HPP_INCLUDED
8-
#define _TIME_SHIELD_CONFIG_HPP_INCLUDED
910

1011
// Check and define macros based on the C++ standard version
1112
#if __cplusplus == 201103L

include/time_shield_cpp/time_shield/constants.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#pragma once
2+
#ifndef _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
3+
#define _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
4+
25
/// \file constants.hpp
36
/// \brief Header file with time-related constants.
47
///
58
/// This file contains various constants used for time calculations and conversions.
6-
#ifndef _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
7-
#define _TIME_SHIELD_CONSTANTS_HPP_INCLUDED
89

910
#include <cstdint>
1011
#include <limits>
@@ -50,11 +51,11 @@ namespace time_shield {
5051
constexpr int64_t MS_PER_HALF_HOUR = 1800000; ///< Milliseconds per half hour
5152
constexpr int64_t MS_PER_HOUR = 3600000; ///< Milliseconds per hour
5253
constexpr int64_t MS_PER_1_HOUR = 3600000; ///< Milliseconds per 1 hour
53-
constexpr int64_t MS_PER_2_HOUR = 7200000; ///< Milliseconds per 2 hour
54-
constexpr int64_t MS_PER_4_HOUR = 14400000; ///< Milliseconds per 4 hour
55-
constexpr int64_t MS_PER_5_HOUR = 18000000; ///< Milliseconds per 5 hour
56-
constexpr int64_t MS_PER_8_HOUR = 28800000; ///< Milliseconds per 8 hour
57-
constexpr int64_t MS_PER_12_HOUR = 43200000; ///< Milliseconds per 12 hour
54+
constexpr int64_t MS_PER_2_HOUR = 7200000; ///< Milliseconds per 2 hour
55+
constexpr int64_t MS_PER_4_HOUR = 14400000; ///< Milliseconds per 4 hour
56+
constexpr int64_t MS_PER_5_HOUR = 18000000; ///< Milliseconds per 5 hour
57+
constexpr int64_t MS_PER_8_HOUR = 28800000; ///< Milliseconds per 8 hour
58+
constexpr int64_t MS_PER_12_HOUR = 43200000; ///< Milliseconds per 12 hour
5859
constexpr int64_t MS_PER_DAY = 86400000; ///< Milliseconds per day
5960

6061
// Seconds

include/time_shield_cpp/time_shield/date_struct.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#pragma once
2+
#ifndef _TIME_SHIELD_DATE_STRUCT_HPP_INCLUDED
3+
#define _TIME_SHIELD_DATE_STRUCT_HPP_INCLUDED
4+
25
/// \file date_struct.hpp
36
/// \brief Header for date structure and related functions.
47
///
58
/// This file contains the definition of the DateStruct structure and a function to create DateStruct instances.
6-
#ifndef _TIME_SHIELD_DATE_STRUCT_HPP_INCLUDED
7-
#define _TIME_SHIELD_DATE_STRUCT_HPP_INCLUDED
89

910
namespace time_shield {
1011

include/time_shield_cpp/time_shield/date_time_struct.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#pragma once
2+
#ifndef _TIME_SHIELD_DATE_TIME_STRUCT_HPP_INCLUDED
3+
#define _TIME_SHIELD_DATE_TIME_STRUCT_HPP_INCLUDED
4+
25
/// \file date_time_struct.hpp
36
/// \brief Header for date and time structure and related functions.
47
///
58
/// This file contains the definition of the DateTimeStruct structure and a function to create DateTimeStruct instances.
6-
#ifndef _TIME_SHIELD_DATE_TIME_STRUCT_HPP_INCLUDED
7-
#define _TIME_SHIELD_DATE_TIME_STRUCT_HPP_INCLUDED
89

910
namespace time_shield {
1011

0 commit comments

Comments
 (0)