#include "globaldef.h"

#ifdef _USE_NAMESPACES
    namespace Else { 
#endif // _USE_NAMESPACES

const Natural MAX_NATURAL(UINT_MAX);
const ShortNatural MAX_SHORT_NATURAL(USHRT_MAX);

/*
const char ALTERNATE_MARK('|');
const char CONTRACTION_MARK('+');
const char SEGMENTATION_MARK('/');
const char SEGMENTATION_SUBMARK('.');
*/

const string START_EVALUATED_PART("<E>");
const string STOP_EVALUATED_PART("</E>");

bool is_space(const char c)
{
    const string ALPHABETIC_EXTENDED_SET("éèàùÉÈÀÙçÇâÂêÊîÎôÔûÛäÄëËïÏöÖüÜãÃõÕ");
	return (isspace(c) && (ALPHABETIC_EXTENDED_SET.find(c) == string::npos));
}


CharCategory categorize(const char& chr)
{
    const string ALPHABETIC_EXTENDED_SET("éèàùÉÈÀÙçÇâÂêÊîÎôÔûÛäÄëËïÏöÖüÜãÃõÕ");

    if (isalpha(chr)) return Alphabetic;
    if (ALPHABETIC_EXTENDED_SET.find(chr) != string::npos) return Alphabetic;
    if (isspace(chr)) return Separator;
    if (isdigit(chr)) return Numeric;
//    if (ALPHABETIC_EXTENDED_SET.find(chr) != string::npos) return Alphabetic;
    return Other;
}

// Reads a string (s) from the input stream (in), stopping when it reaches one of delim, and don't put it on s.
// Return the index of the reached delimitor, npos if end stream is reached before any delimiter.
string::size_type extendedGetLine(istream& in, string& s, const string& delim)
{
	char c;
	string::size_type res(delim.npos);
	s.erase();
	while (in.get(c) && ((res = delim.find(c)) == delim.npos)) s += c;
	return res;
}

// Like extendedGetLine, but delim char are not extracted from the stream.
string::size_type extendedGet(istream& in, string& s, const string& delim)
{
	char c;
	string::size_type res(delim.npos);
	s.erase();
	while (((res = delim.find(in.peek())) == delim.npos) && (in.get(c))) s += c;
	return res;
}


#ifdef _USE_NAMESPACES
    }
#endif // _USE_NAMESPACES
