Skip to content

Commit 777a08c

Browse files
gsoap generate eml23__PositiveLongand eml23__NonNegativeLong as uint64_t
Also fix some conversion warnings
1 parent f68f216 commit 777a08c

25 files changed

Lines changed: 1529 additions & 1551 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ set (FESAPI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1212

1313
# version mechanism
1414
set (Fesapi_VERSION_MAJOR 2)
15-
set (Fesapi_VERSION_MINOR 14)
16-
set (Fesapi_VERSION_PATCH 1)
15+
set (Fesapi_VERSION_MINOR 15)
16+
set (Fesapi_VERSION_PATCH 0)
1717
set (Fesapi_VERSION_TWEAK 0)
1818

1919
set (Fesapi_VERSION ${Fesapi_VERSION_MAJOR}.${Fesapi_VERSION_MINOR}.${Fesapi_VERSION_PATCH}.${Fesapi_VERSION_TWEAK})

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ list(APPEND ALL_SOURCES_AND_HEADERS
191191
)
192192

193193
target_sources(${CPP_LIBRARY_NAME} PRIVATE ${ALL_SOURCES_AND_HEADERS})
194+
# Disable warnings on gsoap which we do not control
195+
if (WIN32)
196+
set_source_files_properties(${FESAPI_PROXIES_SOURCES} PROPERTIES COMPILE_OPTIONS "/W0")
197+
else()
198+
set_source_files_properties(${FESAPI_PROXIES_SOURCES} PROPERTIES COMPILE_OPTIONS "-w")
199+
endif()
194200

195201
target_include_directories(${CPP_LIBRARY_NAME} SYSTEM PRIVATE ${MINIZIP_INCLUDE_DIR})
196202

src/common/AbstractObject.cpp

Lines changed: 45 additions & 36 deletions
Large diffs are not rendered by default.

src/common/AbstractObject.h

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace COMMON_NS
411411
*
412412
* @returns The gSOAP type.
413413
*/
414-
int getGsoapType() const;
414+
long getGsoapType() const;
415415

416416
/**
417417
* Creates an returns an EML2.0 data object reference which targets this data object
@@ -831,11 +831,13 @@ namespace COMMON_NS
831831
throw std::underflow_error("Cannot deal with negative values when using unsigned integer");
832832
}
833833
}
834-
if (rangeArray->Value + rangeArray->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
835-
throw std::overflow_error("The range integer values are superior to maximum value of read datatype.");
834+
if (rangeArray->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
835+
throw std::overflow_error("Please use a larger integer type");
836836
}
837-
for (T i = 0; i < static_cast<T>(rangeArray->Count); ++i) {
838-
arrayOutput[i] = i + static_cast<T>(rangeArray->Value);
837+
const T initialValue = static_cast<T>(rangeArray->Value);
838+
const T count = static_cast<T>(rangeArray->Count);
839+
for (T i = 0; i < count; ++i) {
840+
arrayOutput[i] = i + initialValue;
839841
}
840842
return (std::numeric_limits<T>::max)();
841843
}
@@ -871,22 +873,27 @@ namespace COMMON_NS
871873
if (latticeArray->StartValue < (std::numeric_limits<T>::min)() || latticeArray->Offset[0]->Value < (std::numeric_limits<T>::min)()) {
872874
throw std::underflow_error("Too low integers in XML for the C++ chosen datatype");
873875
}
874-
if (latticeArray->StartValue > (std::numeric_limits<T>::max)() ||
875-
latticeArray->Offset[0]->Value > (std::numeric_limits<T>::max)()) {
876+
if (latticeArray->StartValue > static_cast<int64_t>((std::numeric_limits<T>::max)()) ||
877+
latticeArray->Offset[0]->Value > static_cast<int64_t>((std::numeric_limits<T>::max)()) ||
878+
latticeArray->Offset[0]->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
876879
throw std::overflow_error("Too big integers in XML for the C++ chosen datatype");
877880
}
878881
}
879882
else {
880883
if (latticeArray->StartValue < 0 || latticeArray->Offset[0]->Value < 0) {
881884
throw std::underflow_error("Cannot deal with negative values when using unsigned integer");
882885
}
883-
if (static_cast<uint64_t>(latticeArray->StartValue) > (std::numeric_limits<T>::max)() ||
884-
static_cast<uint64_t>(latticeArray->Offset[0]->Value) > (std::numeric_limits<T>::max)()) {
886+
if (static_cast<uint64_t>(latticeArray->StartValue) > static_cast<uint64_t>((std::numeric_limits<T>::max)()) ||
887+
static_cast<uint64_t>(latticeArray->Offset[0]->Value) > static_cast<uint64_t>((std::numeric_limits<T>::max)()) ||
888+
latticeArray->Offset[0]->Count > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
885889
throw std::overflow_error("Too big integers in XML for the C++ chosen datatype");
886890
}
887891
}
888-
for (uint64_t i = 0; i <= latticeArray->Offset[0]->Count; ++i) {
889-
arrayOutput[i] = static_cast<T>(latticeArray->StartValue) + (i * static_cast<T>(latticeArray->Offset[0]->Value));
892+
const T start = static_cast<T>(latticeArray->StartValue);
893+
const T step = static_cast<T>(latticeArray->Offset[0]->Value);
894+
const T count = static_cast<T>(latticeArray->Offset[0]->Count);
895+
for (T i = 0; i <= count; ++i) {
896+
arrayOutput[i] = static_cast<T>(start + i * step);
890897
}
891898
return (std::numeric_limits<T>::max)();
892899
}
@@ -932,12 +939,12 @@ namespace COMMON_NS
932939
if (latticeArray->Offset.empty() || latticeArray->Offset.size() > 1) {
933940
throw std::invalid_argument("The integer lattice array of UUID " + getUuid() + " contains zero or more than one offset.");
934941
}
935-
if (latticeArray->Offset[0]->Count < 0) {
936-
throw std::invalid_argument("The count of the integer lattice array of UUID " + getUuid() + " is negative which is not valid.");
937-
}
938942

939-
for (size_t i = 0; i <= static_cast<size_t>(latticeArray->Offset[0]->Count); ++i) {
940-
arrayOutput[i] = latticeArray->StartValue + (i * latticeArray->Offset[0]->Value);
943+
const T start = static_cast<T>(latticeArray->StartValue);
944+
const T step = static_cast<T>(latticeArray->Offset[0]->Value);
945+
const T count = static_cast<T>(latticeArray->Offset[0]->Count);
946+
for (T i = 0; i <= count; ++i) {
947+
arrayOutput[i] = static_cast<T>(start + i * step);
941948
}
942949
return (std::numeric_limits<T>::max)();
943950
}
@@ -949,7 +956,7 @@ namespace COMMON_NS
949956
std::sregex_token_iterator endToken;
950957
size_t index = 0;
951958
while (it != endToken) {
952-
arrayOutput[index++] = std::stoll(*it++);
959+
arrayOutput[index++] = static_cast<T>(std::stoll(*it++));
953960
}
954961
return (std::numeric_limits<T>::max)();
955962
}
@@ -1076,7 +1083,7 @@ namespace COMMON_NS
10761083
/**
10771084
* Create an external data array part pointing to a named dataset in an HDF proxy
10781085
*/
1079-
gsoap_eml2_3::eml23__ExternalDataArrayPart* createExternalDataArrayPart(const std::string& datasetName, LONG64 count, EML2_NS::AbstractHdfProxy* proxy = nullptr) const;
1086+
gsoap_eml2_3::eml23__ExternalDataArrayPart* createExternalDataArrayPart(const std::string& datasetName, uint64_t count, EML2_NS::AbstractHdfProxy* proxy = nullptr) const;
10801087

10811088
gsoap_resqml2_0_1::resqml20__IndexableElements mapIndexableElement(gsoap_eml2_3::eml23__IndexableElement toMap) const;
10821089

src/common/DataObjectRepository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ RESQML2_NS::SeismicLatticeFeature* DataObjectRepository::createSeismicLattice(co
14761476
}
14771477

14781478
RESQML2_0_1_NS::SeismicLineFeature* DataObjectRepository::createSeismicLine(const std::string & guid, const std::string & title,
1479-
int traceIndexIncrement, unsigned int firstTraceIndex, unsigned int traceCount)
1479+
int traceIndexIncrement, int firstTraceIndex, unsigned int traceCount)
14801480
{
14811481
return new RESQML2_0_1_NS::SeismicLineFeature(this, guid, title, traceIndexIncrement, firstTraceIndex, traceCount);
14821482
}

