Skip to content

Commit bed8cec

Browse files
committed
warning fixes
1 parent 85225e4 commit bed8cec

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

source/tinyply.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ template<typename T> void ply_cast_ascii(void * dest, std::istream & is)
178178
*(static_cast<T *>(dest)) = ply_read_ascii<T>(is);
179179
}
180180

181-
size_t find_element(const std::string & key, const std::vector<PlyElement> & list)
181+
int64_t find_element(const std::string & key, const std::vector<PlyElement> & list)
182182
{
183183
for (size_t i = 0; i < list.size(); i++) if (list[i].name == key) return i;
184184
return -1;
185185
}
186186

187-
size_t find_property(const std::string & key, const std::vector<PlyProperty> & list)
187+
int64_t find_property(const std::string & key, const std::vector<PlyProperty> & list)
188188
{
189189
for (size_t i = 0; i < list.size(); ++i) if (list[i].name == key) return i;
190190
return -1;
@@ -503,7 +503,7 @@ std::shared_ptr<PlyData> PlyFile::PlyFileImpl::request_properties_from_element(c
503503
if (!propertyKeys.size()) throw std::invalid_argument("`propertyKeys` argument is empty");
504504
if (elementKey.size() == 0) throw std::invalid_argument("`elementKey` argument is empty");
505505

506-
const int elementIndex = find_element(elementKey, elements);
506+
const int64_t elementIndex = find_element(elementKey, elements);
507507

508508
// Sanity check if the user requested element is in the pre-parsed header
509509
if (elementIndex >= 0)
@@ -516,16 +516,18 @@ std::shared_ptr<PlyData> PlyFile::PlyFileImpl::request_properties_from_element(c
516516
// Find each of the keys
517517
for (auto key : propertyKeys)
518518
{
519-
const int propertyIndex = find_property(key, element.properties);
520-
519+
const int64_t propertyIndex = find_property(key, element.properties);
521520
if (propertyIndex >= 0)
522521
{
523522
// We found the property
524523
const PlyProperty & property = element.properties[propertyIndex];
525524
helper.data->t = property.propertyType;
526525
helper.data->isList = property.isList;
527526
auto result = userData.insert(std::pair<uint32_t, ParsingHelper>(hash_fnv1a(element.name + property.name), helper));
528-
if (result.second == false) throw std::invalid_argument("element-property key has already been requested: " + hash_fnv1a(element.name + property.name));
527+
if (result.second == false)
528+
{
529+
throw std::invalid_argument("element-property key has already been requested: " + hash_fnv1a(element.name + property.name));
530+
}
529531
}
530532
else throw std::invalid_argument("one of the property keys was not found in the header: " + key);
531533
}
@@ -556,7 +558,7 @@ void PlyFile::PlyFileImpl::add_properties_to_element(const std::string & element
556558
}
557559
};
558560

559-
int idx = find_element(elementKey, elements);
561+
int64_t idx = find_element(elementKey, elements);
560562
if (idx >= 0)
561563
{
562564
PlyElement & e = elements[idx];

source/tinyply.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ namespace tinyply
7777
{
7878
PlyProperty(std::istream & is);
7979
PlyProperty(Type type, std::string & _name) : name(_name), propertyType(type) {}
80-
PlyProperty(Type list_type, Type prop_type, std::string & _name, int list_count) : name(_name), propertyType(prop_type), isList(true), listType(list_type), listCount(list_count) {}
80+
PlyProperty(Type list_type, Type prop_type, std::string & _name, size_t list_count)
81+
: name(_name), propertyType(prop_type), isList(true), listType(list_type), listCount(list_count) {}
8182
std::string name;
8283
Type propertyType;
8384
bool isList{ false };
8485
Type listType{ Type::INVALID };
85-
int listCount{ 0 };
86+
size_t listCount{ 0 };
8687
};
8788

8889
struct PlyElement
@@ -130,8 +131,16 @@ namespace tinyply
130131
std::vector<std::string> get_info() const;
131132
std::vector<std::string> & get_comments();
132133

133-
std::shared_ptr<PlyData> request_properties_from_element(const std::string & elementKey, const std::initializer_list<std::string> propertyKeys);
134-
void add_properties_to_element(const std::string & elementKey, const std::initializer_list<std::string> propertyKeys, const Type type, const size_t count, uint8_t * data, const Type listType, const size_t listCount);
134+
std::shared_ptr<PlyData> request_properties_from_element(const std::string & elementKey,
135+
const std::initializer_list<std::string> propertyKeys);
136+
137+
void add_properties_to_element(const std::string & elementKey,
138+
const std::initializer_list<std::string> propertyKeys,
139+
const Type type,
140+
const size_t count,
141+
uint8_t * data,
142+
const Type listType,
143+
const size_t listCount);
135144
};
136145

137146
} // namespace tinyply

0 commit comments

Comments
 (0)