FS#8961 - Anti-Aliased Fonts.
[kugel-rb/myfork.git] / utils / zenutils / source / shared / utils.h
blob694cb9c8b128a356517b4fd8e47e182913c17f33
1 /* zenutils - Utilities for working with creative firmwares.
2 * Copyright 2007 (c) Rasmus Ry <rasmus.ry{at}gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef SHARED_UTILS_H_INCLUDED
20 #define SHARED_UTILS_H_INCLUDED
22 #include <vector>
23 #include <pelib/PeLib.h>
25 #ifndef byte
26 typedef PeLib::byte byte;
27 #endif
28 #ifndef word
29 typedef PeLib::word word;
30 #endif
31 #ifndef dword
32 typedef PeLib::dword dword;
33 #endif
35 namespace shared {
36 typedef std::vector<byte> bytes;
38 inline dword swap(dword val)
40 return ((val & 0xFF) << 24)
41 | ((val & 0xFF00) << 8)
42 | ((val & 0xFF0000) >> 8)
43 | ((val & 0xFF000000) >> 24);
46 template <typename _Type>
47 inline void reverse(_Type* start, _Type* end)
49 while (start < end)
51 *start ^= *end;
52 *end ^= *start;
53 *start ^= *end;
54 start++;
55 end--;
59 std::string replace_extension(const std::string& filename, const std::string& extension);
60 std::string remove_extension(const std::string& filename);
61 std::string get_path(const std::string& filename);
62 std::string double_quote(const std::string& str);
64 bool inflate_to_file(const bytes& buffer, const char* filename);
65 bool deflate_to_file(const bytes& buffer, const char* filename);
66 }; //namespace shared
68 #endif //SHARED_UTILS_H_INCLUDED