src/common/DataObjectRepository.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,14 +1246,17 @@ namespace COMMON_NS
12461246
* will be generated.
12471247
* @param title The title to set to the seismic line. If empty then \"unknown\"
12481248
* title will be set.
1249-
* @param traceIndexIncrement The constant index increment between two consecutive traces.
1250-
* @param firstTraceIndex The index of the first trace of the seismic line.
1251-
* @param traceCount Number of traces.
1249+
* @param traceIndexIncrement The trace index increment. The trace index increment will
1250+
* be the difference in the trace number from abscissa i=0
1251+
* and abscissa i=1. The increment can be a positive or
1252+
* negative integer, but not zero.
1253+
* @param firstTraceIndex The index of the first trace beginning at abscissa i=0.
1254+
* @param traceCount The count of traces in this seismic line.
12521255
*
12531256
* @returns A pointer to the new seismic line.
12541257
*/
12551258
DLL_IMPORT_OR_EXPORT RESQML2_0_1_NS::SeismicLineFeature* createSeismicLine(const std::string & guid, const std::string & title,
1256-
int traceIndexIncrement, unsigned int firstTraceIndex, unsigned int traceCount);
1259+
int traceIndexIncrement, int firstTraceIndex, unsigned int traceCount);
12571260

12581261
/**
12591262
* @brief Creates a CMP line into this repository

src/common/NumberArrayStatistics.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,20 @@ namespace COMMON_NS
129129
}
130130

131131
//mean
132-
valuesMean[j] += (pair.second * pair.first) / validValueCount[j];
132+
valuesMean[j] += (static_cast<double>(pair.second) * static_cast<double>(pair.first)) / static_cast<double>(validValueCount[j]);
133+
133134
}
134-
valuesMedian[j] = (validValueCount[j] % 2 == 0) ? (median1 + median2) / 2.0 : median2;
135-
modePercentage[j] = static_cast<double>(maxCount) / validValueCount[j];
135+
valuesMedian[j] = (validValueCount[j] % 2 == 0) ? (static_cast<double>(median1) + static_cast<double>(median2)) / 2.0 : static_cast<double>(median2);
136+
modePercentage[j] = static_cast<double>(maxCount) / static_cast<double>(validValueCount[j]);
136137

137138

138139
// Standard Deviation
139140
double variance = 0.0;
140141
for (const auto& pair : mapView) {
141142
double diff = static_cast<double>(pair.first) - valuesMean[j];
142-
variance += pair.second * diff * diff;
143+
variance += static_cast<double>(pair.second) * diff * diff;
143144
}
144-
valuesStandardDeviation[j] = std::sqrt(variance / validValueCount[j]);
145+
valuesStandardDeviation[j] = std::sqrt(variance / static_cast<double>(validValueCount[j]));
145146
}
146147
}
147148

src/epc/FilePart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const FileRelationship & FilePart::getFileRelationship() const
5353
return fileRelationship;
5454
}
5555

56-
Relationship FilePart::getIndexRelationship(int index) const
56+
Relationship FilePart::getIndexRelationship(size_t index) const
5757
{
5858
return fileRelationship.getIndexRelationship(index);
5959
}

src/epc/FilePart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace epc
6262
*
6363
* @returns The index relationship.
6464
*/
65-
Relationship getIndexRelationship(int index) const;
65+
Relationship getIndexRelationship(size_t index) const;
6666

