[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 8793b22 2/4: Use fixed-width integers where a
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 8793b22 2/4: Use fixed-width integers where appropriate |
Date: |
Thu, 7 Jun 2018 06:37:03 -0400 (EDT) |
branch: master
commit 8793b2291f52d7c29d41df6d836f1641f197faf4
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Use fixed-width integers where appropriate
---
rate_table.cpp | 17 ++++++++---------
rate_table.hpp | 3 ++-
rate_table_tool.cpp | 2 +-
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/rate_table.cpp b/rate_table.cpp
index 403c9a0..3c8bd83 100644
--- a/rate_table.cpp
+++ b/rate_table.cpp
@@ -35,7 +35,6 @@
#include <algorithm> // count()
#include <climits> // ULLONG_MAX
-#include <cstdint>
#include <cstdlib> // strtoull()
#include <cstring> // strncmp()
#include <iomanip>
@@ -846,7 +845,7 @@ class table_impl final
void name(std::string const& name) { name_ = name; }
std::uint32_t number() const { return *number_; }
std::string const& name() const { return *name_; }
- unsigned long int compute_hash_value() const;
+ std::uint32_t compute_hash_value() const;
private:
table_impl(table_impl const&) = delete;
@@ -910,10 +909,10 @@ class table_impl final
);
// Parse number checking that it is less than the given maximal value.
- static unsigned long int do_parse_number
+ static std::uint32_t do_parse_number
(enum_soa_field field
,int line_num
- ,unsigned long int max_num
+ ,std::uint32_t max_num
,std::string const& value
);
@@ -1309,10 +1308,10 @@ std::string* table_impl::parse_string
return &ostr.operator *();
}
-unsigned long int table_impl::do_parse_number
+std::uint32_t table_impl::do_parse_number
(enum_soa_field field
,int line_num
- ,unsigned long int max_num
+ ,std::uint32_t max_num
,std::string const& value
)
{
@@ -1341,7 +1340,7 @@ unsigned long int table_impl::do_parse_number
;
}
- return static_cast<unsigned long int>(res.num);
+ return static_cast<std::uint32_t>(res.num);
}
template<typename T>
@@ -2228,7 +2227,7 @@ bool table_impl::is_equal(table_impl const& other) const
;
}
-unsigned long int table_impl::compute_hash_value() const
+std::uint32_t table_impl::compute_hash_value() const
{
// This is a bug-for-bug reimplementation of the hash value computation
// algorithm used in the original SOA format which produces compatible
@@ -2330,7 +2329,7 @@ std::string const& table::name() const
return impl_->name();
}
-unsigned long int table::compute_hash_value() const
+std::uint32_t table::compute_hash_value() const
{
return impl_->compute_hash_value();
}
diff --git a/rate_table.hpp b/rate_table.hpp
index 9e50103..35e1862 100644
--- a/rate_table.hpp
+++ b/rate_table.hpp
@@ -27,6 +27,7 @@
#include <boost/filesystem/path.hpp>
#include <cstddef> // size_t
+#include <cstdint>
#include <iosfwd>
#include <memory> // shared_ptr
#include <string>
@@ -84,7 +85,7 @@ class table
std::string const& name() const;
// Method computing the hash value as used in the original SOA format.
- unsigned long int compute_hash_value() const;
+ std::uint32_t compute_hash_value() const;
// Comparison with another table: all fields are compared.
bool operator==(table const& other) const;
diff --git a/rate_table_tool.cpp b/rate_table_tool.cpp
index 1bb64ac..aa41fac 100644
--- a/rate_table_tool.cpp
+++ b/rate_table_tool.cpp
@@ -54,7 +54,7 @@ void calculate_and_display_crcs(fs::path const&
database_filename)
for(int i = 0; i != table_file.tables_count(); ++i)
{
table const& t = table_file.get_nth_table(i);
- unsigned long int crc = t.compute_hash_value();
+ std::uint32_t crc = t.compute_hash_value();
std::cout
<< std::dec << std::setw( 5) << std::setfill('0')
<< t.number().value()