00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _ID3LIB_UTILS_H_
00029 #define _ID3LIB_UTILS_H_
00030
00031 #if defined HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035 #include "id3/id3lib_streams.h"
00036 #include "id3/globals.h"
00037 #include "id3/id3lib_strings.h"
00038
00039 namespace dami
00040 {
00041 #ifdef MAXPATHLEN
00042 # define ID3_PATH_LENGTH (MAXPATHLEN + 1)
00043 #elif defined (PATH_MAX)
00044 # define ID3_PATH_LENGTH (PATH_MAX + 1)
00045 #else
00046 # define ID3_PATH_LENGTH (2048 + 1)
00047 #endif
00048
00049 #ifndef min
00050 template<typename T>
00051 const T& min(const T& a, const T& b)
00052 {
00053 return (a < b) ? a : b;
00054 }
00055 #endif
00056
00057 #ifndef max
00058 template<typename T>
00059 const T& max(const T& a, const T& b)
00060 {
00061 return (b < a) ? a : b;
00062 }
00063 #endif
00064
00065 #ifndef mid
00066 template<typename T>
00067 const T& mid(const T& lo, const T& mid, const T& hi)
00068 {
00069 return max(lo, min(mid, hi));
00070 }
00071 #endif
00072
00073 #ifndef abs
00074 template<typename T>
00075 T abs(const T& a)
00076 {
00077 return (a < T(0)) ? -a : a;
00078 }
00079 #endif
00080
00081 size_t ID3_C_EXPORT renderNumber(uchar *buffer, uint32 val, size_t size = sizeof(uint32));
00082 String ID3_C_EXPORT renderNumber(uint32 val, size_t size = sizeof(uint32));
00083
00084 String ID3_C_EXPORT toString(uint32 val);
00085 WString ID3_C_EXPORT toWString(const unicode_t[], size_t);
00086
00087 size_t ID3_C_EXPORT ucslen(const unicode_t *unicode);
00088 String ID3_C_EXPORT convert(String data, ID3_TextEnc, ID3_TextEnc);
00089
00090
00091 size_t ID3_C_EXPORT getFileSize(fstream&);
00092 size_t ID3_C_EXPORT getFileSize(ifstream&);
00093 size_t ID3_C_EXPORT getFileSize(ofstream&);
00094 ID3_Err ID3_C_EXPORT createFile(String, fstream&);
00095 ID3_Err ID3_C_EXPORT openWritableFile(String, fstream&);
00096 ID3_Err ID3_C_EXPORT openWritableFile(String, ofstream&);
00097 ID3_Err ID3_C_EXPORT openReadableFile(String, fstream&);
00098 ID3_Err ID3_C_EXPORT openReadableFile(String, ifstream&);
00099
00100 };
00101
00102 #endif
00103