Skip to content

Commit dc6dff7

Browse files
Use more often uint64_t instead of uint32_t to better conform to XML
SWIG port RepresentationSetRepresentation::pushBack(RESQML2_NS::AbstractRepresentation* rep)
1 parent 48f1cea commit dc6dff7

47 files changed

Lines changed: 878 additions & 357 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/common/DataObjectRepository.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,11 @@ namespace COMMON_NS
558558
*/
559559
#define GETTER_DATAOBJECTS(returnedDataType, dataObjectName)\
560560
DLL_IMPORT_OR_EXPORT std::vector<returnedDataType*> get##dataObjectName##Set() const;\
561-
DLL_IMPORT_OR_EXPORT unsigned int get##dataObjectName##Count() const {\
562-
const size_t result = get##dataObjectName##Set().size();\
563-
if (result > (std::numeric_limits<unsigned int>::max)()) { throw std::range_error("The count is superior to unsigned int max"); }\
564-
return static_cast<unsigned int>(result);\
561+
DLL_IMPORT_OR_EXPORT uint64_t get##dataObjectName##Count() const {\
562+
return get##dataObjectName##Set().size();\
565563
}\
566-
DLL_IMPORT_OR_EXPORT returnedDataType* get##dataObjectName(unsigned int index) const {\
567-
std::vector<returnedDataType*> all = get##dataObjectName##Set();\
568-
if (index >= all.size()) { throw std::out_of_range("The index is out of range"); }\
569-
return all[index];\
564+
DLL_IMPORT_OR_EXPORT returnedDataType* get##dataObjectName(uint64_t index) const {\
565+
return get##dataObjectName##Set().at(index);\
570566
}
571567

572568
GETTER_DATAOBJECTS(EML2_NS::AbstractHdfProxy, HdfProxy)

src/eml2_3/Activity.cpp

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ void Activity::pushBackParameter(const std::string& title, double value, gsoap_r
5353
if (maxOccurs > -1 && static_cast<uint64_t>(maxOccurs) <= getParameterCount(title)) {
5454
throw invalid_argument("The max number of occurrences has already been reached for parameter " + title);
5555
}
56-
if (dynamic_cast<EML2_NS::ActivityTemplate*>(activityTemplate) != nullptr) {
57-
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = static_cast<EML2_NS::ActivityTemplate*>(activityTemplate)->getParameterAllowedKinds(title);
58-
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::floatingPoint) == allowedKinds.end())
59-
throw invalid_argument("The parameter template " + title + " does not allow a double datatype.");
60-
}
56+
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = activityTemplate->getParameterAllowedKinds(title);
57+
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::floatingPoint) == allowedKinds.end())
58+
throw invalid_argument("The parameter template " + title + " does not allow a double datatype.");
6159
}
6260

6361
_eml23__Activity* activity = static_cast<_eml23__Activity*>(gsoapProxy2_3);
@@ -80,11 +78,9 @@ void Activity::pushBackParameter(const std::string& title, const std::string & v
8078
if (maxOccurs > -1 && static_cast<uint64_t>(maxOccurs) <= getParameterCount(title)) {
8179
throw invalid_argument("The max number of occurrences has already been reached for parameter " + title);
8280
}
83-
if (dynamic_cast<EML2_NS::ActivityTemplate*>(activityTemplate) != nullptr) {
84-
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = static_cast<EML2_NS::ActivityTemplate*>(activityTemplate)->getParameterAllowedKinds(title);
85-
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::string) == allowedKinds.end())
86-
throw invalid_argument("The parameter template " + title + " does not allow a string datatype.");
87-
}
81+
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = activityTemplate->getParameterAllowedKinds(title);
82+
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::string) == allowedKinds.end())
83+
throw invalid_argument("The parameter template " + title + " does not allow a string datatype.");
8884
}
8985

