예제 #1
0
void GUITable::setTextList(const std::vector<std::string> &content,
		bool transparent)
{
	clear();

	if (transparent) {
		m_background.setAlpha(0);
		m_border = false;
	}

	m_is_textlist = true;

	s32 empty_string_index = allocString("");

	m_rows.resize(content.size());
	for (s32 i = 0; i < (s32) content.size(); ++i) {
		Row *row = &m_rows[i];
		row->cells = new Cell[1];
		row->cellcount = 1;
		row->indent = 0;
		row->visible_index = i;
		m_visible_rows.push_back(i);

		Cell *cell = row->cells;
		cell->xmin = 0;
		cell->xmax = 0x7fff;  // something large enough
		cell->xpos = 6;
		cell->content_type = COLUMN_TYPE_TEXT;
		cell->content_index = empty_string_index;
		cell->tooltip_index = empty_string_index;
		cell->color.set(255, 255, 255, 255);
		cell->color_defined = false;
		cell->reported_column = 1;

		// parse row content (color)
		const std::string &s = content[i];
		if (s[0] == '#' && s[1] == '#') {
			// double # to escape
			cell->content_index = allocString(s.substr(2));
		}
		else if (s[0] == '#' && s.size() >= 7 &&
				parseColorString(
					s.substr(0,7), cell->color, false)) {
			// single # for color
			cell->color_defined = true;
			cell->content_index = allocString(s.substr(7));
		}
		else {
			// no #, just text
			cell->content_index = allocString(s);
		}

	}

	allocationComplete();

	// Clamp scroll bar position
	updateScrollBar();
}
예제 #2
0
CzString& CzString::operator+=	(char chr)
{
	int len1 = getLength();
	int	len2 = 1;

	if (Data == NULL)
	{
		allocString(len1 + len2);
		*Data = chr;
	}
	else
	{
		if ((len1 + len2) >= Size)
			reallocString(len1 + len2);

		*(Data + len1) = chr;
		Data[len1 + len2] = 0;
	}

	Length = len1 + len2;

	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
	
	return *this;
}
예제 #3
0
CzString& CzString::operator+= (const char *op)
{
	if (op == NULL)
		return *this;

	int len1 = getLength();
	int	len2 = (int)strlen(op);

	if (Data == NULL)
	{
		allocString(len1 + len2);
		memcpy(Data, op, len2 + 1);
	}
	else
	{
		if ((len1 + len2) >= Size)
			reallocString(len1 + len2);

		memcpy(Data + len1, op, len2);
		Data[len1 + len2] = 0;
	}
	Length = len1 + len2;

	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
	
	return *this;
}
예제 #4
0
CIwGameString& CIwGameString::operator+= (const CIwGameString &op)
{
	int len1 = GetLength();
	int	len2 = op.GetLength();

	if (Data == NULL)
	{
		allocString(len1 + len2);
		strcpy(Data, op.c_str());
	}
	else
	{
		if ((len1 + len2) >= Size)
			reallocString(len1 + len2);

		memcpy(Data + len1, op.c_str(), len2);
		Data[len1 + len2] = 0;
	}
	Length = len1 + len2;

	if (AutoHash)
		DataHash = IwHashString(Data);

	return *this;
}
예제 #5
0
CIwGameString& CIwGameString::operator+= (const char *op)
{
	if (op == NULL)
		return *this;

	int len1 = GetLength();
	int	len2 = (int)strlen(op);

	if (Data == NULL)
	{
		allocString(len1 + len2);
		strcpy(Data, op);
	}
	else
	{
		if ((len1 + len2) >= Size)
			reallocString(len1 + len2);

		memcpy(Data + len1, op, len2);
		Data[len1 + len2] = 0;
	}
	Length = len1 + len2;

	if (AutoHash)
		DataHash = IwHashString(Data);
	
	return *this;
}
예제 #6
0
CIwGameString& CIwGameString::operator+=	(int nNum)
{
	char str[32];
	snprintf(str, 32, "%d", nNum);

	int len1 = GetLength();
	int	len2 = (int)strlen(str);

	if (Data == NULL)
	{
		allocString(len1 + len2);
		strcpy(Data, str);
	}
	else
	{
		if ((len1 + len2) >= Size)
			reallocString(len1 + len2);

		memcpy(Data + len1, str, len2);
		Data[len1 + len2] = 0;
	}

	Length = len1 + len2;

	if (AutoHash)
		DataHash = IwHashString(Data);
	
	return *this;
}
예제 #7
0
CzString& CzString::operator+=	(float v)
{
	char str[64];
	snprintf(str, 64, "%f", v);

	int len1 = getLength();
	int	len2 = (int)strlen(str);

	if (Data == NULL)
	{
		allocString(len1 + len2);
		memcpy(Data, str, len2 + 1);
	}
	else
	{
		if ((len1 + len2) >= Size)
			reallocString(len1 + len2);

		memcpy(Data + len1, str, len2);
		Data[len1 + len2] = 0;
	}

	Length = len1 + len2;

	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
	
	return *this;
}
예제 #8
0
void SimpleString::replace(const char* to, const char* with)
{
    int c = count(to);
    int len = size();
    int tolen = PlatformSpecificStrLen(to);
    int withlen = PlatformSpecificStrLen(with);

    int newsize = len + (withlen * c) - (tolen * c) + 1;

    if (newsize) {
        char* newbuf = allocString(newsize);
        for (int i = 0, j = 0; i < len;) {
            if (PlatformSpecificStrNCmp(&buffer[i], to, tolen) == 0) {
                PlatformSpecificStrNCpy(&newbuf[j], with, withlen);
                j += withlen;
                i += tolen;
            }
            else {
                newbuf[j] = buffer[i];
                j++;
                i++;
            }
        }
        deallocString(buffer);
        buffer = newbuf;
        buffer[newsize-1] = '\0';
    }
    else {
        buffer = getEmptryString();
        buffer [0] = '\0';
    }
}
예제 #9
0
CIwGameString& CIwGameString::operator=	(const char *op)
{
	Length = (int)strlen(op);

	if (Data == NULL)
	{
		allocString(Length);
	}
	else
	{
		if (Length >= Size)
			reallocString(Length);
	}

	if (op == NULL)
	{
		Data[0] = 0;
		return *this;
	}
	strcpy(Data, op);

	if (AutoHash)
		DataHash = IwHashString(Data);

	return *this;
}
예제 #10
0
void
exToHt(char *filename)
{
    char line[MaxLineLength], *line2;
    char *title, *pagename;
    FILE *inFile = fopen(filename, "r");
    FILE *outFile;
    int len, i;
    struct timeval  tvp;
    struct stat buf;

    if (inFile == NULL) {
        fprintf(stderr, "couldn't open %s for reading.\n", filename);
        return;
    }
    strcpy(line, "Menu");
    strcat(line, filename);
    len = strlen(line);
    for (i = 0; i < len; i++)
        if (line[i] == '.') {
            line[i] = '\0';
            break;
        }
    outFile = fopen(line, "w");
    if (outFile == NULL) {
        fprintf(stderr, "couldn't open %s for writing.\n", line);
        return;
    }
    pagename = allocString(line);
    title = getExTitle(inFile, line);
    if (title == NULL) {
        return;
    }
    files[numFiles++] = pagename;
    emitCoverLink(pagename, title);
    emitHeader(outFile, pagename, title);
    while (fgets(line, MaxLineLength, inFile) != NULL) {
        if ((line2 = strPrefix("\\begin{page}{", line)))
            emitMenuEntry(line2, outFile);
        else if ((line2 = strPrefix("\\spadcommand{", line)))
            emitSpadCommand(line2, "\\spadcommand{", outFile);
        else if ((line2 = strPrefix("\\spadpaste{", line)))
            emitSpadCommand(line2, "\\spadpaste{", outFile);
        else if ((line2 = strPrefix("\\example{", line)))
            emitSpadCommand(line2, "\\example{", outFile);
        else if ((line2 = strPrefix("\\graphpaste{", line)))
            emitSpadCommand(line2, "\\graphpaste{", outFile);
    }
    emitFooter(outFile);
    fclose(inFile);
    fclose(outFile);
    stat(filename,&buf);
    tvp.tv_sec =buf.st_mtime;
    tvp.tv_usec =0;
    if timercmp(&tvp,&latest_date[1],>){
        latest_date[1].tv_sec=buf.st_mtime;
        }
}
예제 #11
0
SimpleString& SimpleString::operator=(const SimpleString& other)
{
	if (this != &other) {
		deallocString(buffer);
		int len = other.size() + 1;
		buffer = allocString(len);
		PlatformSpecificStrCpy(buffer, other.buffer);
	}
	return *this;
}
예제 #12
0
char *prependString(char *s, const char *p)
{
	int slen = strlen(s);
	int plen = strlen(p);
	char *t = allocString(slen + plen + 1);
	strcpy(t, p);
	strcpy(t + plen, s);
	nzFree(s);
	return t;
}				/* prependstring */
예제 #13
0
SimpleString& SimpleString::operator+=(const char* rhs)
{
    int len = this->size() + PlatformSpecificStrLen(rhs) + 1;
    char* tbuffer = allocString(len);
    PlatformSpecificStrCpy(tbuffer, this->buffer);
    PlatformSpecificStrCat(tbuffer, rhs);
    deallocString(buffer);
    buffer = tbuffer;
    return *this;
}
예제 #14
0
void CzString::Copy(const char* pString, int start, int count)
{
	allocString(count);
	memcpy(Data, pString + start, count);
	Length = count;
	Data[count] = 0;
	FindIndex = 0;
	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
}
예제 #15
0
SimpleString::SimpleString (const char *otherBuffer)
{
    if (otherBuffer == 0) {
        buffer = getEmptryString();
    }
    else {
        int len = PlatformSpecificStrLen (otherBuffer) + 1;
        buffer = allocString(len);
        PlatformSpecificStrCpy (buffer, otherBuffer);
    }
}
예제 #16
0
 void String::setString(const char * aString)
 {
     int newSize = stringLength(aString);
     deallocString(m_Characters);
     m_Characters = allocString(newSize + 1); //+ 1 for null terminator
     m_Length = newSize;
     for(int i = 0; i < m_Length; i++)
     {
         m_Characters[i] = aString[i];
     }
     m_Characters[m_Length] = '\0';
 }
