00001
00012 #if !defined(Comun_hpp)
00013 #define Comun_hpp
00014
00015 #include <set>
00016 #include <string>
00017 #include <ostream>
00018 #include <sstream>
00019
00020 #ifdef ASSERT
00021 #undef ASSERT
00022 #endif
00023 #ifdef NDEBUG
00024 #define ASSERT(x) ((void)0)
00025 #warning NDEBUG activo compilando sin ASSERT
00026 #else
00027 #define ASSERT(x) \
00028 if (! (x)) \
00029 { \
00030 stringstream _sa; _sa.clear(); _sa.str(""); \
00031 _sa << __FILE__ << ":" << __LINE__ << "Falló aserción " << #x << " \n"; \
00032 throw std::string(_sa.str()); \
00033 }
00034 #endif
00035
00037 const unsigned int MAXLURL = 1024;
00038
00040 const unsigned int MAXLCONDENSADO = 64;
00041
00044 const unsigned int MAXLHEX = 8;
00045
00049 const int MAXL128B = 5;
00050
00054 const int MAXLNUMERO = MAXL128B;
00055
00058 const int MAXLDEC = 10;
00059
00061 const unsigned int MAXCAD = 32;
00062
00063 using namespace std;
00064
00066 const string MARCAIND = "Mt77:índiceP5";
00067
00068
00070 const string MARCAREL = "Mt77:relaciónP5";
00071
00072
00074 const char FINCADENA = '{';
00075
00082 void verificaNombre(const char *na, char *nrel);
00083
00084
00092 template <class T>
00093 std::ostream &
00094 operator<<(std::ostream &os, set<T> c)
00095 {
00096 os <<"{";
00097 typename set<T>::iterator i;
00098 string sep = "";
00099 for (i = c.begin(); i != c.end(); i++) {
00100 os << sep << *i;
00101 sep = ", ";
00102 }
00103 os <<"}";
00104 return os;
00105 }
00106
00112 string prefijo_comun_mas_largo(string a, string b);
00113
00120 std::string errorFormato(std::istream &is, string m);
00121
00126 string leeCad(istream &is) throw(string);
00127
00132 long leeHex(std::istream &is) throw(string);
00133
00134
00140 void escribeHex(std::ostream &os, unsigned long n);
00141
00148 long lee128b(std::istream &is) throw(string);
00149
00150
00157 void escribe128b(std::ostream &os, unsigned long n);
00158
00164 string n128b_c(unsigned long n);
00165
00171 unsigned long c_n128b(string s);
00172
00179 inline unsigned int
00180 long128b(unsigned long n)
00181 {
00182 return MAXL128B;
00183 }
00184
00185
00190 inline long
00191 leeNDesp(std::istream &is) throw (std::string)
00192 {
00193 return lee128b(is);
00194 }
00195
00196
00202 inline void
00203 escribeNDesp(std::ostream &os, unsigned long n)
00204 {
00205 escribe128b(os, n);
00206 }
00207
00208
00212 inline unsigned int
00213 longNDesp(unsigned long n)
00214 {
00215 return MAXL128B;
00216 }
00217
00218
00224 string normalizaCaracter(char c);
00225
00231 string normaliza(string s);
00232
00245 int car_utf8_a_latin1(const char *u8, char *latin1);
00246
00255 string utf8_a_latin1(const char *u8, int len);
00256
00264 vector<string> estalla(const string &delimitador, const string &cad);
00265
00266
00272 string directorio_temp();
00273
00274
00275 #endif