diff options
author | Raphael Langella <raphael.langella@gmail.com> | 2012-08-26 22:50:06 +0200 |
---|---|---|
committer | Raphael Langella <raphael.langella@gmail.com> | 2012-08-26 23:06:30 +0200 |
commit | 770bcbd1844b97b671d0e47ea8313cdf2c74c5ea (patch) | |
tree | e030cf61afce9ca69b74bb38eb73734bf10f633e /crawl-ref/source/tags.h | |
parent | a6c16c7f2066c854a01f25e9e6c3d8e44282a638 (diff) | |
download | crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.tar.gz crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.zip |
Use std namespace.
I had to rename distance() (in coord.h) to distance2() because it conflicts
with the STL function to compare 2 iterators. Not a bad change given how it
returns the square of the distance anyway.
I also had to rename the message global variable (in message.cc) to buffer.
I tried to fix and improve the coding style has much as I could, but I
probably missed a few given how huge and tedious it is.
I also didn't touch crawl-gdb.py, and the stuff in prebuilt, rltiles/tool
and util/levcomp.*, because I have no clue about those.
Diffstat (limited to 'crawl-ref/source/tags.h')
-rw-r--r-- | crawl-ref/source/tags.h | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h index 567fbce446..33b98569de 100644 --- a/crawl-ref/source/tags.h +++ b/crawl-ref/source/tags.h @@ -32,7 +32,7 @@ enum tag_type // used during save/load process to identify data blocks struct enum_info { - void (*collect)(std::vector<std::pair<int,std::string> >& prs); + void (*collect)(vector<pair<int,string> >& prs); int replacement; struct enum_val @@ -48,8 +48,8 @@ struct enum_info struct enum_write_state { - std::set<int> used; - std::map<int, std::string> names; + set<int> used; + map<int, string> names; char store_type; enum_write_state() : used(), names(), store_type(0) {} @@ -57,8 +57,8 @@ struct enum_write_state struct enum_read_state { - std::map<int, int> mapping; - std::map<std::string, int> names; + map<int, int> mapping; + map<string, int> names; char store_type; enum_read_state() : mapping(), names(), store_type(0) {} @@ -79,17 +79,16 @@ template<typename enm> struct enum_details; class writer { public: - writer(const std::string &filename, FILE* output, - bool ignore_errors = false) + writer(const string &filename, FILE* output, bool ignore_errors = false) : _filename(filename), _file(output), _chunk(0), _ignore_errors(ignore_errors), _pbuf(0), failed(false) { ASSERT(output); } - writer(std::vector<unsigned char>* poutput) + writer(vector<unsigned char>* poutput) : _filename(), _file(0), _chunk(0), _ignore_errors(false), _pbuf(poutput), failed(false) { ASSERT(poutput); } - writer(package *save, const std::string &chunkname) + writer(package *save, const string &chunkname) : _filename(), _file(0), _chunk(0), _ignore_errors(false), failed(false) { @@ -109,16 +108,16 @@ private: void check_ok(bool ok); private: - std::string _filename; + string _filename; FILE* _file; chunk_writer *_chunk; bool _ignore_errors; - std::vector<unsigned char>* _pbuf; + vector<unsigned char>* _pbuf; bool failed; - std::map<const enum_info*, enum_write_state> used_enums; + map<const enum_info*, enum_write_state> used_enums; friend void marshallEnumVal(writer&, const enum_info*, int); }; @@ -128,8 +127,8 @@ void marshallInt (writer &, int32_t); void marshallFloat (writer &, float); void marshallUByte (writer &, uint8_t); void marshallBoolean (writer &, bool); -void marshallString (writer &, const std::string &, int maxSize = 0); -void marshallString4 (writer &, const std::string &); +void marshallString (writer &, const string &, int maxSize = 0); +void marshallString4 (writer &, const string &); void marshallCoord (writer &, const coord_def &); void marshallItem (writer &, const item_def &, bool info = false); void marshallMonster (writer &, const monster&); @@ -155,15 +154,15 @@ void marshallSigned(writer& th, int64_t v); class reader { public: - reader(const std::string &filename, int minorVersion = TAG_MINOR_INVALID); + reader(const string &filename, int minorVersion = TAG_MINOR_INVALID); reader(FILE* input, int minorVersion = TAG_MINOR_INVALID) : _file(input), _chunk(0), opened_file(false), _pbuf(0), _read_offset(0), _minorVersion(minorVersion) {} - reader(const std::vector<unsigned char>& input, + reader(const vector<unsigned char>& input, int minorVersion = TAG_MINOR_INVALID) : _file(0), _chunk(0), opened_file(false), _pbuf(&input), _read_offset(0), _minorVersion(minorVersion) {} - reader(package *save, const std::string &chunkname, + reader(package *save, const string &chunkname, int minorVersion = TAG_MINOR_INVALID); ~reader(); @@ -173,25 +172,25 @@ public: int getMinorVersion() const; void setMinorVersion(int minorVersion); bool valid() const; - void fail_if_not_eof(const std::string &name); + void fail_if_not_eof(const string &name); void close(); - std::string filename() const { return _filename; } + string filename() const { return _filename; } private: - std::string _filename; + string _filename; FILE* _file; chunk_reader *_chunk; bool opened_file; - const std::vector<unsigned char>* _pbuf; + const vector<unsigned char>* _pbuf; unsigned int _read_offset; int _minorVersion; - std::map<const enum_info*, enum_read_state> seen_enums; + map<const enum_info*, enum_read_state> seen_enums; friend int unmarshallEnumVal(reader &, const enum_info *); }; -class short_read_exception : std::exception {}; +class short_read_exception : exception {}; int8_t unmarshallByte (reader &); int16_t unmarshallShort (reader &); @@ -199,8 +198,8 @@ int32_t unmarshallInt (reader &); float unmarshallFloat (reader &); uint8_t unmarshallUByte (reader &); bool unmarshallBoolean (reader &); -std::string unmarshallString (reader &, int maxSize = 1000); -void unmarshallString4 (reader &, std::string&); +string unmarshallString (reader &, int maxSize = 1000); +void unmarshallString4 (reader &, string&); coord_def unmarshallCoord (reader &); void unmarshallItem (reader &, item_def &item); void unmarshallMonster (reader &, monster& item); @@ -242,6 +241,6 @@ void tag_read_char(reader &th, uint8_t format, uint8_t major, uint8_t minor); * misc * *********************************************************************** */ -std::string make_date_string(time_t in_date); +string make_date_string(time_t in_date); #endif // TAGS_H |