Skip to content

Commit

Permalink
Be more specific about integer types, so that they work on both i386 …
Browse files Browse the repository at this point in the history
…and x86_64.
  • Loading branch information
zerebubuth committed Oct 3, 2016
1 parent ce53598 commit 9c039dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AC_INIT([CGImap],
[0.5.0],
[0.5.1],
[https://github.com/zerebubuth/openstreetmap-cgimap/issues],
[cgimap-0.5.0],
[cgimap-0.5.1],
[https://github.com/zerebubuth/openstreetmap-cgimap])
AM_INIT_AUTOMAKE([subdir-objects parallel-tests])
LT_INIT
Expand Down
10 changes: 5 additions & 5 deletions include/cgimap/xml_writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <boost/shared_ptr.hpp>
#include "cgimap/output_buffer.hpp"
#include "cgimap/output_writer.hpp"
#include <inttypes.h>

/**
* Writes UTF-8 output to a file or stdout.
Expand Down Expand Up @@ -33,11 +34,10 @@ class xml_writer : public output_writer {

// overloaded versions of writeAttribute for convenience
void attribute(const std::string &name, double value);
void attribute(const std::string &name, int value);
void attribute(const std::string &name, unsigned long int value);
void attribute(const std::string &name, unsigned long long int value);
void attribute(const std::string &name, long int value);
void attribute(const std::string &name, long long int value);
void attribute(const std::string &name, int32_t value);
void attribute(const std::string &name, int64_t value);
void attribute(const std::string &name, uint32_t value);
void attribute(const std::string &name, uint64_t value);
void attribute(const std::string &name, bool value);

// write a child text element
Expand Down
34 changes: 12 additions & 22 deletions src/xml_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,45 +122,35 @@ void xml_writer::attribute(const std::string &name, double value) {
}
}

void xml_writer::attribute(const std::string &name, unsigned long int value) {
void xml_writer::attribute(const std::string &name, int32_t value) {
int rc = xmlTextWriterWriteFormatAttribute(
pimpl->writer, BAD_CAST name.c_str(), "%lu", value);
pimpl->writer, BAD_CAST name.c_str(), "%" PRId32, value);
if (rc < 0) {
throw write_error("cannot write osm_id_t(unsigned long int) attribute.");
throw write_error("cannot write int32_t attribute.");
}
}

void xml_writer::attribute(const std::string &name,
unsigned long long int value) {
void xml_writer::attribute(const std::string &name, int64_t value) {
int rc = xmlTextWriterWriteFormatAttribute(
pimpl->writer, BAD_CAST name.c_str(), "%llu", value);
pimpl->writer, BAD_CAST name.c_str(), "%" PRId64, value);
if (rc < 0) {
throw write_error("cannot write osm_id_t(unsigned long long int) attribute.");
throw write_error("cannot write int64_t attribute.");
}
}

void xml_writer::attribute(const std::string &name, long int value) {
void xml_writer::attribute(const std::string &name, uint32_t value) {
int rc = xmlTextWriterWriteFormatAttribute(
pimpl->writer, BAD_CAST name.c_str(), "%ld", value);
pimpl->writer, BAD_CAST name.c_str(), "%" PRIu32, value);
if (rc < 0) {
throw write_error("cannot write osm_id_t(long int) attribute.");
throw write_error("cannot write uint32_t attribute.");
}
}

void xml_writer::attribute(const std::string &name,
long long int value) {
void xml_writer::attribute(const std::string &name, uint64_t value) {
int rc = xmlTextWriterWriteFormatAttribute(
pimpl->writer, BAD_CAST name.c_str(), "%lld", value);
pimpl->writer, BAD_CAST name.c_str(), "%" PRIu64, value);
if (rc < 0) {
throw write_error("cannot write osm_id_t(long long int) attribute.");
}
}

void xml_writer::attribute(const std::string &name, int value) {
int rc = xmlTextWriterWriteFormatAttribute(
pimpl->writer, BAD_CAST name.c_str(), "%d", value);
if (rc < 0) {
throw write_error("cannot write integer attribute.");
throw write_error("cannot write uint64_t attribute.");
}
}

Expand Down

0 comments on commit 9c039dc

Please sign in to comment.