COMMON: Move tag2str from util.h to str.h
svn-id: r48281
This commit is contained in:
parent
3e63df5415
commit
30c84d2cff
4 changed files with 39 additions and 24 deletions
|
@ -724,4 +724,19 @@ bool matchString(const char *str, const char *pat, bool ignoreCase, bool pathMod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String tag2string(uint32 tag) {
|
||||||
|
char str[5];
|
||||||
|
str[0] = (char)(tag >> 24);
|
||||||
|
str[1] = (char)(tag >> 16);
|
||||||
|
str[2] = (char)(tag >> 8);
|
||||||
|
str[3] = (char)tag;
|
||||||
|
str[4] = '\0';
|
||||||
|
// Replace non-printable chars by dot
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
if (!isprint((unsigned char)str[i]))
|
||||||
|
str[i] = '.';
|
||||||
|
}
|
||||||
|
return Common::String(str);
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
20
common/str.h
20
common/str.h
|
@ -319,8 +319,28 @@ Common::String normalizePath(const Common::String &path, const char sep);
|
||||||
bool matchString(const char *str, const char *pat, bool ignoreCase = false, bool pathMode = false);
|
bool matchString(const char *str, const char *pat, bool ignoreCase = false, bool pathMode = false);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 'list' of strings. Actually, this is nowadays an array, and hence misnamed.
|
||||||
|
*/
|
||||||
typedef Array<String> StringList;
|
typedef Array<String> StringList;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take a 32 bit value and turn it into a four character string, where each of
|
||||||
|
* the four bytes is turned into one character. Most significant byte is printed
|
||||||
|
* first.
|
||||||
|
*/
|
||||||
|
String tag2string(uint32 tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience wrapper for tag2string which "returns" a C string.
|
||||||
|
* Note: It is *NOT* safe to do anything with the return value other than directly
|
||||||
|
* copying or printing it.
|
||||||
|
*/
|
||||||
|
#define tag2str(x) Common::tag2string(x).c_str()
|
||||||
|
|
||||||
|
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -59,6 +59,10 @@ String StringTokenizer::nextToken() {
|
||||||
return String(_str.c_str() + _tokenBegin, _tokenEnd - _tokenBegin);
|
return String(_str.c_str() + _tokenBegin, _tokenEnd - _tokenBegin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Print hexdump of the data passed in
|
// Print hexdump of the data passed in
|
||||||
//
|
//
|
||||||
|
@ -111,21 +115,6 @@ void hexdump(const byte * data, int len, int bytesPerLine, int startOffset) {
|
||||||
printf("|\n");
|
printf("|\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
String tag2string(uint32 tag) {
|
|
||||||
char str[5];
|
|
||||||
str[0] = (char)(tag >> 24);
|
|
||||||
str[1] = (char)(tag >> 16);
|
|
||||||
str[2] = (char)(tag >> 8);
|
|
||||||
str[3] = (char)tag;
|
|
||||||
str[4] = '\0';
|
|
||||||
// Replace non-printable chars by dot
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
if (!isprint((unsigned char)str[i]))
|
|
||||||
str[i] = '.';
|
|
||||||
}
|
|
||||||
return Common::String(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
|
|
|
@ -102,15 +102,6 @@ private:
|
||||||
extern void hexdump(const byte * data, int len, int bytesPerLine = 16, int startOffset = 0);
|
extern void hexdump(const byte * data, int len, int bytesPerLine = 16, int startOffset = 0);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take a 32 bit value and turn it into a four character string, where each of
|
|
||||||
* the four bytes is turned into one character. Most significant byte is printed
|
|
||||||
* first.
|
|
||||||
*/
|
|
||||||
String tag2string(uint32 tag);
|
|
||||||
#define tag2str(x) Common::tag2string(x).c_str()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of game language.
|
* List of game language.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue