/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2012-2014, Tomasz Sowa * All rights reserved. * */ #ifndef headerfile_winix_core_timezones #define headerfile_winix_core_timezones #include #include #include "timezone.h" #include "space/spaceparser.h" namespace Winix { class TimeZones { public: TimeZones(); // maximum allowed time zone's identifier void SetTimeZoneMaxId(size_t max_id); // reading time zone from a file bool ReadTimeZones(const wchar_t * path); bool ReadTimeZones(const std::wstring & path); // returning true if there is a time zone with the zone_id identifier bool HasZone(size_t zone_id); // returning a time zone by time zone's identifier // can return a null pointer if there is no such a zone TimeZone * GetZone(size_t zone_id); // returning the number of all time zones size_t Size() const; // returning a time zone by an internal index // usuful for iterating through all zones // this index is in a range of <0, Size()-1> // can return a null pointer if the index is out of range TimeZone * GetZoneByIndex(size_t zone_index); // return true if there are not any time zones bool Empty() const; // clears all time zones // this does not affect SetTimeZoneMaxId() // so the size of zone_indices is not changed but all indices are invalidated void Clear(); private: // indices to 'tab' // with this we have O(1) time to find a time zone in 'tab' // everywhere we use zone_id we refer to this table // SetTimeZoneMaxId(size_t max_id) sets size of this table to max_id+1 std::vector zone_indices; // time zones // everywhere we use zone_index we refer to this table std::vector zone_tab; PT::SpaceParser parser; PT::Space temp_space; TimeZone temp_zone; void ParseZones(); }; } // namespace Winix #endif