9086
_eml23__Activity* activity = static_cast<_eml23__Activity*>(gsoapProxy2_3);
@@ -106,11 +102,9 @@ void Activity::pushBackParameter(const std::string& title, int64_t value)
106102
if (maxOccurs > -1 && static_cast<uint64_t>(maxOccurs) <= getParameterCount(title)) {
107103
throw invalid_argument("The max number of occurrences has already been reached for parameter " + title);
108104
}
109-
if (dynamic_cast<EML2_NS::ActivityTemplate*>(activityTemplate) != nullptr) {
110-
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = static_cast<EML2_NS::ActivityTemplate*>(activityTemplate)->getParameterAllowedKinds(title);
111-
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::integer) == allowedKinds.end())
112-
throw invalid_argument("The parameter template " + title + " does not allow an integer datatype.");
113-
}
105+
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = activityTemplate->getParameterAllowedKinds(title);
106+
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::integer) == allowedKinds.end())
107+
throw invalid_argument("The parameter template " + title + " does not allow an integer datatype.");
114108
}
115109

116110
_eml23__Activity* activity = static_cast<_eml23__Activity*>(gsoapProxy2_3);
@@ -134,11 +128,9 @@ void Activity::pushBackParameter(const std::string& title, AbstractObject* resqm
134128
int64_t maxOccurs = activityTemplate->getParameterMaxOccurences(title);
135129
if (maxOccurs > -1 && static_cast<uint64_t>(maxOccurs) <= getParameterCount(title))
136130
throw invalid_argument("The max number of occurrences has already been reached for parameter " + title);
137-
if (dynamic_cast<EML2_NS::ActivityTemplate*>(activityTemplate) != nullptr) {
138-
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = static_cast<EML2_NS::ActivityTemplate*>(activityTemplate)->getParameterAllowedKinds(title);
139-
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::dataObject) == allowedKinds.end())
140-
throw invalid_argument("The parameter template " + title + " does not allow a data object datatype.");
141-
}
131+
vector<gsoap_resqml2_0_1::resqml20__ParameterKind> allowedKinds = activityTemplate->getParameterAllowedKinds(title);
132+
if (allowedKinds.size() > 0 && find(allowedKinds.begin(), allowedKinds.end(), gsoap_resqml2_0_1::resqml20__ParameterKind::dataObject) == allowedKinds.end())
133+
throw invalid_argument("The parameter template " + title + " does not allow a data object datatype.");
142134
}
143135

144136
getRepository()->addRelationship(this, resqmlObject);
@@ -260,7 +252,7 @@ vector<gsoap_resqml2_0_1::resqml20__ResqmlUom> Activity::getFloatingPointQuantit
260252
throw range_error("The parameter " + paramTitle + " is not in the parameter range.");
261253

