Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GDCMPERSONNAME_H
00017 #define GDCMPERSONNAME_H
00018
00019 #include "gdcmTypes.h"
00020 #include <vector>
00021 #include <algorithm>
00022 #include <string.h>
00023
00024 namespace gdcm
00025 {
00026
00030 class GDCM_EXPORT PersonName
00031 {
00032 public:
00033 static const unsigned int MaxNumberOfComponents = 5;
00034 static const unsigned int MaxLength = 64;
00035 char Component[MaxNumberOfComponents][MaxLength+1];
00036 static const char Separator = '^';
00037 static const char Padding = ' ';
00038
00039 unsigned int GetNumberOfComponents() const {
00040 unsigned int r = 0;
00041 for(unsigned int i = 0; i < 5; ++i) {
00042 if( *Component[i] != '\0' ) r = i;
00043 }
00044 return r+1;
00045 }
00046 unsigned int GetMaxLength() const { return MaxLength; };
00047 void SetBlob(const std::vector<char>& v) {
00048 (void)v;
00049
00050 }
00051 void SetComponents(const char *comp1 = "",
00052 const char *comp2 = "",
00053 const char *comp3 = "",
00054 const char *comp4 = "",
00055 const char *comp5 = "") {
00056 const char *components[5] = { comp1, comp2, comp3, comp4, comp5 };
00057 SetComponents( components );
00058 }
00059 void SetComponents(const char *components[]) {
00060 for(unsigned int i = 0; i < 5; ++i) {
00061
00062 assert( strlen(components[i]) < GetMaxLength() );
00063 strcpy(Component[i], components[i]);
00064 assert( strlen(Component[i]) < GetMaxLength() );
00065 }
00066 }
00067 void Print(std::ostream &os) const
00068 {
00069
00070
00071
00072
00073
00074 os << Component[0] << '^';
00075 os << Component[1] << '^';
00076 os << Component[2] << '^';
00077 os << Component[3] << '^';
00078 os << Component[4];
00079 }
00080 };
00081
00082 }
00083
00084 #endif //GDCMPERSONNAME_H
00085