File: VR.cpp

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (55 lines) | stat: -rw-r--r-- 2,072 bytes parent folder | download | duplicates (4)
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
/*************************************************************************
 * 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.
 ************************************************************************/

#include <Python.h>

#include <pybind11/pybind11.h>

#include "odil/Tag.h"
#include "odil/VR.h"

#include "opaque_types.h"
#include "type_casters.h"

void wrap_VR(pybind11::module & m)
{
    using namespace pybind11;
    using namespace odil;

    auto vr = enum_<VR>(m, "VR")
        .value("UNKNOWN", VR::UNKNOWN)
        .value("AE", VR::AE).value("AS", VR::AS).value("AT", VR::AT)
        .value("CS", VR::CS).value("DA", VR::DA).value("DS", VR::DS)
        .value("DT", VR::DT).value("FD", VR::FD).value("FL", VR::FL)
        .value("IS", VR::IS).value("LO", VR::LO).value("LT", VR::LT)
        .value("PN", VR::PN).value("OB", VR::OB).value("OF", VR::OF)
        .value("OV", VR::OV).value("OW", VR::OW).value("SH", VR::SH)
        .value("SL", VR::SL).value("SQ", VR::SQ).value("SS", VR::SS)
        .value("ST", VR::ST).value("SV", VR::SV).value("TM", VR::TM)
        .value("UC", VR::UC).value("UI", VR::UI).value("UL", VR::UL)
        .value("UN", VR::UN).value("UR", VR::UR).value("US", VR::US)
        .value("UT", VR::UT).value("UV", VR::UV)
        .value("INVALID", VR::INVALID)
        .def(init([](std::string const & string) { return as_vr(string); }))
    ;
    
    // See pybind11#2537
    vr.attr("__str__") = cpp_function(
        [](VR const & vr ) { return as_string(vr); },
        name("__str__"),
        is_method(vr));
    
    m.def("as_string", (std::string (*)(VR)) as_string);
    m.def("as_vr", (VR (*)(std::string)) as_string);
    m.def("as_vr", (VR (*)(Tag)) as_string);

    m.def("is_int", odil::is_int);
    m.def("is_real", odil::is_real);
    m.def("is_string", odil::is_string);
    m.def("is_binary", odil::is_binary);
}