Exemplo n.º 1
0
char *JoinUtf(const char *path, const char *fileName, Allocator *allocator)
{
    if (IsSep(*fileName))
        fileName++;
    char *sepStr = NULL;
    if (!IsSep(path[str::Len(path) - 1]))
        sepStr = "\\";
    return str::Join(path, sepStr, fileName, allocator);
}
Exemplo n.º 2
0
WCHAR *Join(const WCHAR *path, const WCHAR *fileName)
{
    if (IsSep(*fileName))
        fileName++;
    WCHAR *sepStr = NULL;
    if (!IsSep(path[str::Len(path) - 1]))
        sepStr = L"\\";
    return str::Join(path, sepStr, fileName);
}
Exemplo n.º 3
0
// Note: returns pointer inside <path>, do not free
const WCHAR *GetBaseName(const WCHAR *path)
{
    const WCHAR *fileBaseName = path + str::Len(path);
    for (; fileBaseName > path; fileBaseName--)
        if (IsSep(fileBaseName[-1]))
            break;
    return fileBaseName;
}
Exemplo n.º 4
0
// Note: returns pointer inside <path>, do not free
const WCHAR *GetExt(const WCHAR *path)
{
    const WCHAR *ext = path + str::Len(path);
    for (; ext > path && !IsSep(*ext); ext--) {
        if (*ext == '.')
            return ext;
    }
    return path + str::Len(path);
}
Exemplo n.º 5
0
// Note: returns pointer inside <path>, do not free
const char *GetBaseName(const char *path)
{
    const char *fileBaseName = path + str::Len(path);
    for (; fileBaseName > path; fileBaseName--) {
        if (IsSep(fileBaseName[-1]))
            break;
    }
    return fileBaseName;
}
Exemplo n.º 6
0
int String::Chop(StringArray &ar,TCHAR cSep,bool bObserveStrings/*=TRUE*/) const
{
  assert('\0'!=cSep);
#define IsSep(c) (cSep==_TCHAR(' ')?_istspace(c):c==cSep)
  LPCTSTR c=c_str();
  ar.clear();
  while(*c){
    // Spaces are slightly different from other separators - we treat multiple instances as
    // just one (a la sscanf)
    if(_istspace(cSep)){
      while(IsSep(*c))c++;
    } else if (ar.size()>0) {
      c++;
    }
    if(*c){
      String strTok;
      if(bObserveStrings){
        bool bInString=false;
        do{
          if(*c==_TCHAR('\\') && c[1]){
            strTok+=c[1];
            c++;
          } else if(*c==_TCHAR('"')){
            bInString ^= 1;
          } else if (!bInString && IsSep(*c)) {
            break;
          } else {
            strTok+=*c;
          }
        } while (*++c);
      } else {
        do {
          if(IsSep(*c)) {
            break;
          } else {
            strTok+=*c;
          }
        } while (*++c);
      }
      ar.push_back(strTok);
    }
  }
  return ar.size();
}
Exemplo n.º 7
0
TokenType ReadStringConst(istream& is, string& str, Coordinates& xy)
{
	char c;
	bool eos = false;
	c = str[0];
	str = "";
	while (!is.eof())
	{
		switch (c){
			case '\'' :
				while (!is.eof() && !eos)
				{
					c = is.peek();
					if (c == '\n')
						throw Error("wrong string literal", pos.first, pos.second);
					if (c == '\'')
					{
						GetSymb(is,xy);
						if (is.peek() != '\'')
							eos = true;
					}
					if (!eos)
					{
						str = str + c;
						GetSymb(is,xy);
					}
				}
				eos = false;
				break;
			case '#':
				{
					int symb = -1;
					c = is.peek();
					if (GetState(c) != is_digit)
					    throw Error("wrong string literal", pos.first, pos.second);
					is>>symb;
					if (symb < 0 || symb > 255)
					    throw Error("wrong string literal", pos.first, pos.second);
					char ch = symb;
					str = str + ch;
					break;
				}
			default : 
				{
					str = '\'' + str + '\'';
					return string_const;
				}
		}
		c = is.peek();
		if ((!IsSep(c) && c != ' ') || c == '\'')
			GetSymb(is,xy);
	}
	str = '\'' + str + '\'';
	return string_const;
}
Exemplo n.º 8
0
TokenType ReadOctNumber(istream& is, string& str, Coordinates& xy)
{
	State st;
	char c;
	while (!is.eof())
	{
		st = GetState(is.peek());
		if (IsSyntaxError(st))
		    throw Error("syntax error", pos.first, pos.second);
		if (IsOctDigit(is.peek()))
			str = str + GetSymb(is,xy);
		else
		{
			c = GetSymb(is,xy);
			if (!IsSep(c) && c != '\n' && c != EOF)
				throw Error("wrong oct number", pos.first, pos.second);
			return int_const_oct;
		}
	}
	return int_const_hex;
}