Esempio n. 1
0
bool parseRange(TNum & beginPos, TNum & endPos, seqan::CharString const & rangeStr)
{
    seqan::DirectionIterator<seqan::CharString const, seqan::Input>::Type reader = directionIterator(rangeStr, seqan::Input());

    // Parse out begin position.
    seqan::CharString buffer;
    readUntil(buffer, reader, seqan::EqualsChar<'-'>(), seqan::EqualsChar<','>());
    if (!lexicalCast(beginPos, buffer))
        return false;

    if (atEnd(reader))
        return false;

    skipOne(reader);    // Skip '-'.

    // Parse out end position.
    clear(buffer);
    readUntil(buffer, reader, seqan::False(), seqan::EqualsChar<','>());

    if (empty(buffer))
    {
        endPos = seqan::maxValue<TNum>();
        return true;
    }

    if (!lexicalCast(endPos, buffer))
        return false;

    return (beginPos <= endPos);
}
Esempio n. 2
0
File: xml.c Progetto: jac8b/libcubic
bool extractAttributes(char **ptr, Attribute *a)
{
	// Find attribute name.
	{
		skipSpace(ptr);
		a->name = *ptr;

		findSpaceOrChar(ptr, '=');
		
		if (**ptr == '\0')
			return false;

		**ptr = '\0';
		++(*ptr);
	}
	
	// Find attribute value.
	{
		findCharAOrB(ptr, '\'', '\"');
		const char quot = **ptr;
		
		skipOne(ptr);
		a->value = *ptr;
		
		findChar(ptr, quot);
		
		if (**ptr == '\0')
			return false;
		
		**ptr = '\0';
		++(*ptr);
	}
	
	return true;
}
Esempio n. 3
0
void KateSearch::replaceSlot() {
  switch( (Dialog_results)replacePrompt->result() ) {
  case srCancel: replacePrompt->hide();                break;
  case srAll:    replacePrompt->hide(); replaceAll();  break;
  case srYes:    replaceOne(); promptReplace();        break;
  case srLast:   replacePrompt->hide(), replaceOne();  break;
  case srNo:     skipOne();    promptReplace();        break;
  }
}
Esempio n. 4
0
File: xml.c Progetto: jac8b/libcubic
bool extractElement(char **ptr, Element *e)
{
	// Find element name start.
	{
		do {
			findChar(ptr, '<');
			skipOne(ptr);
		} while (**ptr == '!' || **ptr == '?'); // Skip declarations, doctypes, comments.
		e->name = *ptr;
	}
	
	// Find element name stop, and determine if there are no attributes or no value.
	{
		findSpaceOrCharAOrB(ptr, '/', '>');
		char *nameStop = *ptr;
		switch (**ptr) {
		case '/': // No attributes, no value.
			e->value = EMPTY_STRING;
			findChar(ptr, '>');
		case '>': // No attributes.
			e->attributes = EMPTY_STRING;
		default:
			*nameStop = '\0';
			break;
		case '\0':
			return false;
		}
		++(*ptr);
	}

	// Find attributes, if any.
	if (e->attributes == NULL) {
		skipSpace(ptr);
		e->attributes = *ptr;

		findCharAOrB(ptr, '/', '>');
		if (**ptr == '/') {
			e->value = EMPTY_STRING;
			**ptr = '\0';
			findChar(ptr, '>');
		} else if (**ptr == '\0')
			return false;
		else
			**ptr = '\0';
		++(*ptr);
	}
	
	// Find value, if exists.
	if (e->value == NULL) {
		e->value = *ptr;

		// Skip through child elements.
		int level = 0;
		while (true) {
			findChar(ptr, '<');
			skipOne(ptr);

			if (**ptr == '/') {
				if (--level == -1) {
					--(*ptr);
					break;
				}
				findChar(ptr, '>');
				continue;
			}
			
			findCharAOrB(ptr, '/', '>');
			if (**ptr == '/')
				findChar(ptr, '>');
			else if (**ptr == '\0')
				return false;
			else
				level++;
		}
		**ptr = '\0';
		++(*ptr);
	}
	
	return true;
}