/usr/include/gdcm-2.6/gdcmVL.h is in libgdcm2-dev 2.6.3-3ubuntu3.
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 | /*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCMVL_H
#define GDCMVL_H
#include "gdcmTypes.h"
#include <iostream>
namespace gdcm
{
/**
* \brief Value Length
* \warning this is a 4bytes value ! Do not try to use it for 2bytes value
* length
*/
class GDCM_EXPORT VL
{
public:
typedef uint32_t Type;
VL(uint32_t vl = 0) : ValueLength(vl) { }
// FIXME: ugly
static uint32_t GetVL32Max() { return 0xFFFFFFFF; }
static uint16_t GetVL16Max() { return 0xFFFF; }
bool IsUndefined() const {
return ValueLength == 0xFFFFFFFF;
}
void SetToUndefined() {
ValueLength = 0xFFFFFFFF;
}
/// Return whether or not the VL is odd or not.
bool IsOdd() const {
return !IsUndefined() && ValueLength % 2;
}
/// += operator
VL& operator+=(VL const &vl) {
ValueLength += vl.ValueLength;
return *this;
}
VL& operator++() {
++ValueLength;
return *this;
}
VL operator++(int) {
uint32_t tmp(ValueLength);
++ValueLength;
return tmp;
}
operator uint32_t () const { return ValueLength; }
VL GetLength() const {
// VL cannot know it's length...well in implicit yes...
// TODO: need to check we cannot call this function from an Explicit element
return 4;
}
friend std::ostream& operator<<(std::ostream& os, const VL& vl);
// PURPOSELY not implemented (could not differenciate 16bits vs 32bits VL)
//friend std::istream& operator>>(std::istream& is, VL& n);
template <typename TSwap>
std::istream &Read(std::istream &is)
{
is.read((char*)(&ValueLength), sizeof(uint32_t));
TSwap::SwapArray(&ValueLength,1);
return is;
}
template <typename TSwap>
std::istream &Read16(std::istream &is)
{
uint16_t copy;
is.read((char*)(©), sizeof(uint16_t));
TSwap::SwapArray(©,1);
ValueLength = copy;
assert( ValueLength <= 65535 /*UINT16_MAX*/ ); // ?? doh !
return is;
}
template <typename TSwap>
const std::ostream &Write(std::ostream &os) const
{
uint32_t copy = ValueLength;
if( IsOdd() )
{
++copy;
}
TSwap::SwapArray(©,1);
return os.write((char*)(©), sizeof(uint32_t));
}
template <typename TSwap>
const std::ostream &Write16(std::ostream &os) const
{
assert( ValueLength <= 65535 /*UINT16_MAX*/ );
uint16_t copy = (uint16_t)ValueLength;
if( IsOdd() )
{
++copy;
}
TSwap::SwapArray(©,1);
return os.write((char*)(©), sizeof(uint16_t));
}
private:
uint32_t ValueLength;
};
//----------------------------------------------------------------------------
inline std::ostream& operator<<(std::ostream& os, const VL& val)
{
os << /*std::hex <<*/ val.ValueLength;
return os;
}
} // end namespace gdcm
#endif //GDCMVL_H
|