_utility.cpp

Go to the documentation of this file.
00001 #include "config.hpp"
00002 
00003 #if !defined(ARAGELI_INCLUDE_CPP_WITH_EXPORT_TEMPLATE) || \
00004     defined(ARAGELI_INCLUDE_CPP_WITH_EXPORT_TEMPLATE__UTILITY)
00005 
00006 #include "_utility.hpp"
00007 
00008 namespace Arageli { namespace _Internal
00009 {
00010 
00011 template <typename A, typename B, typename Store_A, typename Store_B>
00012 void swap_help_1
00013 (A& a, B& b, Store_A& sa, Store_B& sb, false_type)
00014 {
00015     A t;
00016     a.swap(t);
00017     a = b;
00018     b = t;
00019 }
00020 
00021 
00022 template <typename In_a, typename In_b>
00023 int aggregate_cmp (In_a ai, In_a aend, In_b bi, In_b bend)
00024 {
00025     for(; ai != aend && bi != bend; ++ai, ++bi)
00026     {
00027         int lres = cmp(*ai, *bi);
00028         if(lres < 0)return -1;
00029         else if(lres > 0)return +1;
00030     }
00031 
00032     if(ai == aend)
00033         if(bi == bend)return 0;
00034         else return -1;
00035     else
00036     { // ai != aend
00037         ARAGELI_ASSERT_1(bi == bend);
00038         return +1;
00039     }
00040 }
00041 
00042 
00043 }}
00044 
00045 
00046 #else
00047 
00048 
00049 #include <cctype>
00050 #include "_utility.hpp"
00051 
00052 
00053 namespace Arageli { namespace _Internal
00054 {
00055 
00056 
00057 bool is_not_contains_spaces (const char* s)
00058 {
00059     while(*s)if(std::isspace(*s++))return false;
00060     return true;
00061 }
00062 
00063 
00064 bool read_literal (std::istream& in, const char* s)
00065 {
00066     const char* s_beg = s;
00067     if(!*s)return true;
00068     if(!in)return false;
00069     
00070     char ch;
00071     in >> ch;
00072     if(!in)return false;
00073     if(*s != ch)
00074     {
00075         in.putback(ch);
00076         return false;
00077     }
00078 
00079     Auto_stream_state ass(in, in.flags() & ~std::istream::skipws);
00080 
00081     while(*++s)
00082     {
00083         ch = in.get();
00084         if(!in)
00085         {
00086             in.clear();
00087             do in.putback(*--s); while(s != s_beg);
00088             return false;
00089         }
00090         if(*s != ch)
00091         {
00092             in.clear();
00093             in.putback(*s);
00094             do in.putback(*--s); while(s != s_beg);
00095             return false;
00096         }
00097     }
00098 
00099     return true;
00100 }
00101 
00102 
00103 
00104 
00105 }}
00106 
00107 #endif

Generated on Thu Aug 31 17:38:04 2006 for Arageli by  doxygen 1.4.7