dcmdata/include/dcmtk/dcmdata/dcbytstr.h

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, Andreas Barth
00017  *
00018  *  Purpose: Interface of class DcmByteString
00019  *
00020  *  Last Update:      $Author: joergr $
00021  *  Update Date:      $Date: 2010-11-05 09:34:11 $
00022  *  CVS/RCS Revision: $Revision: 1.46 $
00023  *  Status:           $State: Exp $
00024  *
00025  *  CVS/RCS Log at end of file
00026  *
00027  */
00028 
00029 
00030 #ifndef DCBYTSTR_H
00031 #define DCBYTSTR_H
00032 
00033 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00034 
00035 #include "dcmtk/dcmdata/dctypes.h"
00036 #include "dcmtk/dcmdata/dcelem.h"
00037 #include "dcmtk/ofstd/ofstring.h"
00038 
00039 
00042 class DcmByteString: public DcmElement
00043 {
00044 
00046     enum E_StringMode
00047     {
00049         DCM_MachineString,
00051         DCM_DicomString,
00053         DCM_UnknownString
00054     };
00055 
00056 
00057  public:
00058 
00064     DcmByteString(const DcmTag &tag,
00065                   const Uint32 len = 0);
00066 
00070     DcmByteString(const DcmByteString &old);
00071 
00074     virtual ~DcmByteString();
00075 
00080     DcmByteString& operator=(const DcmByteString& obj);
00081 
00085     virtual DcmObject *clone() const
00086     {
00087       return new DcmByteString(*this);
00088     }
00089 
00102     virtual OFCondition copyFrom(const DcmObject& rhs);
00103 
00107     virtual DcmEVR ident() const;
00108 
00112     virtual OFCondition clear();
00113 
00117     virtual unsigned long getVM();
00118 
00123     Uint32 getRealLength();
00124 
00132     virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00133                              const E_EncodingType enctype = EET_UndefinedLength);
00134 
00144     virtual void print(STD_NAMESPACE ostream&out,
00145                        const size_t flags = 0,
00146                        const int level = 0,
00147                        const char *pixelFileName = NULL,
00148                        size_t *pixelCounter = NULL);
00149 
00156     virtual OFCondition write(DcmOutputStream &outStream,
00157                               const E_TransferSyntax oxfer,
00158                               const E_EncodingType enctype,
00159                               DcmWriteCache *wcache);
00160 
00167     virtual OFCondition writeSignatureFormat(
00168       DcmOutputStream &outStream,
00169       const E_TransferSyntax oxfer,
00170       const E_EncodingType enctype,
00171       DcmWriteCache *wcache);
00172 
00179     virtual OFCondition getOFString(OFString &stringVal,
00180                                     const unsigned long pos,
00181                                     OFBool normalize = OFTrue);
00182 
00189     virtual OFCondition getString(char *&stringVal);
00190 
00195     virtual OFCondition putString(const char *stringVal);
00196 
00201     virtual OFCondition putOFStringArray(const OFString &stringVal);
00202 
00209     virtual OFCondition verify(const OFBool autocorrect = OFFalse);
00210 
00216     virtual OFBool containsExtendedCharacters(const OFBool checkAllStrings = OFFalse);
00217 
00221     virtual OFBool isAffectedBySpecificCharacterSet() const;
00222 
00227     virtual OFBool isEmpty(const OFBool normalize = OFTrue);
00228 
00229  protected:
00230 
00237     virtual Uint8 *newValueField();
00238 
00242     virtual void postLoadValue();
00243 
00248     virtual OFCondition makeMachineByteString();
00249 
00255     OFCondition makeDicomByteString();
00256 
00262     OFCondition getStringValue(OFString &stringVal);
00263 
00267     void setPaddingChar(char c) { paddingChar = c; }
00268 
00272     void setMaxLength(Uint32 val) { maxLength = val; }
00273 
00277     void setNonSignificantChars(const OFString &characters) { nonSignificantChars = characters; }
00278 
00279     /* --- static helper functions --- */
00280 
00291     static OFCondition checkStringValue(const OFString &value,
00292                                         const OFString &vm,
00293                                         const OFString &vr,
00294                                         const int vrID,
00295                                         const size_t maxLen = 0);
00296 
00297 private:
00298 
00300     char paddingChar;
00301 
00303     Uint32 maxLength;
00304 
00306     Uint32 realLength;
00307 
00309     E_StringMode fStringMode;
00310 
00312     OFString nonSignificantChars;
00313 };
00314 
00315 
00320 
00322 const OFBool DELETE_TRAILING = OFTrue;
00324 const OFBool DELETE_LEADING = OFTrue;
00326 const OFBool MULTIPART = OFTrue;
00327 
00329 
00330 
00331 /* Function to get part out of a String for VM > 1 */
00332 
00340 OFCondition getStringPart(OFString &result,
00341                           const char *orgStr,
00342                           const unsigned long pos);
00343 
00344 
00351 void normalizeString(OFString &string,
00352                      const OFBool multiPart,
00353                      const OFBool leading,
00354                      const OFBool trailing);
00355 
00356 
00357 #endif // DCBYTSTR_H
00358 
00359 
00360 /*
00361 ** CVS/RCS Log:
00362 ** $Log: dcbytstr.h,v $
00363 ** Revision 1.46  2010-11-05 09:34:11  joergr
00364 ** Added support for checking the value multiplicity "9" (see Supplement 131).
00365 **
00366 ** Revision 1.45  2010-10-14 13:15:40  joergr
00367 ** Updated copyright header. Added reference to COPYRIGHT file.
00368 **
00369 ** Revision 1.44  2010-04-23 14:29:28  joergr
00370 ** Renamed static helper function checkValue() to checkStringValue().
00371 **
00372 ** Revision 1.43  2010-04-22 09:01:18  joergr
00373 ** Added support for further VM values ("1-8", "1-99", "16", "32") to be checked.
00374 **
00375 ** Revision 1.42  2010-02-22 11:39:53  uli
00376 ** Remove some unneeded includes.
00377 **
00378 ** Revision 1.41  2009-08-07 14:40:38  joergr
00379 ** Enhanced isEmpty() method by checking whether the data element value consists
00380 ** of non-significant characters only.
00381 **
00382 ** Revision 1.40  2009-08-03 09:05:29  joergr
00383 ** Added methods that check whether a given string value conforms to the VR and
00384 ** VM definitions of the DICOM standards.
00385 **
00386 ** Revision 1.39  2008-07-17 11:19:48  onken
00387 ** Updated copyFrom() documentation.
00388 **
00389 ** Revision 1.38  2008-07-17 10:30:22  onken
00390 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
00391 ** permits setting an instance's value from an existing object. Implemented
00392 ** assignment operator where necessary.
00393 **
00394 ** Revision 1.37  2008-06-23 12:09:13  joergr
00395 ** Fixed inconsistencies in Doxygen API documentation.
00396 **
00397 ** Revision 1.36  2007/11/29 14:30:19  meichel
00398 ** Write methods now handle large raw data elements (such as pixel data)
00399 **   without loading everything into memory. This allows very large images to
00400 **   be sent over a network connection, or to be copied without ever being
00401 **   fully in memory.
00402 **
00403 ** Revision 1.35  2007/06/29 14:17:49  meichel
00404 ** Code clean-up: Most member variables in module dcmdata are now private,
00405 **   not protected anymore.
00406 **
00407 ** Revision 1.34  2006/12/15 14:18:07  joergr
00408 ** Added new method that checks whether a DICOM object or element is affected
00409 ** by SpecificCharacterSet (0008,0005).
00410 **
00411 ** Revision 1.33  2006/12/13 13:58:15  joergr
00412 ** Added new optional parameter "checkAllStrings" to method containsExtended
00413 ** Characters().
00414 **
00415 ** Revision 1.32  2006/11/08 17:00:06  meichel
00416 ** Added DcmByteString::containsExtendedCharacters
00417 **
00418 ** Revision 1.31  2006/08/15 15:49:56  meichel
00419 ** Updated all code in module dcmdata to correctly compile when
00420 **   all standard C++ classes remain in namespace std.
00421 **
00422 ** Revision 1.30  2005/12/08 16:27:59  meichel
00423 ** Changed include path schema for all DCMTK header files
00424 **
00425 ** Revision 1.29  2004/07/01 12:28:25  meichel
00426 ** Introduced virtual clone method for DcmObject and derived classes.
00427 **
00428 ** Revision 1.28  2003/07/04 13:25:35  meichel
00429 ** Replaced forward declarations for OFString with explicit includes,
00430 **   needed when compiling with HAVE_STD_STRING
00431 **
00432 ** Revision 1.27  2003/06/12 13:35:54  joergr
00433 ** Fixed inconsistent API documentation reported by Doxygen.
00434 **
00435 ** Revision 1.26  2002/12/10 17:41:22  meichel
00436 ** Removed typedef to avoid warnings on various compilers
00437 **
00438 ** Revision 1.25  2002/12/06 12:49:07  joergr
00439 ** Enhanced "print()" function by re-working the implementation and replacing
00440 ** the boolean "showFullData" parameter by a more general integer flag.
00441 ** Added doc++ documentation.
00442 ** Made source code formatting more consistent with other modules/files.
00443 **
00444 ** Revision 1.24  2002/08/27 16:55:30  meichel
00445 ** Initial release of new DICOM I/O stream classes that add support for stream
00446 **   compression (deflated little endian explicit VR transfer syntax)
00447 **
00448 ** Revision 1.23  2002/04/25 10:05:14  joergr
00449 ** Removed getOFStringArray() implementation.
00450 ** Made makeMachineByteString() virtual to avoid ambiguities.
00451 **
00452 ** Revision 1.22  2001/09/25 17:19:24  meichel
00453 ** Adapted dcmdata to class OFCondition
00454 **
00455 ** Revision 1.21  2001/06/01 15:48:33  meichel
00456 ** Updated copyright header
00457 **
00458 ** Revision 1.20  2000/11/07 16:56:05  meichel
00459 ** Initial release of dcmsign module for DICOM Digital Signatures
00460 **
00461 ** Revision 1.19  2000/04/14 15:31:31  meichel
00462 ** Removed default value from output stream passed to print() method.
00463 **   Required for use in multi-thread environments.
00464 **
00465 ** Revision 1.18  2000/03/08 16:26:11  meichel
00466 ** Updated copyright header.
00467 **
00468 ** Revision 1.17  2000/03/03 14:05:22  meichel
00469 ** Implemented library support for redirecting error messages into memory
00470 **   instead of printing them to stdout/stderr for GUI applications.
00471 **
00472 ** Revision 1.16  2000/02/10 10:50:49  joergr
00473 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00474 ** pixel data/item value fields to raw files.
00475 **
00476 ** Revision 1.15  1999/03/31 09:24:30  meichel
00477 ** Updated copyright header in module dcmdata
00478 **
00479 ** Revision 1.14  1998/11/12 16:47:36  meichel
00480 ** Implemented operator= for all classes derived from DcmObject.
00481 **
00482 ** Revision 1.13  1997/09/11 15:13:09  hewett
00483 ** Modified getOFString method arguments by removing a default value
00484 ** for the pos argument.  By requiring the pos argument to be provided
00485 ** ensures that callers realise getOFString only gets one component of
00486 ** a multi-valued string.
00487 **
00488 ** Revision 1.12  1997/08/29 13:11:38  andreas
00489 ** Corrected Bug in getOFStringArray Implementation
00490 **
00491 ** Revision 1.11  1997/08/29 08:32:37  andreas
00492 ** - Added methods getOFString and getOFStringArray for all
00493 **   string VRs. These methods are able to normalise the value, i. e.
00494 **   to remove leading and trailing spaces. This will be done only if
00495 **   it is described in the standard that these spaces are not relevant.
00496 **   These methods do not test the strings for conformance, this means
00497 **   especially that they do not delete spaces where they are not allowed!
00498 **   getOFStringArray returns the string with all its parts separated by \
00499 **   and getOFString returns only one value of the string.
00500 **   CAUTION: Currently getString returns a string with trailing
00501 **   spaces removed (if dcmEnableAutomaticInputDataCorrection == OFTrue) and
00502 **   truncates the original string (since it is not copied!). If you rely on this
00503 **   behaviour please change your application now.
00504 **   Future changes will ensure that getString returns the original
00505 **   string from the DICOM object (NULL terminated) inclusive padding.
00506 **   Currently, if you call getOF... before calling getString without
00507 **   normalisation, you can get the original string read from the DICOM object.
00508 **
00509 ** Revision 1.10  1997/07/21 08:25:05  andreas
00510 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00511 **   with one unique boolean type OFBool.
00512 **
00513 ** Revision 1.9  1997/05/16 08:31:19  andreas
00514 ** - Revised handling of GroupLength elements and support of
00515 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00516 **   got additional enumeration values (for a description see dctypes.h).
00517 **   addGroupLength and removeGroupLength methods are replaced by
00518 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00519 **   element and sequence write functions changed.
00520 **
00521 ** Revision 1.8  1997/04/18 08:13:28  andreas
00522 ** - The put/get-methods for all VRs did not conform to the C++-Standard
00523 **   draft. Some Compilers (e.g. SUN-C++ Compiler, Metroworks
00524 **   CodeWarrier, etc.) create many warnings concerning the hiding of
00525 **   overloaded get methods in all derived classes of DcmElement.
00526 **   So the interface of all value representation classes in the
00527 **   library are changed rapidly, e.g.
00528 **   OFCondition get(Uint16 & value, const unsigned long pos);
00529 **   becomes
00530 **   OFCondition getUint16(Uint16 & value, const unsigned long pos);
00531 **   All (retired) "returntype get(...)" methods are deleted.
00532 **   For more information see dcmdata/include/dcelem.h
00533 **
00534 ** Revision 1.7  1996/08/05 08:45:15  andreas
00535 ** new print routine with additional parameters:
00536 **         - print into files
00537 **         - fix output length for elements
00538 ** corrected error in search routine with parameter ESM_fromStackTop
00539 **
00540 ** Revision 1.6  1996/03/12 15:26:52  hewett
00541 ** Removed get method for unsigned char*
00542 **
00543 ** Revision 1.5  1996/01/29 13:38:11  andreas
00544 ** - new put method for every VR to put value as a string
00545 ** - better and unique print methods
00546 **
00547 ** Revision 1.4  1996/01/09 11:06:13  andreas
00548 ** New Support for Visual C++
00549 ** Correct problems with inconsistent const declarations
00550 **
00551 ** Revision 1.3  1996/01/05 13:22:52  andreas
00552 ** - changed to support new streaming facilities
00553 ** - more cleanups
00554 ** - merged read / write methods for block and file transfer
00555 **
00556 */


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1