Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
CheckedConverter.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_CheckedConverter_h_
5#define _Stroika_Foundation_DataExchange_CheckedConverter_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10#include "Stroika/Foundation/DataExchange/BadFormatException.h"
11
12/**
13 * \file
14 *
15 * TODO:
16 * @todo UNDOCUMENTED - VERY PRELIMINARY DRAFT
17 *
18 *
19 * \em Design Note:
20 */
21
23
24 /**
25 * CheckedConverter_Range takes a lower and upper bound, and creates a new RANGE_TYPE
26 * object using that lower/upper bound, after validating (similar to @CheckedConverter_ValueInRange,
27 * but not exactly the same because of 'openness')
28 *
29 * CheckedConverter_Range also checks that the endpoints are valid with respect to the type, and that s <= e.
30 *
31 * CheckedConverter_Range () if any values are invalid.
32 *
33 * @see CheckedConverter_ValueInRange
34 */
35 template <typename RANGE_TYPE>
36 RANGE_TYPE CheckedConverter_Range (const typename RANGE_TYPE::value_type& s, const typename RANGE_TYPE::value_type& e);
37
38 /**
39 * CheckedConverter_ValueInRange () will throw BadFormatException{} if the argument 'val' is outside
40 * the given argument range.
41 *
42 * The 'range' defaults to the RANGE_TYPE::FullRange ().
43 *
44 * Note - for floating point ElementType - if the value ('val') is 'really close' to an edge - it
45 * will be pinned to the range edge, not treated as out of range.
46 *
47 * The returned value is always at least nearly identical to the 'val' passed in, but could be slightly different due to
48 * the above floating point near-edge adjustment.
49 */
50 template <typename RANGE_TYPE>
51 typename RANGE_TYPE::ElementType CheckedConverter_ValueInRange (typename RANGE_TYPE::ElementType val,
52 const RANGE_TYPE& range = RANGE_TYPE::FullRange ());
53
54}
55
56/*
57 ********************************************************************************
58 ***************************** Implementation Details ***************************
59 ********************************************************************************
60 */
61#include "CheckedConverter.inl"
62
63#endif /*_Stroika_Foundation_DataExchange_CheckedConverter_h_*/
RANGE_TYPE CheckedConverter_Range(const typename RANGE_TYPE::value_type &s, const typename RANGE_TYPE::value_type &e)
RANGE_TYPE::ElementType CheckedConverter_ValueInRange(typename RANGE_TYPE::ElementType val, const RANGE_TYPE &range=RANGE_TYPE::FullRange())