Coverage Report

Created: 2026-06-08 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/index.cpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2006, 2007 StatPro Italia srl
5
6
 This file is part of QuantLib, a free-software/open-source library
7
 for financial quantitative analysts and developers - http://quantlib.org/
8
9
 QuantLib is free software: you can redistribute it and/or modify it
10
 under the terms of the QuantLib license.  You should have received a
11
 copy of the license along with this program; if not, please email
12
 <quantlib-dev@lists.sf.net>. The license is also available online at
13
 <https://www.quantlib.org/license.shtml>.
14
15
 This program is distributed in the hope that it will be useful, but WITHOUT
16
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
 FOR A PARTICULAR PURPOSE.  See the license for more details.
18
*/
19
20
#include <ql/index.hpp>
21
22
namespace QuantLib {
23
24
    void Index::addFixing(const Date& fixingDate,
25
                          Real fixing,
26
2.74k
                          bool forceOverwrite) {
27
2.74k
        checkNativeFixingsAllowed();
28
2.74k
        addFixings(&fixingDate, (&fixingDate) + 1, &fixing, forceOverwrite);
29
2.74k
    }
30
31
    void Index::addFixings(const TimeSeries<Real>& t,
32
0
                           bool forceOverwrite) {
33
0
        checkNativeFixingsAllowed();
34
        // is there a way of iterating over dates and values
35
        // without having to make a copy?
36
0
        std::vector<Date> dates = t.dates();
37
0
        std::vector<Real> values = t.values();
38
0
        addFixings(dates.begin(), dates.end(),
39
0
                   values.begin(),
40
0
                   forceOverwrite);
41
0
    }
42
43
888
    void Index::clearFixings() {
44
888
        checkNativeFixingsAllowed();
45
888
        QL_DEPRECATED_DISABLE_WARNING
46
888
        IndexManager::instance().clearHistory(name());
47
888
        QL_DEPRECATED_ENABLE_WARNING
48
888
    }
49
50
6.37k
    void Index::checkNativeFixingsAllowed() {
51
        QL_REQUIRE(allowsNativeFixings(),
52
6.37k
                   "native fixings not allowed for " << name()
53
6.37k
                   << "; refer to underlying indices instead");
54
6.37k
    }
55
56
}
57