00001 /* 00002 * 00003 * Copyright (C) 1994-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmdata 00015 * 00016 * Author: Gerd Ehlers, Joerg Riesmeier 00017 * 00018 * Purpose: Interface of class DcmDateTime 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-11-05 09:34:11 $ 00022 * CVS/RCS Revision: $Revision: 1.29 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCVRDT_H 00030 #define DCVRDT_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 00034 #include "dcmtk/dcmdata/dcbytstr.h" 00035 #include "dcmtk/ofstd/ofdatime.h" 00036 00037 00040 class DcmDateTime 00041 : public DcmByteString 00042 { 00043 00044 public: 00045 00051 DcmDateTime(const DcmTag &tag, 00052 const Uint32 len = 0); 00053 00057 DcmDateTime(const DcmDateTime &old); 00058 00061 virtual ~DcmDateTime(); 00062 00067 DcmDateTime &operator=(const DcmDateTime &obj); 00068 00072 virtual DcmObject *clone() const 00073 { 00074 return new DcmDateTime(*this); 00075 } 00076 00089 virtual OFCondition copyFrom(const DcmObject& rhs); 00090 00094 virtual DcmEVR ident() const; 00095 00103 virtual OFCondition checkValue(const OFString &vm = "1-n", 00104 const OFBool oldFormat = OFFalse); 00105 00112 virtual OFCondition getOFString(OFString &stringValue, 00113 const unsigned long pos, 00114 OFBool normalize = OFTrue); 00115 00129 OFCondition setCurrentDateTime(const OFBool seconds = OFTrue, 00130 const OFBool fraction = OFFalse, 00131 const OFBool timeZone = OFFalse); 00132 00137 OFCondition setOFDateTime(const OFDateTime &dateTimeValue); 00138 00148 OFCondition getOFDateTime(OFDateTime &dateTimeValue, 00149 const unsigned long pos = 0); 00150 00169 OFCondition getISOFormattedDateTime(OFString &formattedDateTime, 00170 const unsigned long pos = 0, 00171 const OFBool seconds = OFTrue, 00172 const OFBool fraction = OFFalse, 00173 const OFBool timeZone = OFTrue, 00174 const OFBool createMissingPart = OFFalse); 00175 00194 OFCondition getISOFormattedDateTime(OFString &formattedDateTime, 00195 const unsigned long pos /*= 0*/, 00196 const OFBool seconds /*= OFTrue*/, 00197 const OFBool fraction /*= OFFalse*/, 00198 const OFBool timeZone /*= OFTrue*/, 00199 const OFBool createMissingPart /*= OFFalse*/, 00200 const OFString &dateTimeSeparator /*= " "*/); 00201 00202 /* --- static helper functions --- */ 00203 00218 static OFCondition getCurrentDateTime(OFString &dicomDateTime, 00219 const OFBool seconds = OFTrue, 00220 const OFBool fraction = OFFalse, 00221 const OFBool timeZone = OFFalse); 00222 00238 static OFCondition getDicomDateTimeFromOFDateTime(const OFDateTime &dateTimeValue, 00239 OFString &dicomDateTime, 00240 const OFBool seconds = OFTrue, 00241 const OFBool fraction = OFFalse, 00242 const OFBool timeZone = OFFalse); 00243 00253 static OFCondition getOFDateTimeFromString(const OFString &dicomDateTime, 00254 OFDateTime &dateTimeValue); 00255 00274 static OFCondition getISOFormattedDateTimeFromString(const OFString &dicomDateTime, 00275 OFString &formattedDateTime, 00276 const OFBool seconds = OFTrue, 00277 const OFBool fraction = OFFalse, 00278 const OFBool timeZone = OFTrue, 00279 const OFBool createMissingPart = OFFalse); 00280 00299 static OFCondition getISOFormattedDateTimeFromString(const OFString &dicomDateTime, 00300 OFString &formattedDateTime, 00301 const OFBool seconds /*= OFTrue*/, 00302 const OFBool fraction /*= OFFalse*/, 00303 const OFBool timeZone /*= OFTrue*/, 00304 const OFBool createMissingPart /*= OFFalse*/, 00305 const OFString &dateTimeSeparator /*= " "*/); 00306 00315 static OFCondition checkStringValue(const OFString &value, 00316 const OFString &vm = "1-n"); 00317 }; 00318 00319 00320 #endif // DCVRDT_H 00321 00322 00323 /* 00324 ** CVS/RCS Log: 00325 ** $Log: dcvrdt.h,v $ 00326 ** Revision 1.29 2010-11-05 09:34:11 joergr 00327 ** Added support for checking the value multiplicity "9" (see Supplement 131). 00328 ** 00329 ** Revision 1.28 2010-10-14 13:15:42 joergr 00330 ** Updated copyright header. Added reference to COPYRIGHT file. 00331 ** 00332 ** Revision 1.27 2010-04-23 15:26:13 joergr 00333 ** Specify an appropriate default value for the "vm" parameter of checkValue(). 00334 ** 00335 ** Revision 1.26 2010-04-23 14:25:27 joergr 00336 ** Added new method to all VR classes which checks whether the stored value 00337 ** conforms to the VR definition and to the specified VM. 00338 ** 00339 ** Revision 1.25 2010-04-22 09:31:30 joergr 00340 ** Revised misleading parameter documentation for the checkValue() method. 00341 ** 00342 ** Revision 1.24 2010-04-22 08:59:10 joergr 00343 ** Added support for further VM values ("1-8", "1-99", "16", "32") to be checked. 00344 ** 00345 ** Revision 1.23 2010-03-01 09:08:45 uli 00346 ** Removed some unnecessary include directives in the headers. 00347 ** 00348 ** Revision 1.22 2009-08-03 09:05:30 joergr 00349 ** Added methods that check whether a given string value conforms to the VR and 00350 ** VM definitions of the DICOM standards. 00351 ** 00352 ** Revision 1.21 2008-07-17 11:19:49 onken 00353 ** Updated copyFrom() documentation. 00354 ** 00355 ** Revision 1.20 2008-07-17 10:30:23 onken 00356 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which 00357 ** permits setting an instance's value from an existing object. Implemented 00358 ** assignment operator where necessary. 00359 ** 00360 ** Revision 1.19 2005-12-08 16:28:57 meichel 00361 ** Changed include path schema for all DCMTK header files 00362 ** 00363 ** Revision 1.18 2004/07/01 12:28:25 meichel 00364 ** Introduced virtual clone method for DcmObject and derived classes. 00365 ** 00366 ** Revision 1.17 2004/04/16 12:49:25 joergr 00367 ** Restructured code to avoid default parameter values for "complex types" like 00368 ** OFString. Required for Sun CC 2.0.1. 00369 ** 00370 ** Revision 1.16 2004/01/16 14:04:11 joergr 00371 ** Introduced new parameter "dateTimeSeparator" in getISOFormattedXXX() methods 00372 ** to support ISO 8601 format as required by XML Schema type "dateTime". 00373 ** 00374 ** Revision 1.15 2002/12/06 12:49:15 joergr 00375 ** Enhanced "print()" function by re-working the implementation and replacing 00376 ** the boolean "showFullData" parameter by a more general integer flag. 00377 ** Added doc++ documentation. 00378 ** Made source code formatting more consistent with other modules/files. 00379 ** 00380 ** Revision 1.14 2002/04/25 09:51:08 joergr 00381 ** Removed getOFStringArray() implementation. 00382 ** 00383 ** Revision 1.13 2002/04/11 12:25:09 joergr 00384 ** Enhanced DICOM date, time and date/time classes. Added support for new 00385 ** standard date and time functions. 00386 ** 00387 ** Revision 1.12 2001/10/10 15:17:37 joergr 00388 ** Updated comments. 00389 ** 00390 ** Revision 1.11 2001/10/01 15:01:39 joergr 00391 ** Introduced new general purpose functions to get/set person names, date, time 00392 ** and date/time. 00393 ** 00394 ** Revision 1.10 2001/09/25 17:19:31 meichel 00395 ** Adapted dcmdata to class OFCondition 00396 ** 00397 ** Revision 1.9 2001/06/01 15:48:49 meichel 00398 ** Updated copyright header 00399 ** 00400 ** Revision 1.8 2000/03/08 16:26:23 meichel 00401 ** Updated copyright header. 00402 ** 00403 ** Revision 1.7 1999/03/31 09:24:59 meichel 00404 ** Updated copyright header in module dcmdata 00405 ** 00406 ** Revision 1.6 1998/11/12 16:47:48 meichel 00407 ** Implemented operator= for all classes derived from DcmObject. 00408 ** 00409 ** Revision 1.5 1997/09/11 15:13:14 hewett 00410 ** Modified getOFString method arguments by removing a default value 00411 ** for the pos argument. By requiring the pos argument to be provided 00412 ** ensures that callers realise getOFString only gets one component of 00413 ** a multi-valued string. 00414 ** 00415 ** Revision 1.4 1997/08/29 08:32:41 andreas 00416 ** - Added methods getOFString and getOFStringArray for all 00417 ** string VRs. These methods are able to normalise the value, i. e. 00418 ** to remove leading and trailing spaces. This will be done only if 00419 ** it is described in the standard that these spaces are not relevant. 00420 ** These methods do not test the strings for conformance, this means 00421 ** especially that they do not delete spaces where they are not allowed! 00422 ** getOFStringArray returns the string with all its parts separated by \ 00423 ** and getOFString returns only one value of the string. 00424 ** CAUTION: Currently getString returns a string with trailing 00425 ** spaces removed (if dcmEnableAutomaticInputDataCorrection == OFTrue) and 00426 ** truncates the original string (since it is not copied!). If you rely on this 00427 ** behaviour please change your application now. 00428 ** Future changes will ensure that getString returns the original 00429 ** string from the DICOM object (NULL terminated) inclusive padding. 00430 ** Currently, if you call getOF... before calling getString without 00431 ** normalisation, you can get the original string read from the DICOM object. 00432 ** 00433 ** Revision 1.3 1996/01/05 13:23:05 andreas 00434 ** - changed to support new streaming facilities 00435 ** - more cleanups 00436 ** - merged read / write methods for block and file transfer 00437 ** 00438 */