Commit da89bdd6 authored by Rashad Kanavath's avatar Rashad Kanavath

WRG: MSVC: C4267 fix possible loss of data

parent fdce529d
......@@ -195,14 +195,14 @@ public:
* \pre <tt>index < GetSize()</tt>
* \throw None
*/
Field operator[](size_t index);
Field operator[](int index);
/**
* Read-only access to the i-th field.
* \invariant <tt>m_Feature != 0</tt>
* \pre <tt>index < GetSize()</tt>
* \throw None
*/
Field const operator[](size_t index) const;
Field const operator[](int index) const;
/**
* Read-Write access to a field by name.
* \invariant <tt>m_Feature != 0</tt>
......@@ -221,7 +221,7 @@ public:
* \throw None
* \sa \c OGRFeature::GetFieldDefnRef()
*/
FieldDefn GetFieldDefn(size_t index) const;
FieldDefn GetFieldDefn(int index) const;
/** Accessor to the definition of a field gven its name.
* \invariant <tt>m_Feature != 0</tt>
* \throw itk::ExceptionObject if no field named \c name exists.
......@@ -314,9 +314,9 @@ private:
void UncheckedSetFrom(Feature const& rhs, int *map, bool mustForgive = true);
void UncheckedSetFrom(Feature const& rhs, bool mustForgive = true);
void UncheckedPrintSelf(std::ostream &os, itk::Indent indent) const;
Field UncheckedGetElement(size_t index);
Field UncheckedGetElement(int index);
Field UncheckedGetElement(std::string const& name);
FieldDefn UncheckedGetFieldDefn(size_t index) const;
FieldDefn UncheckedGetFieldDefn(int index) const;
FieldDefn UncheckedGetFieldDefn(std::string const& name) const;
int UncheckedGetFieldIndex(std::string const& name) const;
long UncheckedGetFID() const;
......
......@@ -66,14 +66,14 @@ void otb::ogr::Feature::SetFrom(Feature const& rhs, int * map, bool mustForgive)
/*================================[ Fields ]=================================*/
/*===========================================================================*/
inline
otb::ogr::Field otb::ogr::Feature::operator[](size_t index)
otb::ogr::Field otb::ogr::Feature::operator[](int index)
{
assert(index < GetSize() && "out of range field-index."); // also calls CheckInvariants();
return UncheckedGetElement(index);
}
inline
otb::ogr::Field const otb::ogr::Feature::operator[](size_t index) const
otb::ogr::Field const otb::ogr::Feature::operator[](int index) const
{
return const_cast<Feature*>(this)->operator[](index);
}
......@@ -92,7 +92,7 @@ otb::ogr::Field const otb::ogr::Feature::operator[](std::string const& name) con
}
inline
otb::ogr::FieldDefn otb::ogr::Feature::GetFieldDefn(size_t index) const
otb::ogr::FieldDefn otb::ogr::Feature::GetFieldDefn(int index) const
{
assert(index < GetSize() && "out of range field-index."); // also calls CheckInvariants();
return UncheckedGetFieldDefn(index);
......
......@@ -25,7 +25,6 @@ class OGRFeature;
#include "ogr_core.h" // OGR enums
#include "itkIndent.h"
namespace otb { namespace ogr {
/*===========================================================================*/
......@@ -101,7 +100,7 @@ public:
* \param[in] index Index of the field in the \c Feature.
* \throw None
*/
Field(Feature & feature, size_t index);
Field(Feature & feature, int index);
/// %Field definition accessor.
FieldDefn const& GetDefinition() const
{ return m_Definition; }
......@@ -167,6 +166,7 @@ public:
/** \copydoc Field::ogr() const */
OGRField & ogr();
private:
/**\name Unchecked definitions
* All the definitions that follow do the real work. However, they are not the
......@@ -201,10 +201,12 @@ private:
* All the fields decoding is at the wrong place (\c OGRFeature instead of
* \c OGRField) => need for an index.
*/
size_t m_index;
int m_index;
};
} } // end namespace otb::ogr
}
} // end namespace otb::ogr
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbOGRFieldWrapper.txx"
......
......@@ -386,7 +386,7 @@ inline
void otb::ogr::Field::CheckInvariants() const
{
assert(m_Feature && "OGR Fields must be associated to a valid feature");
assert(int(m_index) < m_Feature->GetFieldCount() && "Out-of-range index for a OGR field");
assert(m_index < m_Feature->GetFieldCount() && "Out-of-range index for a OGR field");
assert(m_Feature->GetFieldDefnRef(m_index) && "No definition available for the OGR field");
}
......
......@@ -377,11 +377,11 @@ public:
* \sa \c feature_iter
* Depending of the actual driver (i.e. \c OGRDriver), this may be done in O(N).
*/
const_iterator cstart_at(size_t index) const;
const_iterator cstart_at(GIntBig index) const;
/** \copydoc cstart_at */
const_iterator start_at (size_t index) const { return cstart_at(index); }
const_iterator start_at (GIntBig index) const { return cstart_at(index); }
/** \copydoc cstart_at */
iterator start_at (size_t index);
iterator start_at (GIntBig index);
//@}
/**\name Features definition
......@@ -426,7 +426,7 @@ public:
* \pre To be available, this function requires OTB to be compiled against OGR
* v1.9.0 at least.
*/
void DeleteField(size_t fieldIndex);
void DeleteField(int fieldIndex);
/**
* Changes the definition of the i-th field.
......
......@@ -33,6 +33,7 @@
#include "cpl_error.h"
#include "itkMacro.h"
/*===========================================================================*/
/*======================[ Construction / Destruction ]=======================*/
/*===========================================================================*/
......@@ -91,11 +92,11 @@ void otb::ogr::Feature::UncheckedSetFrom(Feature const& rhs, int * map, bool mus
/*===========================================================================*/
void otb::ogr::Feature::UncheckedPrintSelf(std::ostream & os, itk::Indent indent) const
{
const size_t nbFields = m_Feature->GetFieldCount();
const int nbFields = m_Feature->GetFieldCount();
os << indent << "+";
os << " " << nbFields << " fields\n";
indent = indent.GetNextIndent();
for (size_t i=0; i!=nbFields; ++i)
for (int i=0; i!=nbFields; ++i)
{
assert(ogr().GetFieldDefnRef(i) && "No definition associated to the i-th field");
Field const& field = (*this)[i];
......@@ -124,7 +125,7 @@ size_t otb::ogr::Feature::GetSize() const {
return ogr().GetFieldCount();
}
otb::ogr::Field otb::ogr::Feature::UncheckedGetElement(size_t index)
otb::ogr::Field otb::ogr::Feature::UncheckedGetElement(int index)
{
Field field(*this, index);
return field;
......@@ -136,7 +137,7 @@ otb::ogr::Field otb::ogr::Feature::UncheckedGetElement(std::string const& name)
return this->operator[](index);
}
otb::ogr::FieldDefn otb::ogr::Feature::UncheckedGetFieldDefn(size_t index) const
otb::ogr::FieldDefn otb::ogr::Feature::UncheckedGetFieldDefn(int index) const
{
return FieldDefn(*m_Feature->GetFieldDefnRef(index));
}
......@@ -151,7 +152,9 @@ otb::ogr::FieldDefn otb::ogr::Feature::UncheckedGetFieldDefn(std::string const&
return this->GetFieldDefn(index);
}
int otb::ogr::Feature::UncheckedGetFieldIndex(std::string const& name) const
int
otb::ogr::Feature
::UncheckedGetFieldIndex(std::string const& name) const
{
const int index = m_Feature->GetFieldIndex(name.c_str());
if (index < 0)
......
......@@ -114,7 +114,7 @@ std::ostream & otb::ogr::operator<<(std::ostream & os, otb::ogr::FieldDefn const
/*=================================[ Field ]=================================*/
/*===========================================================================*/
otb::ogr::Field::Field(otb::ogr::Feature & feature, size_t index)
otb::ogr::Field::Field(otb::ogr::Feature & feature, int index)
: m_Definition(*feature.ogr().GetFieldDefnRef(index))
, m_Feature(feature.sptr())
, m_index(index)
......
......@@ -98,14 +98,14 @@ otb::ogr::Layer::const_iterator otb::ogr::Layer::cbegin() const
return const_iterator(*const_cast <Layer*>(this));
}
otb::ogr::Layer::iterator otb::ogr::Layer::start_at(size_t index)
otb::ogr::Layer::iterator otb::ogr::Layer::start_at(GIntBig index)
{
assert(m_Layer && "OGRLayer not initialized");
m_Layer->SetNextByIndex(index);
return iterator(*this);
}
otb::ogr::Layer::const_iterator otb::ogr::Layer::cstart_at(size_t index) const
otb::ogr::Layer::const_iterator otb::ogr::Layer::cstart_at(GIntBig index) const
{
assert(m_Layer && "OGRLayer not initialized");
m_Layer->SetNextByIndex(index);
......@@ -320,7 +320,7 @@ void otb::ogr::Layer::CreateField(
}
}
void otb::ogr::Layer::DeleteField(size_t fieldIndex)
void otb::ogr::Layer::DeleteField(int fieldIndex)
{
assert(m_Layer && "OGRLayer not initialized");
......@@ -334,7 +334,7 @@ void otb::ogr::Layer::DeleteField(size_t fieldIndex)
itkGenericExceptionMacro("OGRLayer::DeleteField is not supported by OGR v"
<< GDAL_VERSION_NUM << ". Upgrade to a version >= 1.9.0, and recompile OTB.")
#else
const OGRErr res = m_Layer->DeleteField(int(fieldIndex));
const OGRErr res = m_Layer->DeleteField(fieldIndex);
if (res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot delete the "<<fieldIndex << "th field in the layer <"
......
......@@ -81,6 +81,7 @@ public:
//{return "ImageKeywordlist"; }
typedef std::map<std::string, std::string> KeywordlistMap;
typedef KeywordlistMap::size_type KeywordlistMapSizeType;
/** Get the internal map container */
const KeywordlistMap& GetKeywordlist() const
......@@ -94,8 +95,8 @@ public:
{
m_Keywordlist.clear();
}
unsigned int GetSize(void) const
KeywordlistMapSizeType GetSize(void) const
{
return m_Keywordlist.size();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment