Stopped using the generic "unsigned int" in favor of more specific types.

This commit is contained in:
John Wiegley 2009-01-29 18:23:57 -04:00
parent 119b5dc197
commit 05c77351e4
27 changed files with 120 additions and 120 deletions

View file

@ -108,13 +108,13 @@ class account_t : public scope_t
#define ACCOUNT_EXT_HAS_NON_VIRTUALS 0x08
#define ACCOUNT_EXT_HAS_UNB_VIRTUALS 0x10
value_t value;
value_t total;
value_t sort_value;
unsigned int count; // xacts counted toward amount
unsigned int total_count; // xacts counted toward total
unsigned int virtuals;
unsigned short dflags;
value_t value;
value_t total;
value_t sort_value;
std::size_t count; // xacts counted toward amount
std::size_t total_count; // xacts counted toward total
std::size_t virtuals;
uint_least8_t dflags;
xdata_t()
: supports_flags<>(), count(0), total_count(0),

View file

@ -1341,7 +1341,7 @@ void amount_t::read(const char *& data,
}
}
void amount_t::write(std::ostream& out, unsigned int index) const
void amount_t::write(std::ostream& out, std::size_t index) const
{
using namespace ledger::binary;

View file

@ -104,7 +104,7 @@ public:
* The number of places of precision by which values are extended to
* avoid losing precision during division and multiplication.
*/
static const unsigned int extend_by_digits = 6U;
static const std::size_t extend_by_digits = 6U;
/**
* The current_pool is a static variable indicating which commodity
@ -805,7 +805,7 @@ public:
void read(const char *& data,
char ** pool = NULL,
char ** pool_next = NULL);
void write(std::ostream& out, unsigned int index = 0) const;
void write(std::ostream& out, std::size_t index = 0) const;
/*@}*/

View file

@ -517,10 +517,10 @@ void write_account(std::ostream& out, account_t * account)
write_account(out, pair.second);
}
unsigned int read_journal(std::istream& in,
const path& file,
journal_t& journal,
account_t * master)
std::size_t read_journal(std::istream& in,
const path& file,
journal_t& journal,
account_t * master)
{
using namespace binary;

View file

@ -86,7 +86,7 @@ expr_t& expr_t::operator=(const expr_t& _expr)
return *this;
}
void expr_t::parse(const string& _str, const unsigned int flags)
void expr_t::parse(const string& _str, const uint32_t flags)
{
if (! parser.get())
throw_(parse_error, "Value expression parser not initialized");
@ -96,7 +96,7 @@ void expr_t::parse(const string& _str, const unsigned int flags)
compiled = false;
}
void expr_t::parse(std::istream& in, const unsigned int flags,
void expr_t::parse(std::istream& in, const uint32_t flags,
const string * original_string)
{
if (! parser.get())

View file

@ -108,8 +108,8 @@ public:
str = txt;
}
void parse(const string& _str, const unsigned int flags = 0);
void parse(std::istream& in, const unsigned int flags = 0,
void parse(const string& _str, const uint32_t flags = 0);
void parse(std::istream& in, const uint32_t flags = 0,
const string * original_string = NULL);
void compile(scope_t& scope);

View file

@ -125,7 +125,7 @@ void sort_xacts::post_accumulated_xacts()
}
namespace {
string to_hex(unsigned int * message_digest)
string to_hex(uint_least32_t * message_digest)
{
std::ostringstream buf;
@ -140,9 +140,9 @@ namespace {
void anonymize_xacts::operator()(xact_t& xact)
{
SHA1 sha;
unsigned int message_digest[5];
bool copy_entry_details = false;
SHA1 sha;
uint_least32_t message_digest[5];
bool copy_entry_details = false;
if (last_entry != xact.entry) {
entry_temps.push_back(*xact.entry);

View file

@ -296,11 +296,11 @@ inline void clear_entries_xacts(std::list<entry_t>& entries_list) {
class collapse_xacts : public item_handler<xact_t>
{
value_t subtotal;
unsigned int count;
entry_t * last_entry;
xact_t * last_xact;
account_t totals_account;
value_t subtotal;
std::size_t count;
entry_t * last_entry;
xact_t * last_xact;
account_t totals_account;
std::list<entry_t> entry_temps;
std::list<xact_t> xact_temps;

View file

@ -323,12 +323,12 @@ void format_t::format(std::ostream& out_str, scope_t& scope)
}
}
string format_t::truncate(const unistring& ustr, unsigned int width,
string format_t::truncate(const unistring& ustr, std::size_t width,
const bool is_account)
{
assert(width < 4095);
const unsigned int len = ustr.length();
const std::size_t len = ustr.length();
if (len <= width)
return ustr.extract();
@ -361,7 +361,7 @@ string format_t::truncate(const unistring& ustr, unsigned int width,
std::ostringstream result;
unsigned int newlen = len;
std::size_t newlen = len;
for (std::list<string>::iterator i = parts.begin();
i != parts.end();
i++) {

View file

@ -185,7 +185,7 @@ public:
elem->dump(out);
}
static string truncate(const unistring& str, unsigned int width,
static string truncate(const unistring& str, std::size_t width,
const bool is_account = false);
};

View file

@ -55,14 +55,14 @@ static amount_t curr_quant;
static XML_Parser current_parser;
static accounts_map accounts_by_id;
static account_comm_map account_comms;
static unsigned int count;
static std::size_t count;
static string have_error;
static std::istream * instreamp;
static unsigned int offset;
static std::size_t offset;
static XML_Parser parser;
static path pathname;
static unsigned int src_idx;
static std::size_t src_idx;
static istream_pos_type beg_pos;
static unsigned long beg_line;
@ -376,11 +376,11 @@ bool gnucash_parser_t::test(std::istream& in) const
return true;
}
unsigned int gnucash_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
std::size_t gnucash_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
{
#if 0
char buf[BUFSIZ];

View file

@ -41,11 +41,11 @@ class gnucash_parser_t : public journal_t::parser_t
public:
virtual bool test(std::istream& in) const;
virtual unsigned int parse(std::istream& in,
session_t& session,
virtual std::size_t parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
account_t * master = NULL,
const path * original_file = NULL);
};
} // namespace ledger

View file

@ -96,11 +96,11 @@ public:
virtual bool test(std::istream& in) const = 0;
virtual unsigned int parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL) = 0;
virtual std::size_t parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL) = 0;
};
class binary_parser_t : public parser_t
@ -108,11 +108,11 @@ public:
public:
virtual bool test(std::istream& in) const;
virtual unsigned int parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
virtual std::size_t parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
};
bool valid() const;

View file

@ -230,11 +230,11 @@ bool ofx_parser_t::test(std::istream& in) const
return true;
}
unsigned int ofx_parser_t::parse(std::istream&,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
std::size_t ofx_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
{
if (! original_file)
return 0;

View file

@ -41,11 +41,11 @@ class ofx_parser_t : public journal_t::parser_t
public:
virtual bool test(std::istream& in) const;
virtual unsigned int parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
virtual std::size_t parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
};
} // namespace ledger

View file

@ -49,7 +49,7 @@ private:
mutable short refc;
ptr_op_t left_;
variant<unsigned int, // used by constant INDEX
variant<std::size_t, // used by constant INDEX
value_t, // used by constant VALUE
string, // used by constant IDENT
mask_t, // used by constant MASK
@ -122,16 +122,16 @@ public:
}
bool is_index() const {
return data.type() == typeid(unsigned int);
return data.type() == typeid(std::size_t);
}
unsigned int& as_index_lval() {
std::size_t& as_index_lval() {
assert(kind == INDEX);
return boost::get<unsigned int>(data);
return boost::get<std::size_t>(data);
}
const unsigned int& as_index() const {
const std::size_t& as_index() const {
return const_cast<op_t *>(this)->as_index_lval();
}
void set_index(unsigned int val) {
void set_index(std::size_t val) {
data = val;
}

View file

@ -110,7 +110,7 @@ void process_environment(const char ** envp, const string& tag,
scope_t& scope)
{
const char * tag_p = tag.c_str();
unsigned int tag_len = tag.length();
std::size_t tag_len = tag.length();
for (const char ** p = envp; *p; p++)
if (! tag_p || std::strncmp(*p, tag_p, tag_len) == 0) {

View file

@ -177,12 +177,12 @@ void format_accounts::operator()(account_t& account)
bool format_accounts::disp_subaccounts_p(account_t& account,
account_t *& to_show)
{
bool display = false;
unsigned int counted = 0;
bool matches = should_display(account);
bool computed = false;
value_t acct_total;
value_t result;
bool display = false;
std::size_t counted = 0;
bool matches = should_display(account);
bool computed = false;
value_t acct_total;
value_t result;
to_show = NULL;

View file

@ -39,8 +39,8 @@ namespace ledger {
static char line[MAX_LINE + 1];
static path pathname;
static unsigned int src_idx;
static unsigned int linenum;
static std::size_t src_idx;
static std::size_t linenum;
static inline char * get_line(std::istream& in) {
in.getline(line, MAX_LINE);
@ -53,9 +53,9 @@ static inline char * get_line(std::istream& in) {
bool qif_parser_t::test(std::istream& in) const
{
char magic[sizeof(unsigned int) + 1];
in.read(magic, sizeof(unsigned int));
magic[sizeof(unsigned int)] = '\0';
char magic[sizeof(uint32_t) + 1];
in.read(magic, sizeof(uint32_t));
magic[sizeof(uint32_t)] = '\0';
in.clear();
in.seekg(0, std::ios::beg);
@ -64,17 +64,17 @@ bool qif_parser_t::test(std::istream& in) const
std::strcmp(magic, "\r\n!T") == 0);
}
unsigned int qif_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
std::size_t qif_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
{
std::auto_ptr<entry_t> entry;
std::auto_ptr<amount_t> amount;
xact_t * xact;
unsigned int count = 0;
std::size_t count = 0;
account_t * misc = NULL;
commodity_t * def_commodity = NULL;
bool saw_splits = false;

View file

@ -41,11 +41,11 @@ class qif_parser_t : public journal_t::parser_t
public:
virtual bool test(std::istream& in) const;
virtual unsigned int parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
virtual std::size_t parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
};
} // namespace ledger

View file

@ -151,10 +151,10 @@ public:
return args;
}
value_t& operator[](const unsigned int index) {
value_t& operator[](const std::size_t index) {
return args[index];
}
const value_t& operator[](const unsigned int index) const {
const value_t& operator[](const std::size_t index) const {
return args[index];
}
@ -182,9 +182,9 @@ public:
: value(scope.resolve(name).template as_pointer<T>()) {
TRACE_CTOR(ptr_t, "scope_t&, const string&");
}
ptr_t(call_scope_t& scope, const unsigned int idx)
ptr_t(call_scope_t& scope, const std::size_t idx)
: value(scope[idx].template as_pointer<T>()) {
TRACE_CTOR(ptr_t, "call_scope_t&, const unsigned int");
TRACE_CTOR(ptr_t, "call_scope_t&, const std::size_t");
}
~ptr_t() throw() {
TRACE_DTOR(ptr_t);
@ -215,9 +215,9 @@ public:
}
}
var_t(call_scope_t& scope, const unsigned int idx)
var_t(call_scope_t& scope, const std::size_t idx)
{
TRACE_CTOR(var_t, "call_scope_t&, const unsigned int");
TRACE_CTOR(var_t, "call_scope_t&, const std::size_t");
if (idx < scope.size())
value = scope[idx];

View file

@ -72,7 +72,7 @@ typedef std::pair<std::string, std::size_t> allocation_pair;
typedef std::map<void *, allocation_pair> live_memory_map;
typedef std::multimap<void *, allocation_pair> live_objects_map;
typedef std::pair<unsigned int, std::size_t> count_size_pair;
typedef std::pair<std::size_t, std::size_t> count_size_pair;
typedef std::map<std::string, count_size_pair> object_count_map;
static live_memory_map * live_memory = NULL;
@ -432,7 +432,7 @@ std::ostream * _log_stream = &std::cerr;
std::ostringstream _log_buffer;
#if defined(TRACING_ON)
unsigned int _trace_level;
uint8_t _trace_level;
#endif
#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK

View file

@ -286,7 +286,7 @@ bool logger_func(log_level_t level);
#if defined(TRACING_ON)
extern unsigned int _trace_level;
extern uint8_t _trace_level;
#define SHOW_TRACE(lvl) \
(ledger::_log_level >= ledger::LOG_TRACE && lvl <= ledger::_trace_level)

View file

@ -237,7 +237,7 @@ xact_context::xact_context(const xact_t& _xact, const string& desc) throw()
: file_context("", 0, desc), xact(_xact)
{
const paths_list& sources(xact.entry->journal->sources);
unsigned int x = 0;
std::size_t x = 0;
foreach (const path& path, sources)
if (x == xact.entry->src_idx) {
file = path;

View file

@ -114,13 +114,13 @@ public:
#define XACT_EXT_COMPOUND 0x40
#define XACT_EXT_MATCHES 0x80
value_t total;
value_t sort_value;
value_t value;
unsigned int index;
date_t date;
account_t * account;
void * ptr;
value_t total;
value_t sort_value;
value_t value;
std::size_t index;
date_t date;
account_t * account;
void * ptr;
optional<xacts_list> component_xacts;

View file

@ -36,7 +36,7 @@
namespace ledger {
static irr::io::IrrXMLReader * current_parser;
static unsigned int count;
static std::size_t count;
static journal_t * curr_journal;
static entry_t * curr_entry;
@ -213,11 +213,11 @@ bool xml_parser_t::test(std::istream& in) const
return true;
}
unsigned int xml_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
std::size_t xml_parser_t::parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master,
const path * original_file)
{
TRACE_START(xml_parsing_total, 1, "Total time spent parsing XML:");

View file

@ -75,11 +75,11 @@ class xml_parser_t : public journal_t::parser_t
public:
virtual bool test(std::istream& in) const;
virtual unsigned int parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
virtual std::size_t parse(std::istream& in,
session_t& session,
journal_t& journal,
account_t * master = NULL,
const path * original_file = NULL);
};
class format_xml_entries : public format_entries