OFFIS DCMTK  Version 3.6.0
dcbytstr.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Gerd Ehlers, Andreas Barth
17  *
18  * Purpose: Interface of class DcmByteString
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-11-05 09:34:11 $
22  * CVS/RCS Revision: $Revision: 1.46 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DCBYTSTR_H
31 #define DCBYTSTR_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 
35 #include "dcmtk/dcmdata/dctypes.h"
36 #include "dcmtk/dcmdata/dcelem.h"
37 #include "dcmtk/ofstd/ofstring.h"
38 
39 
43 {
44 
47  {
54  };
55 
56 
57  public:
58 
64  DcmByteString(const DcmTag &tag,
65  const Uint32 len = 0);
66 
70  DcmByteString(const DcmByteString &old);
71 
74  virtual ~DcmByteString();
75 
81 
85  virtual DcmObject *clone() const
86  {
87  return new DcmByteString(*this);
88  }
89 
102  virtual OFCondition copyFrom(const DcmObject& rhs);
103 
107  virtual DcmEVR ident() const;
108 
112  virtual OFCondition clear();
113 
117  virtual unsigned long getVM();
118 
123  Uint32 getRealLength();
124 
132  virtual Uint32 getLength(const E_TransferSyntax xfer = EXS_LittleEndianImplicit,
133  const E_EncodingType enctype = EET_UndefinedLength);
134 
144  virtual void print(STD_NAMESPACE ostream&out,
145  const size_t flags = 0,
146  const int level = 0,
147  const char *pixelFileName = NULL,
148  size_t *pixelCounter = NULL);
149 
156  virtual OFCondition write(DcmOutputStream &outStream,
157  const E_TransferSyntax oxfer,
158  const E_EncodingType enctype,
159  DcmWriteCache *wcache);
160 
168  DcmOutputStream &outStream,
169  const E_TransferSyntax oxfer,
170  const E_EncodingType enctype,
171  DcmWriteCache *wcache);
172 
179  virtual OFCondition getOFString(OFString &stringVal,
180  const unsigned long pos,
181  OFBool normalize = OFTrue);
182 
189  virtual OFCondition getString(char *&stringVal);
190 
195  virtual OFCondition putString(const char *stringVal);
196 
201  virtual OFCondition putOFStringArray(const OFString &stringVal);
202 
209  virtual OFCondition verify(const OFBool autocorrect = OFFalse);
210 
216  virtual OFBool containsExtendedCharacters(const OFBool checkAllStrings = OFFalse);
217 
221  virtual OFBool isAffectedBySpecificCharacterSet() const;
222 
227  virtual OFBool isEmpty(const OFBool normalize = OFTrue);
228 
229  protected:
230 
237  virtual Uint8 *newValueField();
238 
242  virtual void postLoadValue();
243 
249 
256 
262  OFCondition getStringValue(OFString &stringVal);
263 
267  void setPaddingChar(char c) { paddingChar = c; }
268 
272  void setMaxLength(Uint32 val) { maxLength = val; }
273 
277  void setNonSignificantChars(const OFString &characters) { nonSignificantChars = characters; }
278 
279  /* --- static helper functions --- */
280 
291  static OFCondition checkStringValue(const OFString &value,
292  const OFString &vm,
293  const OFString &vr,
294  const int vrID,
295  const size_t maxLen = 0);
296 
297 private:
298 
301 
303  Uint32 maxLength;
304 
306  Uint32 realLength;
307 
310 
313 };
314 
315 
320 
322 const OFBool DELETE_TRAILING = OFTrue;
324 const OFBool DELETE_LEADING = OFTrue;
326 const OFBool MULTIPART = OFTrue;
327 
329 
330 
331 /* Function to get part out of a String for VM > 1 */
332 
340 OFCondition getStringPart(OFString &result,
341  const char *orgStr,
342  const unsigned long pos);
343 
344 
351 void normalizeString(OFString &string,
352  const OFBool multiPart,
353  const OFBool leading,
354  const OFBool trailing);
355 
356 
357 #endif // DCBYTSTR_H
358 
359 
360 /*
361 ** CVS/RCS Log:
362 ** $Log: dcbytstr.h,v $
363 ** Revision 1.46 2010-11-05 09:34:11 joergr
364 ** Added support for checking the value multiplicity "9" (see Supplement 131).
365 **
366 ** Revision 1.45 2010-10-14 13:15:40 joergr
367 ** Updated copyright header. Added reference to COPYRIGHT file.
368 **
369 ** Revision 1.44 2010-04-23 14:29:28 joergr
370 ** Renamed static helper function checkValue() to checkStringValue().
371 **
372 ** Revision 1.43 2010-04-22 09:01:18 joergr
373 ** Added support for further VM values ("1-8", "1-99", "16", "32") to be checked.
374 **
375 ** Revision 1.42 2010-02-22 11:39:53 uli
376 ** Remove some unneeded includes.
377 **
378 ** Revision 1.41 2009-08-07 14:40:38 joergr
379 ** Enhanced isEmpty() method by checking whether the data element value consists
380 ** of non-significant characters only.
381 **
382 ** Revision 1.40 2009-08-03 09:05:29 joergr
383 ** Added methods that check whether a given string value conforms to the VR and
384 ** VM definitions of the DICOM standards.
385 **
386 ** Revision 1.39 2008-07-17 11:19:48 onken
387 ** Updated copyFrom() documentation.
388 **
389 ** Revision 1.38 2008-07-17 10:30:22 onken
390 ** Implemented copyFrom() method for complete DcmObject class hierarchy, which
391 ** permits setting an instance's value from an existing object. Implemented
392 ** assignment operator where necessary.
393 **
394 ** Revision 1.37 2008-06-23 12:09:13 joergr
395 ** Fixed inconsistencies in Doxygen API documentation.
396 **
397 ** Revision 1.36 2007/11/29 14:30:19 meichel
398 ** Write methods now handle large raw data elements (such as pixel data)
399 ** without loading everything into memory. This allows very large images to
400 ** be sent over a network connection, or to be copied without ever being
401 ** fully in memory.
402 **
403 ** Revision 1.35 2007/06/29 14:17:49 meichel
404 ** Code clean-up: Most member variables in module dcmdata are now private,
405 ** not protected anymore.
406 **
407 ** Revision 1.34 2006/12/15 14:18:07 joergr
408 ** Added new method that checks whether a DICOM object or element is affected
409 ** by SpecificCharacterSet (0008,0005).
410 **
411 ** Revision 1.33 2006/12/13 13:58:15 joergr
412 ** Added new optional parameter "checkAllStrings" to method containsExtended
413 ** Characters().
414 **
415 ** Revision 1.32 2006/11/08 17:00:06 meichel
416 ** Added DcmByteString::containsExtendedCharacters
417 **
418 ** Revision 1.31 2006/08/15 15:49:56 meichel
419 ** Updated all code in module dcmdata to correctly compile when
420 ** all standard C++ classes remain in namespace std.
421 **
422 ** Revision 1.30 2005/12/08 16:27:59 meichel
423 ** Changed include path schema for all DCMTK header files
424 **
425 ** Revision 1.29 2004/07/01 12:28:25 meichel
426 ** Introduced virtual clone method for DcmObject and derived classes.
427 **
428 ** Revision 1.28 2003/07/04 13:25:35 meichel
429 ** Replaced forward declarations for OFString with explicit includes,
430 ** needed when compiling with HAVE_STD_STRING
431 **
432 ** Revision 1.27 2003/06/12 13:35:54 joergr
433 ** Fixed inconsistent API documentation reported by Doxygen.
434 **
435 ** Revision 1.26 2002/12/10 17:41:22 meichel
436 ** Removed typedef to avoid warnings on various compilers
437 **
438 ** Revision 1.25 2002/12/06 12:49:07 joergr
439 ** Enhanced "print()" function by re-working the implementation and replacing
440 ** the boolean "showFullData" parameter by a more general integer flag.
441 ** Added doc++ documentation.
442 ** Made source code formatting more consistent with other modules/files.
443 **
444 ** Revision 1.24 2002/08/27 16:55:30 meichel
445 ** Initial release of new DICOM I/O stream classes that add support for stream
446 ** compression (deflated little endian explicit VR transfer syntax)
447 **
448 ** Revision 1.23 2002/04/25 10:05:14 joergr
449 ** Removed getOFStringArray() implementation.
450 ** Made makeMachineByteString() virtual to avoid ambiguities.
451 **
452 ** Revision 1.22 2001/09/25 17:19:24 meichel
453 ** Adapted dcmdata to class OFCondition
454 **
455 ** Revision 1.21 2001/06/01 15:48:33 meichel
456 ** Updated copyright header
457 **
458 ** Revision 1.20 2000/11/07 16:56:05 meichel
459 ** Initial release of dcmsign module for DICOM Digital Signatures
460 **
461 ** Revision 1.19 2000/04/14 15:31:31 meichel
462 ** Removed default value from output stream passed to print() method.
463 ** Required for use in multi-thread environments.
464 **
465 ** Revision 1.18 2000/03/08 16:26:11 meichel
466 ** Updated copyright header.
467 **
468 ** Revision 1.17 2000/03/03 14:05:22 meichel
469 ** Implemented library support for redirecting error messages into memory
470 ** instead of printing them to stdout/stderr for GUI applications.
471 **
472 ** Revision 1.16 2000/02/10 10:50:49 joergr
473 ** Added new feature to dcmdump (enhanced print method of dcmdata): write
474 ** pixel data/item value fields to raw files.
475 **
476 ** Revision 1.15 1999/03/31 09:24:30 meichel
477 ** Updated copyright header in module dcmdata
478 **
479 ** Revision 1.14 1998/11/12 16:47:36 meichel
480 ** Implemented operator= for all classes derived from DcmObject.
481 **
482 ** Revision 1.13 1997/09/11 15:13:09 hewett
483 ** Modified getOFString method arguments by removing a default value
484 ** for the pos argument. By requiring the pos argument to be provided
485 ** ensures that callers realise getOFString only gets one component of
486 ** a multi-valued string.
487 **
488 ** Revision 1.12 1997/08/29 13:11:38 andreas
489 ** Corrected Bug in getOFStringArray Implementation
490 **
491 ** Revision 1.11 1997/08/29 08:32:37 andreas
492 ** - Added methods getOFString and getOFStringArray for all
493 ** string VRs. These methods are able to normalise the value, i. e.
494 ** to remove leading and trailing spaces. This will be done only if
495 ** it is described in the standard that these spaces are not relevant.
496 ** These methods do not test the strings for conformance, this means
497 ** especially that they do not delete spaces where they are not allowed!
498 ** getOFStringArray returns the string with all its parts separated by \
499 ** and getOFString returns only one value of the string.
500 ** CAUTION: Currently getString returns a string with trailing
501 ** spaces removed (if dcmEnableAutomaticInputDataCorrection == OFTrue) and
502 ** truncates the original string (since it is not copied!). If you rely on this
503 ** behaviour please change your application now.
504 ** Future changes will ensure that getString returns the original
505 ** string from the DICOM object (NULL terminated) inclusive padding.
506 ** Currently, if you call getOF... before calling getString without
507 ** normalisation, you can get the original string read from the DICOM object.
508 **
509 ** Revision 1.10 1997/07/21 08:25:05 andreas
510 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
511 ** with one unique boolean type OFBool.
512 **
513 ** Revision 1.9 1997/05/16 08:31:19 andreas
514 ** - Revised handling of GroupLength elements and support of
515 ** DataSetTrailingPadding elements. The enumeratio E_GrpLenEncoding
516 ** got additional enumeration values (for a description see dctypes.h).
517 ** addGroupLength and removeGroupLength methods are replaced by
518 ** computeGroupLengthAndPadding. To support Padding, the parameters of
519 ** element and sequence write functions changed.
520 **
521 ** Revision 1.8 1997/04/18 08:13:28 andreas
522 ** - The put/get-methods for all VRs did not conform to the C++-Standard
523 ** draft. Some Compilers (e.g. SUN-C++ Compiler, Metroworks
524 ** CodeWarrier, etc.) create many warnings concerning the hiding of
525 ** overloaded get methods in all derived classes of DcmElement.
526 ** So the interface of all value representation classes in the
527 ** library are changed rapidly, e.g.
528 ** OFCondition get(Uint16 & value, const unsigned long pos);
529 ** becomes
530 ** OFCondition getUint16(Uint16 & value, const unsigned long pos);
531 ** All (retired) "returntype get(...)" methods are deleted.
532 ** For more information see dcmdata/include/dcelem.h
533 **
534 ** Revision 1.7 1996/08/05 08:45:15 andreas
535 ** new print routine with additional parameters:
536 ** - print into files
537 ** - fix output length for elements
538 ** corrected error in search routine with parameter ESM_fromStackTop
539 **
540 ** Revision 1.6 1996/03/12 15:26:52 hewett
541 ** Removed get method for unsigned char*
542 **
543 ** Revision 1.5 1996/01/29 13:38:11 andreas
544 ** - new put method for every VR to put value as a string
545 ** - better and unique print methods
546 **
547 ** Revision 1.4 1996/01/09 11:06:13 andreas
548 ** New Support for Visual C++
549 ** Correct problems with inconsistent const declarations
550 **
551 ** Revision 1.3 1996/01/05 13:22:52 andreas
552 ** - changed to support new streaming facilities
553 ** - more cleanups
554 ** - merged read / write methods for block and file transfer
555 **
556 */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2