TimePattern.h 1.22 KB
#ifndef TIMEPATTERN_H
#define TIMEPATTERN_H

#include <list>
#include <string>

#include "../Common/TREPSTypes.h"
#include "../Application/Application.h"

using namespace TREPS::Common;
using namespace TREPS::Application;

namespace TREPS
{
	namespace TimeManager
	{
		//type of time pattern part
		typedef enum
		{
			TPPT_STRING,
			TPPT_YEAR_4D,
			TPPT_YEAR_2D,
			TPPT_MONTH,
			TPPT_DAY,
			TPPT_DOY,
			TPPT_HOUR,
			TPPT_MIN,
			TPPT_SEC,
			TPPT_MLS,
		} t_TimePatternPartType;

		//time pattern part
		typedef struct
		{
			//type
			t_TimePatternPartType type;
			//length (ie string length)
			int length;
			//value
			string strVal;
		} t_TimePatternPart;

		//list of time pattern part
		typedef list<t_TimePatternPart> t_TimePatternPartList;

		class TimePatternClass
		{
			public :
				TimePatternClass(void);

				//init the time pattern from definition
				bool init(const char *pattern);

				//load pattern time
				bool load(const char *time, t_Time &t, bool verbose);

				//write pattern time
				bool write(t_Time &t, string &time);

				//get size of the pattern (ie string length)
				int getSize(void);

			private :
				ApplicationClass *app;

				t_TimePatternPartList partList;

				string pattern;
		};
	}
}

#endif