- guint16 g, n;
- gdcmValEntry *newValEntry = (gdcmValEntry *)0;
- gdcmBinEntry *newBinEntry = (gdcmBinEntry *)0;
- gdcmSeqEntry *newSeqEntry = (gdcmSeqEntry *)0;
- gdcmDictEntry *NewTag = (gdcmDictEntry *)0;
- char VR[3];
- long PositionOnEntry;
-
-// while ( (newHeaderEntry = ReadNextHeaderEntry()) ) {
- while (1) {
-
- // ----------------------- was ReadNextHeaderEntry -----------------
- g = ReadInt16();
- n = ReadInt16();
- if (errno == 1)
- // We reached the EOF (or an error occured) therefore
- // header parsing has to be considered as finished.
- break;
-
- // Find out if the tag we encountered is in the dictionaries:
- DictEntry = GetDictEntryByNumber(Group, Elem);
- if (!DictEntry)
- DictEntry = NewVirtualDictEntry(Group, Elem);
- if (!DictEntry) {
- dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
- "failed to allocate gdcmDictEntry");
- return false;
- }
-
- // Right now,
- vr = DictEntry->GetVR(); // Suppose we get it, suppose it's the same one
- // that's in the Explicit VR part of the Header
- // TODO
- // Resoudre pb quand inadequation entre Explicit VR et Dict
-
- if (filetype != ExplicitVR) {} // jamais de risque de conflit
- // pour les autres cas,
- // refaire l'equiv de gdcmParser::FindHeaderEntryVR
- // qui contient CheckHeaderEntryVR
- // le pb, c'est qu'on a besoin de la VR pour fabriquer l'Entry
-
- if (vr == "SQ" ) {
- // --- SeqEntry
- // TODO
- // SEQUENCE; appel 'récursif' de ??? pour charger la 'valeur'
- // (ensemble d' ITEMs, en fait,
- // chaque ITEM etant chargé avec LoadDocEntrySet)
-
-
- } else if (vr == "AE" || vr == "AS" || vr == "DA" || vr == "PN" ||
- vr == "UI" || vr == "TM" ) {
- // --- ValEntry
- NewValEntry = new gdcmValEntry(DictEntry);
- if (!NewValEntry) {
- dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
- "failed to allocate gdcmValEntry");
- return false;
+/**
+ * \brief Accesses an existing DocEntry (i.e. a Dicom Element)
+ * and modifies its content with the given value.
+ * @param content new value (string) to substitute with
+ * @param entry Entry to be modified
+ */
+bool DocEntrySet::SetEntryString(std::string const &content, DataEntry *entry)
+{
+ if (entry)
+ {
+ entry->SetString(content);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * \brief Accesses an existing DataEntry (i.e. a Dicom Element)
+ * and modifies its content with the given value.
+ * @param content new value (void* -> uint8_t*) to substitute with
+ * @param entry Entry to be modified
+ * @param lgth new value length
+ */
+bool DocEntrySet::SetEntryBinArea(uint8_t *content, int lgth, DataEntry *entry)
+{
+ if (entry)
+ {
+ entry->SetLength(lgth);
+ entry->SetBinArea(content);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * \brief Modifies the value of a given Doc Entry (Dicom Element)
+ * when it exists. Creates it with the given value when unexistant.
+ * @param value (string) Value to be set
+ * @param group Group number of the Entry
+ * @param elem Element number of the Entry
+ * @param vr V(alue) R(epresentation) of the Entry -if private Entry-
+ * \return pointer to the modified/created Header Entry (NULL when creation
+ * failed).
+ */
+DataEntry *DocEntrySet::InsertEntryString(std::string const &value,
+ uint16_t group, uint16_t elem,
+ VRKey const &vr )
+{
+ DataEntry *dataEntry = 0;
+ DocEntry *currentEntry = GetDocEntry( group, elem );
+ VRKey localVR = vr;
+ if (currentEntry)
+ {
+ dataEntry = dynamic_cast<DataEntry *>(currentEntry);
+
+ // Verify the VR
+ if ( dataEntry )
+ if ( dataEntry->GetVR()!=vr )
+ dataEntry = NULL;
+
+ // if currentEntry doesn't correspond to the requested dataEntry
+ if ( !dataEntry)
+ {
+ if ( !RemoveEntry(currentEntry) )
+ {
+ gdcmWarningMacro( "Removal of previous DocEntry failed.");
+ return NULL;