File: gdcmPersonName.h

package info (click to toggle)
gdcm 2.4.4-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 32,912 kB
  • ctags: 52,166
  • sloc: cpp: 188,527; ansic: 124,526; xml: 41,799; sh: 7,162; python: 3,667; cs: 2,128; java: 1,344; lex: 1,290; tcl: 677; php: 128; makefile: 116
file content (83 lines) | stat: -rw-r--r-- 2,580 bytes parent folder | download | duplicates (3)
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
/*=========================================================================

  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 GDCMPERSONNAME_H
#define GDCMPERSONNAME_H

#include "gdcmTypes.h"
#include <vector>
#include <algorithm> // std::min
#include <string.h> // strlen

namespace gdcm
{

/**
 * \brief PersonName class
 */
class GDCM_EXPORT PersonName
{
public:
  static const unsigned int MaxNumberOfComponents = 5;
  static const unsigned int MaxLength = 64;
  char Component[MaxNumberOfComponents][MaxLength+1];
  static const char Separator = '^';
  static const char Padding   = ' ';

  unsigned int GetNumberOfComponents() const {
    unsigned int r = 0;
    for(unsigned int i = 0; i < 5; ++i) {
      if( *Component[i] != '\0' ) r = i;
      }
    return r+1;
  }
  unsigned int GetMaxLength() const { return MaxLength; };
  void SetBlob(const std::vector<char>& v) {
  (void)v;
    //assert(0); //TODO
  }
  void SetComponents(const char *comp1 = "",
    const char *comp2 = "",
    const char *comp3 = "",
    const char *comp4 = "",
    const char *comp5 = "") {
    const char *components[5] = { comp1, comp2, comp3, comp4, comp5 };
    SetComponents( components );
  }
  void SetComponents(const char *components[]) {
    for(unsigned int i = 0; i < 5; ++i) {
      //strncpy(Component[i], components[i], std::min( (unsigned int)strlen(components[i]), GetMaxLength() ) );
      assert( strlen(components[i]) < GetMaxLength() );
      strcpy(Component[i], components[i]);
      assert( strlen(Component[i]) < GetMaxLength() );
      }
  }
  void Print(std::ostream &os) const
  {
    //os << "Family Name Complex: " << Component[0] << std::endl;
    //os << "Given  Name Complex: " << Component[1] << std::endl;
    //os << "Middle Name        : " << Component[2] << std::endl;
    //os << "Name Suffix        : " << Component[3] << std::endl;
    //os << "Name Prefix        : " << Component[4] << std::endl;
    os << Component[0] << '^';
    os << Component[1] << '^';
    os << Component[2] << '^';
    os << Component[3] << '^';
    os << Component[4];
  }
};

} // end namespace gdcm

#endif //GDCMPERSONNAME_H