Salome HOME
updated copyright message
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeStudyProperties.cxx
index ce9193631f86600cf2ed6a9e3017d0b587a4a145..a86ab765af529ad2c6e210457cafa2555cebe4ea 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,6 +26,7 @@
 //
 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
 #include <string.h>
+#include <stdlib.h>
 
 const std::string& SALOMEDSImpl_AttributeStudyProperties::GetID()
 {
@@ -48,6 +49,7 @@ SALOMEDSImpl_AttributeStudyProperties::SALOMEDSImpl_AttributeStudyProperties()
 {
   myLocked = false;
   myLockChanged = false;
+  myModified = false;
   Init();
 }
 
@@ -64,11 +66,11 @@ void SALOMEDSImpl_AttributeStudyProperties::Init()
 }
 
 void SALOMEDSImpl_AttributeStudyProperties::SetModification(const std::string& theUserName,
-                                                            const int            theMinute,
-                                                            const int            theHour,
-                                                            const int            theDay,
-                                                            const int            theMonth,
-                                                            const int            theYear)
+                                                            const int          theMinute,
+                                                            const int          theHour,
+                                                            const int          theDay,
+                                                            const int          theMonth,
+                                                            const int          theYear)
 {
   if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 ||
       theDay<0 || theDay>31 || theMonth<0 || theMonth>12)
@@ -196,7 +198,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Restore(DF_Attribute* with)
   std::vector<std::string> aNames;
   std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
   aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
