You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.2 KiB
C
115 lines
3.2 KiB
C
11 years ago
|
/*
|
||
|
* This file is a part of Winix
|
||
9 years ago
|
* and is distributed under the 2-Clause BSD licence.
|
||
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||
|
*/
|
||
|
|
||
|
/*
|
||
9 years ago
|
* Copyright (c) 2012-2014, Tomasz Sowa
|
||
11 years ago
|
* All rights reserved.
|
||
9 years ago
|
*
|
||
|
* Redistribution and use in source and binary forms, with or without
|
||
|
* modification, are permitted provided that the following conditions are met:
|
||
|
*
|
||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||
|
* this list of conditions and the following disclaimer.
|
||
|
*
|
||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||
|
* notice, this list of conditions and the following disclaimer in the
|
||
|
* documentation and/or other materials provided with the distribution.
|
||
|
*
|
||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||
11 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef headerfile_winix_core_timezones
|
||
|
#define headerfile_winix_core_timezones
|
||
|
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
#include "timezone.h"
|
||
|
#include "space/spaceparser.h"
|
||
|
|
||
|
|
||
9 years ago
|
namespace Winix
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
11 years ago
|
|
||
|
class TimeZones
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
TimeZones();
|
||
|
|
||
11 years ago
|
// maximum allowed time zone's identifier
|
||
|
void SetTimeZoneMaxId(size_t max_id);
|
||
11 years ago
|
|
||
11 years ago
|
// reading time zone from a file
|
||
11 years ago
|
bool ReadTimeZones(const wchar_t * path);
|
||
|
bool ReadTimeZones(const std::wstring & path);
|
||
|
|
||
11 years ago
|
// 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
|
||
11 years ago
|
size_t Size() const;
|
||
11 years ago
|
|
||
|
// 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();
|
||
11 years ago
|
|
||
|
|
||
|
private:
|
||
|
|
||
11 years ago
|
// 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<size_t> zone_indices;
|
||
|
|
||
|
// time zones
|
||
|
// everywhere we use zone_index we refer to this table
|
||
|
std::vector<TimeZone> zone_tab;
|
||
|
|
||
11 years ago
|
PT::SpaceParser parser;
|
||
|
PT::Space temp_space;
|
||
11 years ago
|
TimeZone temp_zone;
|
||
11 years ago
|
|
||
11 years ago
|
void ParseZones();
|
||
11 years ago
|
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
9 years ago
|
} // namespace Winix
|
||
|
|
||
|
|
||
11 years ago
|
|
||
|
#endif
|