Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/indexes/region.hpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2007 Chris Kenyon
5
 Copyright (C) 2014 StatPro Italia srl
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <https://www.quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
/*! \file region.hpp
22
    \brief Region, i.e. geographical area, specification
23
*/
24
25
#ifndef quantlib_region_hpp
26
#define quantlib_region_hpp
27
28
#include <ql/qldefines.hpp>
29
#include <ql/shared_ptr.hpp>
30
#include <string>
31
#include <utility>
32
33
namespace QuantLib {
34
35
    //! Region class, used for inflation applicability.
36
    class Region {
37
      public:
38
        //! \name Inspectors
39
        //@{
40
        const std::string& name() const;
41
        const std::string& code() const;
42
        //@}
43
      protected:
44
0
        Region() = default;
45
        struct Data;
46
        ext::shared_ptr<Data> data_;
47
    };
48
49
    struct Region::Data {
50
        std::string name;
51
        std::string code;
52
0
        Data(std::string name, std::string code) : name(std::move(name)), code(std::move(code)) {}
53
    };
54
55
    //! \relates Region
56
    bool operator==(const Region&, const Region&);
57
58
    //! \relates Region
59
    bool operator!=(const Region&, const Region&);
60
61
62
    //! Custom geographical/economic region
63
    /*! This class allows one to create an instance of a particular
64
        region without having to define and compile a corresponding
65
        class.
66
    */
67
    class CustomRegion : public Region {
68
      public:
69
        CustomRegion(const std::string& name,
70
                     const std::string& code);
71
    };
72
73
74
    //! Australia as geographical/economic region
75
    class AustraliaRegion : public Region {
76
      public:
77
        AustraliaRegion();
78
    };
79
80
    //! European Union as geographical/economic region
81
    class EURegion : public Region {
82
      public:
83
        EURegion();
84
    };
85
86
    //! France as geographical/economic region
87
    class FranceRegion : public Region {
88
      public:
89
        FranceRegion();
90
    };
91
92
    //! United Kingdom as geographical/economic region
93
    class UKRegion : public Region {
94
      public:
95
        UKRegion();
96
    };
97
98
    //! USA as geographical/economic region
99
    class USRegion : public Region {
100
    public:
101
        USRegion();
102
    };
103
104
    //! South Africa as geographical/economic region
105
    class ZARegion : public Region {
106
    public:
107
        ZARegion();
108
    };
109
110
111
    // inline definitions
112
113
0
    inline const std::string& Region::name() const {
114
0
        return data_->name;
115
0
    }
116
117
0
    inline const std::string& Region::code() const {
118
0
        return data_->code;
119
0
    }
120
121
0
    inline bool operator==(const Region& r1, const Region& r2) {
122
0
        return r1.name() == r2.name();
123
0
    }
124
125
0
    inline bool operator!=(const Region& r1, const Region& r2) {
126
0
        return !(r1.name() == r2.name());
127
0
    }
128
129
}
130
131
#endif