-  for (int i = 0, len = aNames.size(); i < len; i++) {
+  for (size_t i = 0, len = aNames.size(); i < len; i++) {
     myUserName.push_back(aNames[i]);
     myMinute.push_back(aMinutes[i]);
     myHour.push_back(aHours[i]);
@@ -222,7 +224,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Paste(DF_Attribute* into)
   aProp->Init();
 
   int i;
-  for(i = 0; i < myUserName.size(); i++) {
+  for(i = 0; i < (int)myUserName.size(); i++) {  //TODO: mismatch signed/unsigned
     aProp->SetModification(myUserName[i],
                            myMinute[i], myHour[i],
                            myDay[i], myMonth[i], myYear[i]);
@@ -248,7 +250,7 @@ std::string SALOMEDSImpl_AttributeStudyProperties::Save()
   std::string units = GetUnits();
   std::string comment = GetComment();
 
-  int aLength1 = 0;
+  size_t aLength1 = 0;
   std::map<std::string, std::string> versions;
   versionMap::const_iterator it;
   for (aLength1 = 0, it = myComponentVersions.begin(); it != myComponentVersions.end(); ++it ) {
@@ -282,35 +284,35 @@ std::string SALOMEDSImpl_AttributeStudyProperties::Save()
             (int)(aMonths[anIndex]),
             (int)(aYears[anIndex]),
             (char*)(aNames[anIndex].c_str()));
-    a = strlen(aProperty);
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
     aProperty[a++] = 1;
   }
 
-  //Write delimeter of the section to define end of the modifications section
+  //Write delimiter of the section to define end of the modifications section
   aProperty[a++] = 30;
 
   //Write units if need
   if(units.size() > 0) {
     sprintf(&(aProperty[a]),"%s",units.c_str());
-    a = strlen(aProperty);
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
   }
 
-  aProperty[a++] = 1; //delimeter of the units and comments
+  aProperty[a++] = 1; //delimiter of the units and comments
 
   //Write comments if need
   if(comment.size() > 0) {
     sprintf(&(aProperty[a]),"%s",comment.c_str());
-    a = strlen(aProperty);
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
   }
   
-  aProperty[a++] = 30; //delimeter of the component versions
+  aProperty[a++] = 30; //delimiter of the component versions
 
   std::map<std::string, std::string>::const_iterator versionsIt;
   for ( versionsIt = versions.begin(); versionsIt != versions.end(); ++versionsIt ) {
     sprintf(&(aProperty[a]),"%s=%s",
             (char*)(versionsIt->first.c_str()),
-           (char*)(versionsIt->second.c_str()));
-    a = strlen(aProperty);
+            (char*)(versionsIt->second.c_str()));
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
     aProperty[a++] = 1;
   }
 
@@ -414,7 +416,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value)
   // - yyyy: year   = 4 bytes
   // - name: user's name = arbitrary value, minimal length is 0 bytes
   // - 1   : records delimiter = 1 byte  
-  for (anIndex = 2; anIndex + 13 < value.size() ;) {
+  for (anIndex = 2; anIndex + 13 < (int)value.size() ;) {  //TODO: mismatch signed/unsigned
     char str[10];
     int aMinute, aHour, aDay, aMonth, aYear;
     str[0] = aCopy[anIndex++];
@@ -447,13 +449,13 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value)
     anIndex += aNameSize + 1;
     
     //Check end of the modifications section
-    if(anIndex < value.size() && aCopy[anIndex] == 30)
+    if(anIndex < (int)value.size() && aCopy[anIndex] == 30) //TODO: mismatch signed/unsigned
       break;
   }
   
   //Case when study contains units and comment properties
-  if( anIndex < value.size() ) {
-    anIndex++; //skip the delimeter of the sections: char(30)
+  if( anIndex < (int)value.size() ) {   //TODO: mismatch signed/unsigned
+    anIndex++; //skip the delimiter of the sections: char(30)
     int unitsSize;
     for(unitsSize = 0; aCopy[anIndex+unitsSize] != 1; unitsSize++);
 
@@ -480,34 +482,34 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value)
   }
 
   //Case when study contains components versions
-  if( anIndex < value.size() ) {
-    while ( anIndex < value.size() && aCopy[anIndex] != 0 ) {
+  if( anIndex < (int)value.size() ) { //TODO: mismatch signed/unsigned
+    while ( anIndex < (int)value.size() && aCopy[anIndex] != 0 ) { //TODO: mismatch signed/unsigned
       int modSize;
       for(modSize = 0; aCopy[anIndex+modSize] != '='; modSize++);
       int verSize;
       for(verSize = 0; aCopy[anIndex+modSize+1+verSize] != 1; verSize++);
 
       if(modSize > 0) {
-       char *aModule = new char[modSize+1];
-       strncpy(aModule, &(aCopy[anIndex]), modSize);
-       aModule[modSize] = 0;
-       char *aVersions = new char[verSize+1];
-       if ( verSize > 0 )
-         strncpy(aVersions, &(aCopy[anIndex+modSize+1]), verSize);
-       aVersions[verSize] = 0;
-       
-       std::string mVersions = aVersions;
-       int start = 0, idx = mVersions.find( ';', start );
-       while ( idx != std::string::npos ) {
-         SetComponentVersion( aModule, mVersions.substr( start, idx-start ) );
-         start = idx + 1;
-         idx = mVersions.find( ';', start );
-       }
-       SetComponentVersion( aModule, mVersions.substr( start ) );
-
-       delete [] (aModule);
-       delete [] (aVersions);
-       anIndex += modSize + 1 + verSize + 1;
+        char *aModule = new char[modSize+1];
+        strncpy(aModule, &(aCopy[anIndex]), modSize);
+        aModule[modSize] = 0;
+        char *aVersions = new char[verSize+1];
+        if ( verSize > 0 )
+          strncpy(aVersions, &(aCopy[anIndex+modSize+1]), verSize);
+        aVersions[verSize] = 0;
+        
+        std::string mVersions = aVersions;
+        size_t start = 0, idx = mVersions.find( ';', start );
+        while ( idx != std::string::npos ) {
+          SetComponentVersion( aModule, mVersions.substr( start, idx-start ) );
+          start = idx + 1;
+          idx = mVersions.find( ';', start );
+        }
+        SetComponentVersion( aModule, mVersions.substr( start ) );
+
+        delete [] (aModule);
+        delete [] (aVersions);
+        anIndex += modSize + 1 + verSize + 1;
       }
     }
   }