예제 #17
0
SimpleString::SimpleString(const char *other, int repeatCount)
{
	int len = PlatformSpecificStrLen(other) * repeatCount + 1;
	buffer = allocString(len);
	char* next = buffer;
	for (int i = 0; i < repeatCount; i++) {
		PlatformSpecificStrCpy(next, other);
		next += PlatformSpecificStrLen(other);
	}
	*next = 0;

}
예제 #18
0
 void String::setString(String & aString)
 {
     int newSize = stringLength(aString);
     deallocString(m_Characters);
     m_Characters = allocString(newSize + 1);
     m_Length = newSize;
     for(int i = 0; i < m_Length; i++)
     {
         m_Characters[i] = aString[i];
     }
     m_Characters[m_Length] = '\0';
 }
예제 #19
0
tChyba DOPREDNE() {
	int ret;
	TItem *nasel;
	//DOPREDNE->forward
	if(!strcmp(token.data, "forward") && token.stav == s_klicove) {			
		//neinicializovana pokud se jedna o doprednou deklaraci
		init = false;						
		token = getNextToken();
		if(token.stav == s_lex_error) {
			return S_LEXIKALNI_CHYBA;
		}
		return S_BEZ_CHYB;
	}
	//DOPREDNE->ACT_LIST
	else {
		//initla, pokud se nejedna o doprednou
		init = true;
		// check velikost tabulky
		if( currFuncSize == funcSize ){
			ret = resizeFuncField();
			if(ret != S_BEZ_CHYB) {
				return ret;
			}
		}	

		
		//nastaveni klice funkce
		func[currFuncSize].key = allocString(funkce);

		//inicializace tabulky
		ret = htInit(&func[currFuncSize].table );
		if(ret != S_BEZ_CHYB) {
			return ret;
		}
		//vytovreni listu instrukci
		InitList( &(func[currFuncSize].instrList) );
		//nastaveni ukazatele na prave vytvoreny list instrukci
		listIntrukci = &(func[currFuncSize].instrList);
		//nastaveni ukazatele na aktualni tabulku symbolu
		ptrhtLocal = func[currFuncSize].table;
		//inkrementace indexu 
		currFuncSize++;
		
		nasel = htSearch(ptrhtGlobal, funkce);		
		if(nasel != NULL) {
			//nakopirovani parametru do lokalniho ramce
			for(int i=0; i < nasel->data->param.numParam; i++) {
				htDeclInsert(ptrhtLocal, nasel->data->param.param[i], nasel->data->param.typeParam[i], ID_PARAM);	
			}
		}	
		return ACT_LIST();
	}
}
예제 #20
0
 void String::appendChar(char aChar)
 {
     int bufferSize = 1 + m_Length;
     char * newString = allocString(bufferSize + 1);
     for(int i = 0; i < m_Length; i++)
     {
         newString[i] = m_Characters[i];
     }
     newString[m_Length] = aChar;
     deallocString(m_Characters);
     m_Characters = newString;
     m_Length = bufferSize;
     m_Characters[m_Length] = '\0';
 }