6767
/**
6868
* Copy an existing relationship into the relationship set of the part.

src/epc/Package.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ const FilePart* Package::findPart(const std::string & outputPartPath) const
378378
return it == d_ptr->allFileParts.end() ? nullptr : &(it->second);
379379
}
380380

381-
382381
#ifdef _WIN32
383382
void buildTimeInfo(const char *filename, uLong *dostime)
384383
{
@@ -409,12 +408,12 @@ void buildTimeInfo(tm_zip *tmzip)
409408
time_t tm_t = time(0);
410409
filedate = localtime(&tm_t);
411410

412-
tmzip->tm_sec = filedate->tm_sec;
413-
tmzip->tm_min = filedate->tm_min;
414-
tmzip->tm_hour = filedate->tm_hour;
415-
tmzip->tm_mday = filedate->tm_mday;
416-
tmzip->tm_mon = filedate->tm_mon ;
417-
tmzip->tm_year = filedate->tm_year;
411+
tmzip->tm_sec = static_cast<uInt>(filedate->tm_sec);
412+
tmzip->tm_min = static_cast<uInt>(filedate->tm_min);
413+
tmzip->tm_hour = static_cast<uInt>(filedate->tm_hour);
414+
tmzip->tm_mday = static_cast<uInt>(filedate->tm_mday);
415+
tmzip->tm_mon = static_cast<uInt>(filedate->tm_mon);
416+
tmzip->tm_year = static_cast<uInt>(filedate->tm_year);
418417
}
419418
#endif
420419

0 commit comments

Comments
 (0)