/* @(#)support.cc (c) Telelogic AB */ #include #include "support.h" #include #ifndef _WIN32 #include #else static void sleep(int x) { for (int i = 0; i >(std::istream& f, Text& text) { char buf[256]; f >> buf; text.SetStr((char*) buf); return f; } std::ostream& operator<<(std::ostream& f, Text& text) { return f<>(std::istream& f, LangEnum& lang) { int bufint; comment("\nPLEASE CHOOSE A LANGUAGE \t", "\nCHOISISSEZ VOTRE LANGAGE \t:"); std::cout<<"\n\tEnglish \t: "<< LANG_ENGLISH; std::cout<<"\n\tFrancais \t: "<< LANG_FRENCH; std::cout<<"\n\nChoice - Choix \t: "; //f >> bufint; //Filter(f, bufint); //Filter(f, bufint, 0, 1); Filter(f, bufint, (int) LANG_ENGLISH, (int) LANG_FRENCH); // To modify lang = (LangEnum) bufint; return f; } PolyText::PolyText() { //SetLang(LANG_UNKNOWN); } PolyText::~PolyText() { } LangEnum PolyText::Language; void PolyText::SetLang(LangEnum lang) { Language = lang; } LangEnum PolyText::GetLang() { return( Language ); } void PolyText::SetStr(LangEnum lang, const char* str) { Text &text = GetText(lang); text.SetStr(str); } Text& PolyText::GetText(LangEnum lang) { switch (lang) { case LANG_FRENCH : return(French); break; case LANG_ENGLISH : return(English); break; case LANG_UNKNOWN: std::cout<<"Unknown Language\n"; break; } } std::ostream& operator<<(std::ostream& f, PolyText& polytext) { Text &text = polytext.GetText(polytext.GetLang()); if ((text.GetStr() == NULL) && (polytext.GetLang() != LANG_ENGLISH)) return f << polytext.GetText(LANG_ENGLISH); else return f<< text; } // Date Management Date::Date() { } Date::~Date() { } void Delay() { std::cout<<"."; std::cout.flush(); sleep(1); std::cout<<"."; std::cout.flush(); sleep(1); std::cout<<"."; std::cout.flush(); sleep(1); std::cout<<".\n"; std::cout.flush(); } void Print(char* string) { Delay(); std::cout<<" "<>bufin; EOS = BOOL_FALSE; while(EOS == BOOL_FALSE) { // Non numeric caractere if ((bufin[ibuf] < '0') || (bufin[ibuf] > '9')) { // Error detected // Retry std::cout<<"Bad Input; Please redo\n"; std::cout<<"Choice : "; itry--; break; } else { ibuf++; if (ibuf >= strlen(bufin)) EOS = BOOL_TRUE; } } } // Please check the lenght if (itry <= 0) // Max Limit reached value = 100; // Will map with an unknown transac else value = atoi(bufin); } // Filter Input void Filter(std::istream& f, int& value, int min, int max) { Retry: Filter(f, value); // Exception Bloc try { if ((value < min) || (value > max)) { throw "Error on domain data\n"; comment("Dead Code after a call to an exception\n", "Code mort apres une levee d'exception\n"); } } // Exception Treatment catch(char * msg) { static int nb_try = 0; std::cout< 5) throw "Too much try\n"; goto Retry; } }