Пример #1
0
	bool strIsDate(const char *str, const int strLen)
	{
		int len = strLen ? strLen : (int)strlen(str);
		if (10 != len)
		{
			return false;
		}

		if (strIsDigit(str, 4) && strIsDigit(str + 5, 2) && strIsDigit(str + 8, 2)
			&& (str[4] == '-' || str[4] == '/') && (str[7] == '-' || str[7] == '/'))
		{
			return true;
		}

		return false;
	}
Пример #2
0
void ReadLine (char *pPos, char *pEndPos, TArray<int> *retValues, char **retpPos)
	{
	while (true)
		{
		//	Skip to the next number.

		while (pPos < pEndPos && !strIsDigit(pPos) && *pPos != '-' && *pPos != '+' && *pPos != '\n' && *pPos != '\r')
			pPos++;

		if (pPos >= pEndPos || *pPos == '\n' || *pPos == '\r')
			{
			while (pPos < pEndPos && (*pPos == '\n' || *pPos == '\r'))
				pPos++;

			break;
			}

		//	Parse the number

		int iValue = strParseInt(pPos, 0, &pPos);
		retValues->Insert(iValue);
		}

	if (retpPos)
		*retpPos = pPos;
	}
Пример #3
0
CString CAeonInterface::EncodeFilePathComponent (const CString &sValue)

//	EncodeFilePathComponent
//
//	Encodes a file path component by replacing any invalid characters with ~hh
//	(where hh is the hexcode).

	{
	char *pPos = sValue.GetParsePointer();
	char *pEndPos = pPos + sValue.GetLength();
	CStringBuffer Output;

	while (pPos < pEndPos)
		{
		if (!strIsASCIIAlpha(pPos)					//	alpha
				&& !strIsDigit(pPos)				//	numbers
				&& *pPos != '-'
				&& *pPos != '_'
				&& *pPos != '.'
				&& *pPos != '~'
				&& !strIsASCIIHigh(pPos))			//	unicode characters
			{
			CString sChar = strPattern("~%x", (DWORD)(BYTE)*pPos);
			Output.Write(sChar);
			}
		else
			Output.Write(pPos, 1);

		pPos++;
		}

	//	Done

	return CString::CreateFromHandoff(Output);
	}
Пример #4
0
CString CAeonInterface::FilespecToFilePath (const CString &sFilespec)

//	FilespecToFilePath
//
//	Converts a filespec to an Aeon filePath. We convert \ to / and escape all
//	characters that are not valid Aeon path characters.

	{
	char *pPos = sFilespec.GetParsePointer();
	char *pEndPos = pPos + sFilespec.GetLength();
	CStringBuffer Output;

	while (pPos < pEndPos)
		{
		if (*pPos == '\\')
			Output.Write("/", 1);
		else if (!strIsASCIIAlpha(pPos)				//	alpha
				&& !strIsDigit(pPos)				//	numbers
				&& *pPos != '-'
				&& *pPos != '_'
				&& *pPos != '.'
				&& *pPos != '~'
				&& !strIsASCIIHigh(pPos))			//	unicode characters
			{
			CString sChar = strPattern("_%x_", (DWORD)(BYTE)*pPos);
			Output.Write(sChar);
			}
		else
			Output.Write(pPos, 1);

		pPos++;
		}

	//	Done

	return CString::CreateFromHandoff(Output);
	}
Пример #5
0
CDatum::Types CDatum::GetStringValueType (const CString &sValue)

//	GetStringValueType
//
//	Returns one of the following:
//
//	typeNil if sValue is empty
//	typeInteger32 if sValue is a 32-bit integer
//	typeIntegerIP if sValue is an integer (which may or may not be > 64-bits)
//	typeDouble if sValue is a double
//	typeString otherwise.

	{
	enum EStates
		{
		stateStart,
		stateHex0,
		stateHex,
		stateInteger,
		stateDoubleFrac,
		stateDoubleExp,
		stateDoubleExpSign,
		};

	char *pPos = sValue.GetParsePointer();
	char *pPosEnd = pPos + sValue.GetLength();
	int iState = stateStart;

	while (pPos < pPosEnd)
		{
		switch (iState)
			{
			case stateStart:
				{
				//	If 0 then we might be a hex number

				if (*pPos == '0')
					iState = stateHex0;

				//	If -, +, or a digit, we might be an integer

				else if (*pPos == '-' || *pPos == '+' || strIsDigit(pPos))
					iState = stateInteger;

				//	If . then we might be a double

				else if (*pPos == '.')
					iState = stateDoubleFrac;

				//	Otherwise, we are a string

				else
					return typeString;

				break;
				}

			case stateHex0:
				{
				if (*pPos == 'x' || *pPos == 'X')
					iState = stateHex;
				else if (strIsDigit(pPos))
					iState = stateInteger;
				else if (*pPos == '.')
					iState = stateDoubleFrac;
				else if (*pPos == 'e' || *pPos == 'E')
					iState = stateDoubleExp;
				else
					return typeString;

				break;
				}

			case stateHex:
				{
				if (strIsDigit(pPos)
						|| (*pPos >= 'A' && *pPos <= 'F')
						|| (*pPos >= 'a' && *pPos <= 'f'))
					NULL;
				else
					return typeString;

				break;
				}

			case stateInteger:
				{
				if (strIsDigit(pPos))
					NULL;
				else if (*pPos == '.')
					iState = stateDoubleFrac;
				else if (*pPos == 'e' || *pPos == 'E')
					iState = stateDoubleExp;
				else
					return typeString;

				break;
				}

			case stateDoubleFrac:
				{
				if (strIsDigit(pPos))
					NULL;
				else if (*pPos == 'e' || *pPos == 'E')
					iState = stateDoubleExp;
				else
					return typeString;

				break;
				}

			case stateDoubleExp:
				{
				if (*pPos == '+' || *pPos == '-' || strIsDigit(pPos))
					iState = stateDoubleExpSign;
				else
					return typeString;

				break;
				}

			case stateDoubleExpSign:
				{
				if (strIsDigit(pPos))
					NULL;
				else
					return typeString;

				break;
				}
			}

		pPos++;
		}

	switch (iState)
		{
		case stateStart:
			return typeNil;

		case stateHex:
			//	LATER:
			return typeString;

		case stateInteger:
			if (strOverflowsInteger32(sValue))
				return typeIntegerIP;
			else
				return typeInteger32;

		case stateDoubleFrac:
		case stateDoubleExpSign:
			return typeDouble;

		default:
			return typeString;
		}
	}