This file is indexed.

/usr/include/odil/dcmtk/ElementAccessor.txx is in libodil0-dev 0.7.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*************************************************************************
 * odil - Copyright (C) Universite de Strasbourg
 * Distributed under the terms of the CeCILL-B license, as published by
 * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 * for details.
 ************************************************************************/

#ifndef _f9af3e63_3597_4513_8c10_b55058f5370b
#define _f9af3e63_3597_4513_8c10_b55058f5370b

#include "odil/dcmtk/ElementAccessor.h"

#include <dcmtk/config/osconfig.h>
#include <dcmtk/dcmdata/dcdatset.h>
#include <dcmtk/dcmdata/dcelem.h>
#include <dcmtk/dcmdata/dcerror.h>
#include <dcmtk/ofstd/ofstring.h>

namespace odil
{

namespace dcmtk
{

template<typename TValueType>
bool
ElementAccessor<TValueType>
::has(DcmDataset const & dataset, DcmTagKey const & tag)
{
    DcmElement * dummy;
    OFCondition const condition =
        const_cast<DcmDataset&>(dataset).findAndGetElement(tag, dummy);
    if(condition.good())
    {
        return true;
    }
    else if(condition == EC_TagNotFound)
    {
        return false;
    }
    else
    {
        throw Exception(condition);
    }
}

template<typename TValueType>
TValueType
ElementAccessor<TValueType>
::get(
    DcmDataset const & dataset,
    DcmTagKey const tag, unsigned int const position)
{
    DcmElement * element;
    OFCondition const condition =
        const_cast<DcmDataset &>(dataset).findAndGetElement(tag, element);
    if(condition.bad())
    {
        throw Exception(condition);
    }

    return element_get(*element, position);
}

template<typename TValueType>
void
ElementAccessor<TValueType>
::set(
    DcmDataset & dataset,
    DcmTagKey const tag, ValueType const & value, unsigned int const position)
{
    DcmElement * element;
    OFCondition const get_condition = dataset.findAndGetElement(tag, element);
    if(get_condition.bad())
    {
        OFCondition const insert_condition = dataset.insertEmptyElement(tag);
        if(insert_condition.bad())
        {
            throw Exception(insert_condition);
        }

        OFCondition const new_get_condition =
            dataset.findAndGetElement(tag, element);
        if(new_get_condition.bad())
        {
            throw Exception(insert_condition);
        }
    }

    element_set(*element, value, position);
}

template<typename TValueType>
TValueType
get_default(DcmElement const & element, unsigned long const position)
{
    TValueType value;
    OFCondition const & condition =
        ElementTraits<TValueType>::getter(
            const_cast<DcmElement&>(element), value, position);
    if(condition.bad())
    {
        throw Exception(condition);
    }

    return value;
}

template<typename TValueType>
void
set_default(
    DcmElement & element, TValueType const & value,
    unsigned long const position)
{
    OFCondition const condition = ElementTraits<TValueType>::setter(element, value, position);
    if(condition.bad())
    {
        throw Exception(condition);
    }
}

template<typename TValueType>
TValueType
get_string(DcmElement const & element, unsigned long const position)
{
    OFString value;
    ElementTraits<OFString>::getter(const_cast<DcmElement&>(element), value, position);

    return std::string(value.c_str());
}

template<typename TValueType>
void
set_string(
    DcmElement & element, TValueType const & value,
    unsigned long const position)
{
    OFString const value_dcmtk(value.c_str(), value.size());
    OFCondition const condition = ElementTraits<OFString>::setter(
        element, value_dcmtk, position);
    if(condition.bad())
    {
        throw Exception(condition);
    }
}

template<typename TValueType>
TValueType
get_binary(DcmElement const & element, unsigned long const position)
{
    if(position != 0)
    {
        throw Exception("Position must be 0 for binary VRs");
    }

    DcmEVR const evr = element.getTag().getVR().getValidEVR();

    TValueType result;
    OFCondition condition;

    typename TValueType::value_type * data=NULL;
    if(evr == EVR_OB || evr == EVR_UN)
    {
        Uint8 * typed_data;
        condition = const_cast<DcmElement&>(element).getUint8Array(typed_data);
        data = reinterpret_cast<typename TValueType::value_type *>(typed_data);
    }
    else if(evr == EVR_OW)
    {
        Uint16 * typed_data;
        condition = const_cast<DcmElement&>(element).getUint16Array(typed_data);
        data = reinterpret_cast<typename TValueType::value_type *>(typed_data);
    }
    else if(evr == EVR_OF)
    {
        Float32 * typed_data;
        condition = const_cast<DcmElement&>(element).getFloat32Array(typed_data);
        data = reinterpret_cast<typename TValueType::value_type *>(typed_data);
    }
    else
    {
        throw Exception(
            std::string("Unknown VR: ") +
            element.getTag().getVR().getValidVRName());
    }

    if(condition.bad())
    {
        throw Exception(condition);
    }

    result.resize(element.getLengthField());
    std::copy(data, data+element.getLengthField(), result.begin());

    return result;
}

template<typename TValueType>
void
set_binary(
    DcmElement & element, TValueType const & value,
    unsigned long const position)
{

}

}

}

#endif // _f9af3e63_3597_4513_8c10_b55058f5370b