LEADTOOLS DICOM C++ Class Library Help > Classes and Member Functions > LDicomDS > LDicomDS Class Members > LDicomDS::SetCharValue |
#include "Ltdic.h"
L_BOOL LDicomDS::SetCharValue(pElement, pValue, nCount)
pDICOMELEMENT pElement; |
/* pointer to a DICOMELEMENT structure */ |
L_UCHAR * pValue; |
/* pointer to a character */ |
L_UINT32 nCount; |
/* number of values to set */ |
Sets the character value(s) of a Data Element.
Parameter |
Description |
pElement |
Pointer to a DICOMELEMENT structure within the Data Set. |
pValue |
Pointer to a character or character string that contains the character value(s) to set. If you want to set multiple values in the Value Field, put all character values in this string and set nCount to the appropriate number of values. |
nCount |
Value that indicates the number of values to set in the Value Field. If you want to set multiple values in the Value Field, put all the character values in pValue and set nCount to the appropriate number. |
Returns
TRUE |
The character value(s) were set successfully. |
FALSE |
Could not set the character value(s) of the Data Element. |
Comments
Note: You must allocate the memory for pValue.
If you want to set more than one value in the Value Field of the Data Element, put all the character values in pValue and set nCount to the corresponding number of entries. For example, if you wish to set three character values in the Value Field of the Data Element, put all three characters in pValue and set nCount to three.
If more than one value is stored in the Value Field of the Data Element, you must set all values at the same time.
A character has a standard size of one byte. When multiple characters are in pValue, the first byte of data is the first character, the second byte of data is the second character, etc. Therefore no delimiters are needed.
This function can be called only if the Value Representation of the Data Element is VR_OB, VR_SQ, or VR_UN. For more information about Value Representations, refer to Default Value Representation Table.
Required DLLs and Libraries
LTDIC For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
Win32, x64
See Also
Example
This example sets the value for an element.
L_VOID SetValue(LDicomDS *pDS, pDICOMELEMENT pElement, L_VOID *pValue, L_UINT32 nCount) { switch (pElement->nVR) { case VR_OB: // Other Byte String case VR_UN: // Unknown pDS->SetCharValue(pElement, (L_UCHAR *)pValue, nCount); break; case VR_SS: // Signed Short case VR_US: // Unsigned Short case VR_OW: // Other Word String pDS->SetShortValue(pElement, (L_INT16 *)pValue, nCount); break; case VR_SL: // Signed Long case VR_IS: // Integer String case VR_UL: // Unsigned Long case VR_AT: // Attribute Tag pDS->SetLongValue(pElement, (L_INT32 *)pValue, nCount); break; case VR_FL: // Floating Point Single pDS->SetFloatValue(pElement, (L_FLOAT *)pValue, nCount); break; case VR_FD: // Floating Point Double case VR_DS: // Decimal String pDS->SetDoubleValue(pElement, (L_DOUBLE *)pValue, nCount); break; case VR_CS: // Code String case VR_SH: // Short String case VR_LO: // Long String case VR_AE: // Application Entity case VR_LT: // Long Text case VR_ST: // Short Text case VR_UI: // Unique Identifier case VR_UT: // Unlimited Text case VR_PN: // Person Name pDS->SetStringValue(pElement, (L_TCHAR *)pValue, nCount, DICOM_CHARACTER_SET_DEFAULT); break; case VR_AS: // Age String pDS->SetAgeValue(pElement, (pVALUEAGE)pValue, nCount); break; case VR_DA: // Date pDS->SetDateValue(pElement, (pVALUEDATE)pValue, nCount); break; case VR_TM: // Time pDS->SetTimeValue(pElement, (pVALUETIME)pValue, nCount); break; case VR_DT: // Date Time pDS->SetDateTimeValue(pElement, (pVALUEDATETIME)pValue, nCount); break; } } L_INT LDicomDS_SetCharValueExample() { LDicomDS *pDS; pDICOMELEMENT pElement; pDS = new LDicomDS(NULL); pDS->InitDS( CLASS_CR_IMAGE_STORAGE, 0); pElement = pDS->FindFirstElement(NULL, TAG_IMAGE_TYPE, FALSE); if (pElement != NULL) { SetValue(pDS, pElement, TEXT("ORIGINAL\0PRIMARY"), 2); } delete pDS; return DICOM_SUCCESS; }