예제 #21
0
파일: pl-alloc.c 프로젝트: brayc0/nlfetdb
word
globalWString(size_t len, const pl_wchar_t *s)
{ GET_LD
  const pl_wchar_t *e = &s[len];
  const pl_wchar_t *p;
  Word g;

  for(p=s; p<e; p++)
  { if ( *p > 0xff )
      break;
  }

  if ( p == e )				/* 8-bit string */
  { unsigned char *t;

    if ( !(g = allocString(len+1 PASS_LD)) )
      return 0;
    t = (unsigned char *)&g[1];
    *t++ = 'B';
    for(p=s; p<e; )
      *t++ = *p++ & 0xff;
  } else				/* wide string */
  { char *t;
    pl_wchar_t *w;

    if ( !(g = allocString((len+1)*sizeof(pl_wchar_t) PASS_LD)) )
      return 0;
    t = (char *)&g[1];
    w = (pl_wchar_t*)t;
    w[0] = 0;
    *t = 'W';
    memcpy(&w[1], s, len*sizeof(pl_wchar_t));
  }

  return consPtr(g, TAG_STRING|STG_GLOBAL);
}
예제 #22
0
CzString& CzString::operator=	(char chr)
{
	FindIndex = 0;

	allocString(2);

	*Data = chr;
	*(Data + 1) = 0;
	Length = 1;

	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
	
	return *this;
}
예제 #23
0
static uint16_t
getTagNumber(const char *tag, uint16_t tagLen) {
    char *atag;
    uint16_t t;
    UBool preferredName = ((tagLen > 0) ? (tag[tagLen - 1] == '*') : (FALSE));

    if (tagCount >= MAX_TAG_COUNT) {
        fprintf(stderr, "%s:%d: too many tags\n", path, lineNum);
        exit(U_BUFFER_OVERFLOW_ERROR);
    }

    if (preferredName) {
/*        puts(tag);*/
        tagLen--;
    }

    for (t = 0; t < tagCount; ++t) {
        const char *currTag = GET_TAG_STR(tags[t].tag);
        if (uprv_strlen(currTag) == tagLen && !uprv_strnicmp(currTag, tag, tagLen)) {
            return t;
        }
    }

    /* we need to add this tag */
    if (tagCount >= MAX_TAG_COUNT) {
        fprintf(stderr, "%s:%d: error: too many tags\n", path, lineNum);
        exit(U_BUFFER_OVERFLOW_ERROR);
    }

    /* allocate a new entry in the tag table */
    atag = allocString(&tagBlock, tag, tagLen);

    if (standardTagsUsed) {
        fprintf(stderr, "%s:%d: error: Tag \"%s\" is not declared at the beginning of the alias table.\n",
            path, lineNum, atag);
        exit(1);
    }
    else if (tagLen > 0 && strcmp(tag, ALL_TAG_STR) != 0) {
        fprintf(stderr, "%s:%d: warning: Tag \"%s\" was added to the list of standards because it was not declared at beginning of the alias table.\n",
            path, lineNum, atag);
    }

    /* add the tag to the tag table */
    tags[tagCount].tag = GET_TAG_NUM(atag);
    /* The aliasList should be set to 0's already */

    return tagCount++;
}
예제 #24
0
/* 
	Description- parses a line, and exit when setect error.
	GET-
		line: struct that whlie hold info about this line.
		lineStr: the line that we parse.
		lineNum: line number in the file.
		(IC, DC). 
*/
bool parseLine(lineInfo *line, char *lineStr, int lineNum, int *IC, int *DC)
{
	char *startOfNextPart = lineStr;

	line->lineNum = lineNum;
	line->address = FIRST_ADDRESS + *IC;
	line->originalString = allocString(lineStr);
	line->lineStr = line->originalString;
	line->label = NULL;
	line->commandStr = NULL;
	line->cmd = NULL;

	if (!line->originalString)
	{
		printf("ERR:\tNot enough memory - malloc falied.\n");
		return TRUE;
	}

	/* Check if the line is a comment */
	if (isCommentOrEmpty(line))
	{	
		return FALSE;
	}

	/* Find label and add it to the label list */
	startOfNextPart = findLabel(line, *IC);

	/* Update the line if startOfNextPart isn't NULL */
	if (startOfNextPart)
	{
		line->lineStr = startOfNextPart;
	}

	/* Find the command token */
	line->commandStr = getFirstTok(line->lineStr, &startOfNextPart);
	line->lineStr = startOfNextPart;
	/* Parse the command / directive */
	if (isDirective(line->commandStr))
	{
		line->commandStr++; /* Remove the '.' from the command */
		parseDirective(line, IC, DC);
	}
	else
	{
		parseCommand(line, IC, DC);
	}
	return TRUE;
}
예제 #25
0
파일: pl-alloc.c 프로젝트: brayc0/nlfetdb
word
globalString(size_t len, const char *s)
{ GET_LD
  Word p = allocString(len+1 PASS_LD);

  if ( p )
  { char *q = (char *)&p[1];

    *q++ = 'B';
    memcpy(q, s, len);

    return consPtr(p, TAG_STRING|STG_GLOBAL);
  }

  return 0;
}
예제 #26
0
void CzString::set(float v)
{
	FindIndex = 0;
	char str[64];
	snprintf(str, 64, "%f", v);

	int len = (int)strlen(str);

	allocString(len);
	Length = len;

	memcpy(Data, str, Length + 1);

	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
}
예제 #27
0
CIwGameString::CIwGameString(int nNum)
{
	FindIndex = 0;
	Data = NULL;
	AutoHash = true;
	char str[32];
	snprintf(str, 32, "%d", nNum);

	int len = (int)strlen(str);
	allocString(len);
	Length = len;

	strcpy(Data, str);

	if (AutoHash)
		DataHash = IwHashString(Data);
}
예제 #28
0
void CzString::setString(const char *str)
{
	FindIndex = 0;
	if (str == NULL)
	{
		free(Data);
		Size = 0;
		Length = 0;
		return;
	}
	int len = strlen(str);
	allocString(len);
	memcpy(Data, str, len + 1);
	Length = len;
	if (AutoHash)
		DataHash = CzString::CalculateHash(Data);
}
예제 #29
0
void CIwGameString::setString(const char *str)
{
	if (str == NULL)
	{
		if (Data != NULL)
			delete Data;
		Data = NULL;
		Size = 0;
		Length = 0;
		return;
	}
	int len = strlen(str);
	allocString(len);
	strcpy(Data, str);
	Length = len;
	if (AutoHash)
		DataHash = IwHashString(Data);
}
예제 #30
0
void CIwGameString::setString(const char *str, int len)
{
	if (str == NULL)
	{
		if (Data != NULL)
			delete Data;
		Data = NULL;
		Size = 0;
		Length = 0;
		return;
	}
	allocString(len);
	memcpy(Data, str, len);
	Data[len] = 0;
	Length = len;
	if (AutoHash)
		DataHash = IwHashString(Data);
}