262254
vector<gsoap_resqml2_0_1::resqml20__ResqmlUom> result;
263-
for (unsigned int i = 0; i < param.size(); ++i)
255+
for (size_t i = 0; i < param.size(); ++i)
264256
{
265257
if (param[i]->soap_type() != SOAP_TYPE_gsoap_eml2_3_eml23__DoubleQuantityParameter)
266258
throw invalid_argument("The parameter " + paramTitle + " contains some non double values.");
@@ -373,8 +365,9 @@ vector<string> Activity::getStringParameterValue(const std::string & paramTitle)
373365
{
374366
vector<gsoap_eml2_3::eml23__AbstractActivityParameter*> param = getParameterFromTitle(paramTitle);
375367

376-
if (param.size() < 1)
377-
invalid_argument("There exists no " + paramTitle + " parameter in this activity.");
368+
if (param.size() < 1) {
369+
throw invalid_argument("There exists no " + paramTitle + " parameter in this activity.");
370+
}
378371

379372
vector<string> result;
380373
for (size_t i = 0; i < param.size(); ++i)
@@ -412,7 +405,7 @@ bool Activity::isAResqmlObjectParameter(const std::string & paramTitle) const
412405
throw invalid_argument("There exists no " + paramTitle + " parameter in this activity.");
413406
}
414407

415-
for (unsigned int i = 0; i < param.size(); ++i) {
408+
for (size_t i = 0; i < param.size(); ++i) {
416409
if (param[i]->soap_type() != SOAP_TYPE_gsoap_eml2_3_eml23__DataObjectParameter)
417410
return false;
418411
}
@@ -422,17 +415,16 @@ bool Activity::isAResqmlObjectParameter(const std::string & paramTitle) const
422415

423416
bool Activity::isAResqmlObjectParameter(uint64_t index) const
424417
{
425-
_eml23__Activity* activity = static_cast<_eml23__Activity*>(gsoapProxy2_3);
426-
427-
return activity->Parameter.at(index)->soap_type() == SOAP_TYPE_gsoap_eml2_3_eml23__DataObjectParameter;
418+
return static_cast<_eml23__Activity*>(gsoapProxy2_3)->Parameter.at(index)->soap_type() == SOAP_TYPE_gsoap_eml2_3_eml23__DataObjectParameter;
428419
}
429420

430421
vector<COMMON_NS::AbstractObject*> Activity::getResqmlObjectParameterValue(const std::string & paramTitle) const
431422
{
432423
vector<gsoap_eml2_3::eml23__AbstractActivityParameter*> param = getParameterFromTitle(paramTitle);
433424

434-
if (param.size() < 1)
435-
invalid_argument("There exists no " + paramTitle + " parameter in this activity.");
425+
if (param.size() < 1) {
426+
throw invalid_argument("There exists no " + paramTitle + " parameter in this activity.");
427+
}
436428

437429
vector<COMMON_NS::AbstractObject*> result;
438430
for (size_t i = 0; i < param.size(); ++i)

src/eml2_3/ActivityTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void ActivityTemplate::pushBackParameter(const std::string & title,
3737
uint64_t minOccurs, int64_t maxOccurs)
3838
{
3939
// Preconditions
40-
if (maxOccurs >= 0 && minOccurs > static_cast<unsigned int>(maxOccurs)) {
40+
if (maxOccurs >= 0 && minOccurs > static_cast<uint64_t>(maxOccurs)) {
4141
throw invalid_argument("Maximum occurences of a parameter template must be at least equal to the minimum occurences of this same parameter template.");
4242
}
4343

src/epc/FileCoreProperties.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ std::string FileCoreProperties::toString() const
9191
oss << "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" << endl;
9292

9393
// content
94-
for (unsigned int i = 0; i < CoreProperty::undefinedCoreProperty; ++i) {
94+
for (size_t i = 0; i < CoreProperty::undefinedCoreProperty; ++i) {
9595
if (!properties[i].isEmpty()) {
9696
oss << "\t" << properties[i].toString() << endl;
9797
}
@@ -185,7 +185,7 @@ void FileCoreProperties::setVersion(const std::string & value)
185185

186186
void FileCoreProperties::readFromString(const string & textInput)
187187
{
188-
for (unsigned int i = 0; i < CoreProperty::undefinedCoreProperty; ++i) {
188+
for (size_t i = 0; i < CoreProperty::undefinedCoreProperty; ++i) {
189189
properties[i].setTypeProperty(CoreProperty::undefinedCoreProperty);
190190
}
191191

src/resqml2/AbstractSeismicLineFeature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ std::vector<std::string> AbstractSeismicLineFeature::getTraceLabels() const
7777
if (gsoapProxy2_0_1 != nullptr) {
7878
gsoap_resqml2_0_1::_resqml20__SeismicLineFeature* seismicLine = static_cast<gsoap_resqml2_0_1::_resqml20__SeismicLineFeature*>(gsoapProxy2_0_1);
7979
const uint64_t traceCount = seismicLine->TraceCount;
80-
if (traceCount > (std::numeric_limits<int64_t>::max)()) {
80+
if (traceCount > static_cast<uint64_t>((std::numeric_limits<int64_t>::max)())) {
8181
throw overflow_error("The trace count cannot be superior to int64 max");
8282
}
8383
for (int64_t incr = 0; incr < static_cast<int64_t>(traceCount); ++incr) {

src/resqml2/AbstractStratigraphicOrganizationInterpretation.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,14 @@ under the License.
2727
using namespace RESQML2_NS;
2828
using namespace std;
2929

30-
std::vector<AbstractGridRepresentation *> AbstractStratigraphicOrganizationInterpretation::getGridRepresentations() const
30+
std::vector<AbstractGridRepresentation*> AbstractStratigraphicOrganizationInterpretation::getGridRepresentationSet() const
3131
{
3232
return getRepository()->getSourceObjects<AbstractGridRepresentation>(this);
3333
}
3434

35-
unsigned int AbstractStratigraphicOrganizationInterpretation::getGridRepresentationCount() const
36-
{
37-
const size_t count = getGridRepresentations().size();
38-
39-
if (count > (std::numeric_limits<unsigned int>::max)()) {
40-
throw range_error("Too much associated grids");
41-
}
42-
43-
return static_cast<unsigned int>(count);
44-
}
45-
46-
AbstractGridRepresentation * AbstractStratigraphicOrganizationInterpretation::getGridRepresentation(unsigned int index) const
47-
{
48-
const std::vector<AbstractGridRepresentation *>& gridRepresentationSet = getGridRepresentations();
49-
50-
if (index >= gridRepresentationSet.size()) {
51-
throw out_of_range("The index of the grid representation to get is out of range.");
52-
}
53-
54-
return gridRepresentationSet[index];
55-
}
56-
5735
bool AbstractStratigraphicOrganizationInterpretation::isAssociatedToGridRepresentation(AbstractGridRepresentation* gridRep) const
5836
{
59-
const std::vector<AbstractGridRepresentation *>& gridRepresentationSet = getGridRepresentations();
37+
const std::vector<AbstractGridRepresentation*> gridRepresentationSet = getGridRepresentationSet();
6038

6139
return find(gridRepresentationSet.begin(), gridRepresentationSet.end(), gridRep) != gridRepresentationSet.end();
6240
}

src/resqml2/AbstractStratigraphicOrganizationInterpretation.h

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,7 @@ namespace RESQML2_NS
4242

4343
bool isStratigraphic() const final { return true; }
4444

45-
/**
46-
* Gets the grid representations associated to this stratigraphic organization interpretation.
47-
*
48-
* @returns A vector of pointers to all the grid representations associated to this stratigraphic
49-
* organization interpretation.
50-
*/
51-
DLL_IMPORT_OR_EXPORT std::vector<AbstractGridRepresentation*> getGridRepresentations() const;
52-
53-
/**
54-
* Gets the count of grid representations associated to this stratigraphic organization
55-
* interpretation.
56-
*
57-
* @exception std::range_error If the count of associated grid representations is strictly
58-
* greater than <tt>unsigned int</tt> max.
59-
*
60-
* @returns The count of associated grid representations.
61-
*/
62-
DLL_IMPORT_OR_EXPORT unsigned int getGridRepresentationCount() const;
63-
64-
/**
65-
* Gets a grid representation associated to this stratigraphic organization interpretation by
66-
* means of its index.
67-
*
68-
* @exception std::out_of_range If @p index is out of range.
69-
*
70-
* @param index The index of the grid representation to get in the array of grid
71-
* representations of this stratigraphic organization interpretations.
72-
*
73-
* @returns The associated grid representation at index @p index.
74-
*/
75-
DLL_IMPORT_OR_EXPORT AbstractGridRepresentation * getGridRepresentation(unsigned int index) const;
45+
GETTER_DATAOBJECTS(AbstractGridRepresentation, GridRepresentation)
7646

7747
/**
7848
* Checks whether a given grid representation is associated to this stratigraphic organization

src/resqml2/AbstractSurfaceRepresentation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ void AbstractSurfaceRepresentation::loadTargetRelationships()
2727
{
2828
AbstractRepresentation::loadTargetRelationships();
2929

30-
for (unsigned int i = 0; i < getBoundariesCount(); ++i) {
30+
for (uint64_t i = 0; i < getBoundariesCount(); ++i) {
3131
COMMON_NS::DataObjectReference dor = getOuterRingDor(i);
3232
if (!dor.isEmpty()) {
3333
convertDorIntoRel(dor);
3434
}
3535
}
3636
}
3737

38-
unsigned int AbstractSurfaceRepresentation::getBoundariesCount() const
38+
uint64_t AbstractSurfaceRepresentation::getBoundariesCount() const
3939
{
4040
size_t result;
4141

@@ -56,7 +56,7 @@ unsigned int AbstractSurfaceRepresentation::getBoundariesCount() const
5656
return static_cast<unsigned int>(result);
5757
}
5858

59-
COMMON_NS::DataObjectReference AbstractSurfaceRepresentation::getOuterRingDor(unsigned int index) const
59+
COMMON_NS::DataObjectReference AbstractSurfaceRepresentation::getOuterRingDor(uint64_t index) const
6060
{
6161
if (index >= getBoundariesCount()) {
6262
throw std::out_of_range("The index is out of range");

src/resqml2/AbstractSurfaceRepresentation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace RESQML2_NS
4343
*
4444
* @returns The boundaries count.
4545
*/
46-
unsigned int getBoundariesCount() const;
46+
uint64_t getBoundariesCount() const;
4747

4848
/**
4949
* Gets the DOR of an outer ring at a particular index.
@@ -55,7 +55,7 @@ namespace RESQML2_NS
5555
*
5656
* @returns The DOR of the outer ring at position @p index.
5757
*/
58-
COMMON_NS::DataObjectReference getOuterRingDor(unsigned int index) const;
58+
COMMON_NS::DataObjectReference getOuterRingDor(uint64_t index) const;
5959

6060
/**
6161
* Pushes back an outer ring at the first available boundary index of this surface

src/resqml2/AbstractValuesProperty.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ namespace RESQML2_NS
18561856
if (gsoapProxy2_0_1->soap_type() == SOAP_TYPE_gsoap_resqml2_0_1_resqml20__obj_USCOREContinuousProperty) {
18571857
gsoap_resqml2_0_1::_resqml20__ContinuousProperty* prop = static_cast<gsoap_resqml2_0_1::_resqml20__ContinuousProperty*>(gsoapProxy2_0_1);
18581858
for (size_t i = 0; i < stats.getMinimumSize(); ++i) {
1859-
const double minStat = stats.getMinimum(i);
1859+
const double minStat = static_cast<double>(stats.getMinimum(i));
18601860
if (prop->MinimumValue.size() > i) {
18611861
if (minStat == minStat && prop->MinimumValue[i] > minStat) {
18621862
prop->MinimumValue[i] = minStat;
@@ -1867,7 +1867,7 @@ namespace RESQML2_NS
18671867
}
18681868
}
18691869
for (size_t i = 0; i < stats.getMaximumSize(); ++i) {
1870-
const double maxStat = stats.getMaximum(i);
1870+
const double maxStat = static_cast<double>(stats.getMaximum(i));
18711871
if (prop->MaximumValue.size() > i) {
18721872
if (maxStat == maxStat && prop->MaximumValue[i] < maxStat) {
18731873
prop->MaximumValue[i] = maxStat;
@@ -1881,7 +1881,7 @@ namespace RESQML2_NS
18811881
else if (gsoapProxy2_0_1->soap_type() == SOAP_TYPE_gsoap_resqml2_0_1_resqml20__obj_USCOREDiscreteProperty) {
18821882
gsoap_resqml2_0_1::_resqml20__DiscreteProperty* prop = static_cast<gsoap_resqml2_0_1::_resqml20__DiscreteProperty*>(gsoapProxy2_0_1);
18831883
for (size_t i = 0; i < stats.getMinimumSize(); ++i) {
1884-
const auto minStat = stats.getMinimum(i);
1884+
const auto minStat = static_cast<int64_t>(stats.getMinimum(i));
18851885
if (prop->MinimumValue.size() > i) {
18861886
if (minStat == minStat && prop->MinimumValue[i] > minStat) {
18871887
prop->MinimumValue[i] = minStat;
@@ -1892,7 +1892,7 @@ namespace RESQML2_NS
18921892
}
18931893
}
18941894
for (size_t i = 0; i < stats.getMaximumSize(); ++i) {
1895-
const auto maxStat = stats.getMaximum(i);
1895+
const auto maxStat = static_cast<int64_t>(stats.getMaximum(i));
18961896
if (prop->MaximumValue.size() > i) {
18971897
if (maxStat == maxStat && prop->MaximumValue[i] < maxStat) {
18981898
prop->MaximumValue[i] = maxStat;

0 commit comments

Comments
 (0)