dcbytstr.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmdata
00019  *
00020  *  Author:  Gerd Ehlers, Andreas Barth
00021  *
00022  *  Purpose: Interface of class DcmByteString
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:27:59 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dcbytstr.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.30 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 
00035 #ifndef DCBYTSTR_H
00036 #define DCBYTSTR_H
00037 
00038 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00039 
00040 #include "dcmtk/ofstd/ofconsol.h"
00041 #include "dcmtk/dcmdata/dcerror.h"
00042 #include "dcmtk/dcmdata/dctypes.h"
00043 #include "dcmtk/dcmdata/dcelem.h"
00044 #include "dcmtk/ofstd/ofstring.h"
00045 
00046 
00049 class DcmByteString
00050   : public DcmElement
00051 {
00052 
00054     enum E_StringMode
00055     {
00057         DCM_MachineString,
00059         DCM_DicomString,
00061         DCM_UnknownString
00062     };
00063 
00064 
00065  public:
00066 
00072     DcmByteString(const DcmTag &tag,
00073                   const Uint32 len = 0);
00074 
00078     DcmByteString(const DcmByteString &old);
00079 
00082     virtual ~DcmByteString();
00083 
00088     DcmByteString& operator=(const DcmByteString& obj);
00089 
00093     virtual DcmObject *clone() const
00094     {
00095       return new DcmByteString(*this);
00096     }
00097 
00101     virtual DcmEVR ident() const;
00102 
00106     virtual OFCondition clear();
00107 
00111     virtual unsigned long getVM();
00112 
00117     Uint32 getRealLength();
00118 
00126     virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
00127                              const E_EncodingType enctype = EET_UndefinedLength);
00128 
00138     virtual void print(ostream &out,
00139                        const size_t flags = 0,
00140                        const int level = 0,
00141                        const char *pixelFileName = NULL,
00142                        size_t *pixelCounter = NULL);
00143 
00149     virtual OFCondition write(DcmOutputStream &outStream,
00150                               const E_TransferSyntax writeXfer,
00151                               const E_EncodingType encodingType = EET_UndefinedLength);
00152 
00158     virtual OFCondition writeSignatureFormat(DcmOutputStream &outStream,
00159                                              const E_TransferSyntax writeXfer,
00160                                              const E_EncodingType encodingType = EET_UndefinedLength);
00161 
00168     virtual OFCondition getOFString(OFString &stringVal,
00169                                     const unsigned long pos,
00170                                     OFBool normalize = OFTrue);
00171 
00178     virtual OFCondition getString(char *&stringVal);
00179 
00184     virtual OFCondition putString(const char *stringVal);
00185 
00190     virtual OFCondition putOFStringArray(const OFString &stringVal);
00191 
00198     virtual OFCondition verify(const OFBool autocorrect = OFFalse);
00199 
00200 
00201  protected:
00202 
00209     virtual Uint8 *newValueField();
00210 
00214     virtual void postLoadValue();
00215 
00220     virtual OFCondition makeMachineByteString();
00221 
00227     OFCondition makeDicomByteString();
00228 
00234     OFCondition getStringValue(OFString &stringVal);
00235 
00237     char paddingChar;
00239     Uint32 maxLength;
00240 
00241 
00242  private:
00243 
00245     Uint32 realLength;
00247     E_StringMode fStringMode;
00248 };
00249 
00250 
00255 
00257 const OFBool DELETE_TRAILING = OFTrue;
00259 const OFBool DELETE_LEADING = OFTrue;
00261 const OFBool MULTIPART = OFTrue;
00262 
00264 
00265 
00266 /* Function to get part out of a String for VM > 1 */
00267 
00275 OFCondition getStringPart(OFString &result,
00276                           const char *orgStr,
00277                           const unsigned long pos);
00278 
00279 
00286 void normalizeString(OFString &string,
00287                      const OFBool multiPart,
00288                      const OFBool leading,
00289                      const OFBool trailing);
00290 
00291 
00292 #endif // DCBYTSTR_H
00293 
00294 
00295 /*
00296 ** CVS/RCS Log:
00297 ** $Log: dcbytstr.h,v $
00298 ** Revision 1.30  2005/12/08 16:27:59  meichel
00299 ** Changed include path schema for all DCMTK header files
00300 **
00301 ** Revision 1.29  2004/07/01 12:28:25  meichel
00302 ** Introduced virtual clone method for DcmObject and derived classes.
00303 **
00304 ** Revision 1.28  2003/07/04 13:25:35  meichel
00305 ** Replaced forward declarations for OFString with explicit includes,
00306 **   needed when compiling with HAVE_STD_STRING
00307 **
00308 ** Revision 1.27  2003/06/12 13:35:54  joergr
00309 ** Fixed inconsistent API documentation reported by Doxygen.
00310 **
00311 ** Revision 1.26  2002/12/10 17:41:22  meichel
00312 ** Removed typedef to avoid warnings on various compilers
00313 **
00314 ** Revision 1.25  2002/12/06 12:49:07  joergr
00315 ** Enhanced "print()" function by re-working the implementation and replacing
00316 ** the boolean "showFullData" parameter by a more general integer flag.
00317 ** Added doc++ documentation.
00318 ** Made source code formatting more consistent with other modules/files.
00319 **
00320 ** Revision 1.24  2002/08/27 16:55:30  meichel
00321 ** Initial release of new DICOM I/O stream classes that add support for stream
00322 **   compression (deflated little endian explicit VR transfer syntax)
00323 **
00324 ** Revision 1.23  2002/04/25 10:05:14  joergr
00325 ** Removed getOFStringArray() implementation.
00326 ** Made makeMachineByteString() virtual to avoid ambiguities.
00327 **
00328 ** Revision 1.22  2001/09/25 17:19:24  meichel
00329 ** Adapted dcmdata to class OFCondition
00330 **
00331 ** Revision 1.21  2001/06/01 15:48:33  meichel
00332 ** Updated copyright header
00333 **
00334 ** Revision 1.20  2000/11/07 16:56:05  meichel
00335 ** Initial release of dcmsign module for DICOM Digital Signatures
00336 **
00337 ** Revision 1.19  2000/04/14 15:31:31  meichel
00338 ** Removed default value from output stream passed to print() method.
00339 **   Required for use in multi-thread environments.
00340 **
00341 ** Revision 1.18  2000/03/08 16:26:11  meichel
00342 ** Updated copyright header.
00343 **
00344 ** Revision 1.17  2000/03/03 14:05:22  meichel
00345 ** Implemented library support for redirecting error messages into memory
00346 **   instead of printing them to stdout/stderr for GUI applications.
00347 **
00348 ** Revision 1.16  2000/02/10 10:50:49  joergr
00349 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
00350 ** pixel data/item value fields to raw files.
00351 **
00352 ** Revision 1.15  1999/03/31 09:24:30  meichel
00353 ** Updated copyright header in module dcmdata
00354 **
00355 ** Revision 1.14  1998/11/12 16:47:36  meichel
00356 ** Implemented operator= for all classes derived from DcmObject.
00357 **
00358 ** Revision 1.13  1997/09/11 15:13:09  hewett
00359 ** Modified getOFString method arguments by removing a default value
00360 ** for the pos argument.  By requiring the pos argument to be provided
00361 ** ensures that callers realise getOFString only gets one component of
00362 ** a multi-valued string.
00363 **
00364 ** Revision 1.12  1997/08/29 13:11:38  andreas
00365 ** Corrected Bug in getOFStringArray Implementation
00366 **
00367 ** Revision 1.11  1997/08/29 08:32:37  andreas
00368 ** - Added methods getOFString and getOFStringArray for all
00369 **   string VRs. These methods are able to normalise the value, i. e.
00370 **   to remove leading and trailing spaces. This will be done only if
00371 **   it is described in the standard that these spaces are not relevant.
00372 **   These methods do not test the strings for conformance, this means
00373 **   especially that they do not delete spaces where they are not allowed!
00374 **   getOFStringArray returns the string with all its parts separated by \
00375 **   and getOFString returns only one value of the string.
00376 **   CAUTION: Currently getString returns a string with trailing
00377 **   spaces removed (if dcmEnableAutomaticInputDataCorrection == OFTrue) and
00378 **   truncates the original string (since it is not copied!). If you rely on this
00379 **   behaviour please change your application now.
00380 **   Future changes will ensure that getString returns the original
00381 **   string from the DICOM object (NULL terminated) inclusive padding.
00382 **   Currently, if you call getOF... before calling getString without
00383 **   normalisation, you can get the original string read from the DICOM object.
00384 **
00385 ** Revision 1.10  1997/07/21 08:25:05  andreas
00386 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00387 **   with one unique boolean type OFBool.
00388 **
00389 ** Revision 1.9  1997/05/16 08:31:19  andreas
00390 ** - Revised handling of GroupLength elements and support of
00391 **   DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
00392 **   got additional enumeration values (for a description see dctypes.h).
00393 **   addGroupLength and removeGroupLength methods are replaced by
00394 **   computeGroupLengthAndPadding. To support Padding, the parameters of
00395 **   element and sequence write functions changed.
00396 **
00397 ** Revision 1.8  1997/04/18 08:13:28  andreas
00398 ** - The put/get-methods for all VRs did not conform to the C++-Standard
00399 **   draft. Some Compilers (e.g. SUN-C++ Compiler, Metroworks
00400 **   CodeWarrier, etc.) create many warnings concerning the hiding of
00401 **   overloaded get methods in all derived classes of DcmElement.
00402 **   So the interface of all value representation classes in the
00403 **   library are changed rapidly, e.g.
00404 **   OFCondition get(Uint16 & value, const unsigned long pos);
00405 **   becomes
00406 **   OFCondition getUint16(Uint16 & value, const unsigned long pos);
00407 **   All (retired) "returntype get(...)" methods are deleted.
00408 **   For more information see dcmdata/include/dcelem.h
00409 **
00410 ** Revision 1.7  1996/08/05 08:45:15  andreas
00411 ** new print routine with additional parameters:
00412 **         - print into files
00413 **         - fix output length for elements
00414 ** corrected error in search routine with parameter ESM_fromStackTop
00415 **
00416 ** Revision 1.6  1996/03/12 15:26:52  hewett
00417 ** Removed get method for unsigned char*
00418 **
00419 ** Revision 1.5  1996/01/29 13:38:11  andreas
00420 ** - new put method for every VR to put value as a string
00421 ** - better and unique print methods
00422 **
00423 ** Revision 1.4  1996/01/09 11:06:13  andreas
00424 ** New Support for Visual C++
00425 ** Correct problems with inconsistent const declarations
00426 **
00427 ** Revision 1.3  1996/01/05 13:22:52  andreas
00428 ** - changed to support new streaming facilities
00429 ** - more cleanups
00430 ** - merged read / write methods for block and file transfer
00431 **
00432 */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5