Exemple #1
0
QString SchemaParser::getCodeDefinition(const QString &filename, map<QString,QString> &attributes)
{
	QString object_def;

	if(filename!="")
	{
		unsigned end_cnt, if_cnt;
		int if_level, prev_if_level;
		QString atrib, cond, prev_cond, word, meta, str_aux;
		bool error, if_attrib;
		char chr;
		vector<bool> vet_expif, vet_tk_if, vet_tk_then, vet_tk_else;
		map<int, vector<QString> > if_map, else_map;
		vector<QString>::iterator itr, itr_end;
		vector<int> vet_prev_level;
		vector<QString> *vet_aux;

		SchemaParser::filename=filename;
		loadFile(filename);

		//In case the file was successfuly loaded
		if(buffer.size() > 0)
		{
			//Init the control variables
			error=if_attrib=false;
			if_level=-1;
			end_cnt=if_cnt=0;

			while(line < buffer.size())
			{
				chr=buffer[line][column].toAscii();
				switch(chr)
				{
					/* Increments the number of rows causing the parser
			 to get the next line buffer for analysis */
					case CHR_LINE_END:
						line++;
						column=0;
					break;

					case CHR_SPACE:
						//The parser will ignore the spaces that are not within pure texts
						while(buffer[line][column]==CHR_SPACE) column++;
					break;

						//Metacharacter extraction
					case CHR_INI_METACHAR:
						meta=getMetaCharacter();

						//Checks whether the extracted token is valid metacharacter
						if(meta!=TOKEN_META_SP && meta!=TOKEN_META_TB &&
							 meta!=TOKEN_META_BR)
						{
							str_aux=QString(Exception::getErrorMessage(ERR_INV_METACHARACTER))
											.arg(meta).arg(filename).arg(line + comment_count +1).arg(column+1);


							throw Exception(str_aux,ERR_INV_METACHARACTER,__PRETTY_FUNCTION__,__FILE__,__LINE__);
						}
						//Checks whether the metacharacter is part of the  'if' expression (this is an error)
						else if(if_level>=0 && vet_tk_if[if_level] && !vet_tk_then[if_level])
						{
							str_aux=QString(Exception::getErrorMessage(ERR_INVALID_SYNTAX))
											.arg(filename).arg(line + comment_count +1).arg(column+1);

							throw Exception(str_aux,ERR_INVALID_SYNTAX,__PRETTY_FUNCTION__,__FILE__,__LINE__);
						}
						else
						{
							//Converting the metacharacter drawn to the character that represents this
							if(meta==TOKEN_META_SP) chr=CHR_SPACE;
							else if(meta==TOKEN_META_TB) chr=CHR_TABULATION;
							else chr=CHR_LINE_END;

							meta="";
							meta+=chr;

							//If the parser is inside an 'if / else' extracting tokens
							if(if_level>=0)
							{
								/* If the parser is in 'if' section,
									 places the metacharacter on the word map of the current 'if' */
								if(vet_tk_if[if_level] &&
									 vet_tk_then[if_level] &&
									 !vet_tk_else[if_level])
									if_map[if_level].push_back(meta);

								/* If the parser is in 'else' section,
									 places the metacharacter on the word map of the current 'else'*/
								else if(vet_tk_else[if_level])
									else_map[if_level].push_back(meta);
							}
							else
								/* If the parsers is not in a 'if / else', puts the metacharacter
									 in the definition sql */
								object_def+=meta;
						}

					break;

						//Attribute extraction
					case CHR_INI_ATTRIB:
					case CHR_MID_ATTRIB:
					case CHR_END_ATTRIB:
						atrib=getAttribute();

						//Checks if the attribute extracted belongs to the passed list of attributes
						if(attributes.count(atrib)==0)
						{
							if(!ignore_unk_atribs)
							{
								str_aux=QString(Exception::getErrorMessage(ERR_UNK_ATTRIBUTE))
												.arg(atrib).arg(filename).arg((line + comment_count +1)).arg((column+1));
								throw Exception(str_aux,ERR_UNK_ATTRIBUTE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
							}
							else
								attributes[atrib]="";
						}

						//If the parser is inside an 'if / else' extracting tokens
						if(if_level>=0)
						{
							/* If the parser is in the 'if' part of the expression but not yet
								extracted the attribute */
							if(!if_attrib && vet_tk_if[if_level] && !vet_tk_then[if_level])
							{
								//Mark the flag indicating that an attribute of the if / then has been extracted
								if_attrib=true;

								//Checks if the attribute value is empty. If not evaluates as true the conditional expression
								vet_expif.push_back((attributes[atrib]!=""));
							}

							/* If the parser is in the part of the 'if' expression and yet
								extracted the attribute, returns an error because only one attribute
								may appear if expression */
							else if(if_attrib && vet_tk_if[if_level] && !vet_tk_then[if_level])
							{
								str_aux=QString(Exception::getErrorMessage(ERR_INVALID_SYNTAX))
												.arg(filename).arg(line + comment_count +1).arg(column+1);

								throw Exception(str_aux,ERR_INVALID_SYNTAX,__PRETTY_FUNCTION__,__FILE__,__LINE__);
							}
							else
							{
								word=atrib;
								atrib="";
								atrib+=CHR_INI_ATTRIB;
								atrib+=CHR_MID_ATTRIB;
								atrib+=word;
								atrib+=CHR_END_ATTRIB;

								//If the parser is in the 'if' section
								if(vet_tk_if[if_level] &&
									 vet_tk_then[if_level] &&
									 !vet_tk_else[if_level])
									//Inserts the attribute value in the map of the words of current the 'if' section
									if_map[if_level].push_back(atrib);
								else if(vet_tk_else[if_level])
									//Inserts the attribute value in the map of the words of current the 'else' section
									else_map[if_level].push_back(atrib);
							}
						}
						else
						{
							if(attributes[atrib]=="")
							{
								str_aux=QString(Exception::getErrorMessage(ERR_UNDEF_ATTRIB_VALUE))
												.arg(atrib).arg(filename).arg(line + comment_count +1).arg(column+1);

								throw Exception(str_aux,ERR_UNDEF_ATTRIB_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
							}

							/* If the parser is not in an if / else, concatenates the value of the attribute
								directly in definition in sql */
							object_def+=attributes[atrib];
						}
					break;

						//Conditional instruction extraction
					case CHR_INI_CONDITIONAL:
						prev_cond=cond;
						cond=getConditional();

						//Checks whether the extracted token is a valid conditional
						if(cond!=TOKEN_IF && cond!=TOKEN_ELSE &&
							 cond!=TOKEN_THEN && cond!=TOKEN_END)
						{
							str_aux=QString(Exception::getErrorMessage(ERR_INV_CONDITIONAL))
											.arg(cond).arg(filename).arg(line + comment_count +1).arg(column+1);
							throw Exception(str_aux,ERR_INV_CONDITIONAL,__PRETTY_FUNCTION__,__FILE__,__LINE__);
						}
						else
						{
							//If the toke is an 'if'
							if(cond==TOKEN_IF)
							{
								/* Inserts the value of the current 'if' level  in the previous 'if' levels vector.
								 This vector is used to know which 'if' the parser was in before entering current if */
								vet_prev_level.push_back(if_level);

								/* Mark the flags indicating that an  'if' was found and a
								 'then' and 'else' have not been found yet */
								vet_tk_if.push_back(true);
								vet_tk_then.push_back(false);
								vet_tk_else.push_back(false);

								//Defines the current if level as the size of list 'if' tokens found  -1
								if_level=(vet_tk_if.size()-1);

								//Increases the number of found 'if's
								if_cnt++;
							}
							//If the parser is in 'if / else' and one 'then' token is found
							else if(cond==TOKEN_THEN && if_level>=0)
							{
								//Marks the then thoke flag of the current 'if'
								vet_tk_then[if_level]=true;

								/* Clears the  attribute extracted flag from the 'if - then',
									 so that the parser does not generate an error when it encounters another
									 'if - then' with an attribute still unextracted */
								if_attrib=false;
							}
							//If the parser is in 'if / else' and a 'else' token is found
							else if(cond==TOKEN_ELSE && if_level>=0)
								//Mark the  o flag do token else do if atual
								vet_tk_else[if_level]=true;
							//Case the parser is in 'if/else' and a 'end' token was found
							else if(cond==TOKEN_END && if_level>=0)
							{
								//Increments the number of 'end' tokes found
								end_cnt++;

								//Get the level of the previous 'if' where the parser was
								prev_if_level=vet_prev_level[if_level];

								//In case the current 'if' be internal (nested) (if_level > 0)
								if(if_level > 0)
								{
									//In case the current 'if' doesn't in the 'else' section of the above 'if' (previous if level)
									if(!vet_tk_else[prev_if_level])
										//Get the extracted word vector on the above 'if'
										vet_aux=&if_map[prev_if_level];
									else
										//Get the extracted word vector on the above 'else'
										vet_aux=&else_map[prev_if_level];
								}
								else
									vet_aux=NULL;

								/* Initializes the iterators to scan
									 the auxiliary vector if necessary */
								itr=itr_end=if_map[0].end();

								/* In case the expression of the current 'if' has the value true
									 then the parser will scan the list of words on the 'if' part of the
									 current 'if' */
								if(vet_expif[if_level])
								{
									itr=if_map[if_level].begin();
									itr_end=if_map[if_level].end();
								}
								/* Caso a parte else do if atual exista
									 então o parser varrerá a lista de palavras da parte else
									 do if atual */

								/* If there is a 'else' part on the current 'if'
									 then the parser will scan the list of words on the 'else' part */
								else if(else_map.count(if_level)>0)
								{
									itr=else_map[if_level].begin();
									itr_end=else_map[if_level].end();
								}

								/* This iteration scans the list of words selected above
									 inserting them in 'if' part  of the 'if' or 'else' superior to current.
									 This is done so that only the words extracted based on
									 ifs expressions of the buffer are embedded in defining sql */
								while(itr!=itr_end)
								{
									//If the auxiliary vector is allocated, inserts the word on above 'if / else'
									if(vet_aux)
										vet_aux->push_back((*itr));
									else
									{
										word=(*itr);

										//Check if the work is not an attribute
										if(word[0]==CHR_INI_ATTRIB)
										{
											/* If its an attribute, extracts the name and checks if the same
											has empty value */
											atrib=word.mid(2,word.size()-3);
											word=attributes[atrib];

											//If the attribute has no value set raises an exception
											if(word=="")
											{
												str_aux=QString(Exception::getErrorMessage(ERR_UNDEF_ATTRIB_VALUE))
																.arg(atrib).arg(filename).arg(line + comment_count +1).arg(column+1);
												throw Exception(str_aux,ERR_UNDEF_ATTRIB_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
											}
										}

										//Else, insert the work directly on the object definition
										object_def+=word;
									}
									itr++;
								}

								//Case the current if is nested (internal)
								if(if_level > 0)
									//Causes the parser to return to the earlier 'if'
									if_level=prev_if_level;

								/* In case the 'if' be the uppermost (level 0) indicates that all
									 the if's  has already been checked, so the parser will clear the
									 used auxiliary structures*/
								else
								{
									if_map.clear();
									else_map.clear();
									vet_tk_if.clear();
									vet_tk_then.clear();
									vet_tk_else.clear();
									vet_expif.clear();
									vet_prev_level.clear();

									//Resets the ifs levels
									if_level=prev_if_level=-1;
								}
							}
							else
								error=true;

							if(!error)
							{
								/* Verifying that the conditional words appear in a valid  order if not
								 the parser generates an error. Correct order means IF before THEN,
								 ELSE after IF and before END */
								if((prev_cond==TOKEN_IF && cond!=TOKEN_THEN) ||
									 (prev_cond==TOKEN_ELSE && cond!=TOKEN_IF && cond!=TOKEN_END) ||
									 (prev_cond==TOKEN_THEN && cond==TOKEN_THEN))
									error=true;
							}

							if(error)
							{
								str_aux=QString(Exception::getErrorMessage(ERR_INVALID_SYNTAX))
												.arg(filename).arg(line + comment_count +1).arg(column+1);
								throw Exception(str_aux,ERR_INVALID_SYNTAX,__PRETTY_FUNCTION__,__FILE__,__LINE__);
							}
						}
					break;

						//Extraction of pure text or simple words
					default:
						if(chr==CHR_INI_PURETEXT ||
							 chr==CHR_END_PURETEXT)
							word=getPureText();
						else
							word=getWord();

						//Case the parser is in 'if/else'
						if(if_level>=0)
						{
							/* In case the word/text be inside 'if' expression, the parser returns an error
							 because only an attribute must be on the 'if' expression  */
							if(vet_tk_if[if_level] && !vet_tk_then[if_level])
							{
								str_aux=QString(Exception::getErrorMessage(ERR_INVALID_SYNTAX))
												.arg(filename).arg(line + comment_count +1).arg(column+1);
								throw Exception(str_aux,ERR_INVALID_SYNTAX,__PRETTY_FUNCTION__,__FILE__,__LINE__);
							}
							//Case the parser is in 'if' section
							else if(vet_tk_if[if_level] &&
											vet_tk_then[if_level] &&
											!vet_tk_else[if_level])
								//Inserts the word on the words map extracted on 'if' section
								if_map[if_level].push_back(word);
							else if(vet_tk_else[if_level])
								//Inserts the word on the words map extracted on 'else' section
								else_map[if_level].push_back(word);
						}
						else
							//Case the parser is not in 'if/else' concatenates the word/text directly on the object definition
							object_def+=word;
					break;
				}
			}

			/* If has more 'if' toknes than  'end' tokens, this indicates that some 'if' in code
			was not closed thus the parser returns an error */
			if(if_cnt!=end_cnt)
			{
				str_aux=QString(Exception::getErrorMessage(ERR_INVALID_SYNTAX))
								.arg(filename).arg(line + comment_count +1).arg(column+1);
				throw Exception(str_aux,ERR_INVALID_SYNTAX,__PRETTY_FUNCTION__,__FILE__,__LINE__);
			}
		}
	}

	restartParser();
	ignore_unk_atribs=false;
	return(object_def);
}
Exemple #2
0
String SVGElement::xmlbase() const
{
    return getAttribute(XMLNames::baseAttr);
}
Exemple #3
0
KURL HTMLAnchorElement::href() const
{
    return document()->completeURL(stripLeadingAndTrailingHTMLSpaces(getAttribute(hrefAttr)));
}
double HTMLMeterElement::max() const
{
    double max = std::max(1.0, min());
    parseToDoubleForNumberType(getAttribute(maxAttr), &max);
    return std::max(max, min());
}
QString     AbstractWidgetForm::getClasses()                      const                 { return getAttribute("class");     }
double HTMLMeterElement::low() const
{
    double low = min();
    parseToDoubleForNumberType(getAttribute(lowAttr), &low);
    return std::min(std::max(low, min()), max());
}
double HTMLMeterElement::optimum() const
{
    double optimum = (max() + min()) / 2;
    parseToDoubleForNumberType(getAttribute(optimumAttr), &optimum);
    return std::min(std::max(optimum, min()), max());
}
String HTMLElement::className() const
{
    return getAttribute(classAttr);
}
String HTMLParamElement::get_name()
{
	return getAttribute(WSTR("name"));
}
Exemple #10
0
String HTMLElement::lang() const
{
    return getAttribute(langAttr);
}
Exemple #11
0
String HTMLElement::dir() const
{
    return getAttribute(dirAttr);
}
Exemple #12
0
String HTMLElement::title() const
{
    return getAttribute(titleAttr);
}
Exemple #13
0
String HTMLElement::id() const
{
    return getAttribute(idAttr);
}
Exemple #14
0
void HTMLElement::parseMappedAttribute(MappedAttribute *attr)
{
    if (attr->name() == idAttr || attr->name() == classAttr || attr->name() == styleAttr)
        return StyledElement::parseMappedAttribute(attr);

    String indexstring;
    if (attr->name() == alignAttr) {
        if (equalIgnoringCase(attr->value(), "middle"))
            addCSSProperty(attr, CSSPropertyTextAlign, "center");
        else
            addCSSProperty(attr, CSSPropertyTextAlign, attr->value());
    } else if (attr->name() == contenteditableAttr) {
        setContentEditable(attr);
    } else if (attr->name() == tabindexAttr) {
        indexstring = getAttribute(tabindexAttr);
        if (indexstring.length()) {
            bool parsedOK;
            int tabindex = indexstring.toIntStrict(&parsedOK);
            if (parsedOK)
                // Clamp tabindex to the range of 'short' to match Firefox's behavior.
                setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
        }
    } else if (attr->name() == langAttr) {
        // FIXME: Implement
    } else if (attr->name() == dirAttr) {
        addCSSProperty(attr, CSSPropertyDirection, attr->value());
        addCSSProperty(attr, CSSPropertyUnicodeBidi, hasLocalName(bdoTag) ? CSSValueBidiOverride : CSSValueEmbed);
    }
// standard events
    else if (attr->name() == onclickAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().clickEvent, attr);
    } else if (attr->name() == oncontextmenuAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().contextmenuEvent, attr);
    } else if (attr->name() == ondblclickAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dblclickEvent, attr);
    } else if (attr->name() == onmousedownAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().mousedownEvent, attr);
    } else if (attr->name() == onmousemoveAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().mousemoveEvent, attr);
    } else if (attr->name() == onmouseoutAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().mouseoutEvent, attr);
    } else if (attr->name() == onmouseoverAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().mouseoverEvent, attr);
    } else if (attr->name() == onmouseupAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().mouseupEvent, attr);
    } else if (attr->name() == onmousewheelAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().mousewheelEvent, attr);
    } else if (attr->name() == onfocusAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().focusEvent, attr);
    } else if (attr->name() == onblurAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().blurEvent, attr);
    } else if (attr->name() == onkeydownAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().keydownEvent, attr);
    } else if (attr->name() == onkeypressAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().keypressEvent, attr);
    } else if (attr->name() == onkeyupAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().keyupEvent, attr);
    } else if (attr->name() == onscrollAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().scrollEvent, attr);
    } else if (attr->name() == onbeforecutAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().beforecutEvent, attr);
    } else if (attr->name() == oncutAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().cutEvent, attr);
    } else if (attr->name() == onbeforecopyAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().beforecopyEvent, attr);
    } else if (attr->name() == oncopyAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().copyEvent, attr);
    } else if (attr->name() == onbeforepasteAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().beforepasteEvent, attr);
    } else if (attr->name() == onpasteAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().pasteEvent, attr);
    } else if (attr->name() == ondragenterAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dragenterEvent, attr);
    } else if (attr->name() == ondragoverAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dragoverEvent, attr);
    } else if (attr->name() == ondragleaveAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dragleaveEvent, attr);
    } else if (attr->name() == ondropAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dropEvent, attr);
    } else if (attr->name() == ondragstartAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dragstartEvent, attr);
    } else if (attr->name() == ondragAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dragEvent, attr);
    } else if (attr->name() == ondragendAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().dragendEvent, attr);
    } else if (attr->name() == onselectstartAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().selectstartEvent, attr);
    } else if (attr->name() == onsubmitAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().submitEvent, attr);
    } else if (attr->name() == onerrorAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().errorEvent, attr);
    } else if (attr->name() == onwebkitanimationstartAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().webkitAnimationStartEvent, attr);
    } else if (attr->name() == onwebkitanimationiterationAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().webkitAnimationIterationEvent, attr);
    } else if (attr->name() == onwebkitanimationendAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().webkitAnimationEndEvent, attr);
    } else if (attr->name() == onwebkittransitionendAttr) {
        setInlineEventListenerForTypeAndAttribute(eventNames().webkitTransitionEndEvent, attr);
    }
}
Exemple #15
0
bool SVGAnimationElement::isAccumulated() const
{
    static const AtomicString sum("sum");
    const AtomicString &value = getAttribute(SVGNames::accumulateAttr);
    return value == sum && animationMode() != ToAnimation;
}
String HTMLParamElement::get_valueType()
{
	return getAttribute(WSTR("valuetype"));
}
double HTMLMeterElement::value() const
{
    double value = 0;
    parseToDoubleForNumberType(getAttribute(valueAttr), &value);
    return std::min(std::max(value, min()), max());
}
String HTMLLegendElement::accessKey() const
{
    return getAttribute(accesskeyAttr);
}
double HTMLMeterElement::high() const
{
    double high = max();
    parseToDoubleForNumberType(getAttribute(highAttr), &high);
    return std::min(std::max(high, low()), max());
}
String HTMLLegendElement::align() const
{
    return getAttribute(alignAttr);
}
double HTMLMeterElement::min() const
{
    double min = 0;
    parseToDoubleForNumberType(getAttribute(minAttr), &min);
    return min;
}
Exemple #22
0
DOMString SVGAltGlyphElement::glyphRef() const
{
    return getAttribute(SVGNames::glyphRefAttr);
}
QString     AbstractWidgetForm::getId()                           const                 { return getAttribute("id");        }
Exemple #24
0
DOMString SVGAltGlyphElement::format() const
{
    return getAttribute(SVGNames::formatAttr);
}
Exemple #25
0
int UT_buildindex( int argc, char* argv[] )
{
    relDesc * relInfo;
    attrDesc * attrInfo;
    char * relName, * attrName, * record, * value;
    int relRecId, attrRecId, return_val, recId, indexFileDesc, fileDesc;

    if ( argc != 3 ) {
        printf( "Error: Three arguments expected for function UT_buildindex\n" );
        return AMINIREL_GE;
    }

    inline cleanup() {
        /* apodesmeush dynamikhs mnhmhs */
        if ( relInfo != NULL ) {
            free( relInfo );
        }

        if ( attrInfo != NULL ) {
            free( attrInfo );
        }

        if ( record != NULL ) {
            free( record );
        }

        /* Kleinoyme arxeia pou isws anoiksame */

        /* kleinoyme to arxeio ths sxeshs */
        if ( fileDesc >= 0 ) {
            if ( HF_CloseFile( fileDesc ) != HFE_OK ) {
                HF_PrintError( "Could not close relation's file" );
                return_val = AMINIREL_GE;
            }
        }

        /* kleinoyme to eyrethrio */
        if ( indexFileDesc >= 0 ) {
            if ( AM_CloseIndex( indexFileDesc ) != AME_OK ) {
                AM_PrintError( "Could not close index" );
                return_val = AMINIREL_GE;
            }
        }
    }

    /* initialization */
    relName = argv[1];
    attrName = argv[2];
    relInfo = NULL;
    attrInfo = NULL;
    record = NULL;
    return_val = AMINIREL_OK;
    fileDesc = indexFileDesc = AMINIREL_INVALID;

    /* kanoume retrieve tis plhrofories gia th sxesh me onoma relName */
    if (( relInfo = getRelation( relName, &relRecId ) ) == NULL ) {
        printf( "Error: Could not retrieve information about relation '%s'\n", relName );
        return AMINIREL_GE;
    }

    /* Mias kai mporoume na exoume to poly 1 eurethrio gia kathe attribute, an o arithmos twn eurethriwn
       isoutai me ton arithmo twn attributes tote de ginetai na ftiaksoume allo index */
    if ( relInfo->attrcnt == relInfo->indexcnt ) {
        printf( "Error: Cannot create yet another index for any of %s's attributes, delete one first\n", relName );
        return_val =  AMINIREL_GE;
        cleanup();
        return return_val;
    }

    /* afou mporesame na vroume th sxesh relName, twra kanoume retrieve tis plhrofories gia to attribute ths */
    if (( attrInfo = getAttribute( relName, attrName, &attrRecId ) ) == NULL ) {
        printf( "Error: Could not retrieve information about attribute '%s' of relation %s\n", attrName, relName );
        return_val = AMINIREL_GE;
        cleanup();
        return return_val;
    }

    /* Vrhkame to attribute, twra elegxoume an yparxei hdh ena eurethrio gia to attribute! */
    if ( attrInfo->indexed == TRUE ) {
        printf( "Error: There is already an index for attribute '%s' of relation '%s'\n", attrName, relName );
        return_val =  AMINIREL_GE;
        cleanup();
        return return_val;
    }
    else {

        /* Mporoume na ftiaksoume neo eurethrio! :v */
        /* Enhmerwnoume to indexed kai indexno tou attrInfo */
        attrInfo->indexed = TRUE;
        attrInfo->indexno = relInfo->indexcnt;

        /* Enhmerwnoume ton indexcnt tou relInfo */
        ( relInfo->indexcnt )++;

        /* Mias kai to HF epipedo mas epistrefei antigrafa twn records, emeis twra pou exoume tis nees versions twn records
           prepei na diagrapsoume ta original kai na eisagoume pali ta kainourgia! */

        /* Diagrafh ths eggrafhs sto relCat */
        if ( HF_DeleteRec( this_db.relCatDesc, relRecId, sizeof( relDesc ) ) != HFE_OK ) {
            HF_PrintError( "Could not Destroy record in relCat " );
            return_val =  AMINIREL_GE;
            cleanup();
            return return_val;
        }

        /* Diagrafh ths eggrafhs sto attrCat */
        if ( HF_DeleteRec( this_db.attrCatDesc, attrRecId, sizeof( attrDesc ) ) != HFE_OK ) {
            HF_PrintError( "Could not Destroy record in attrCat " );
            return_val =  AMINIREL_GE;
            cleanup();
            return return_val;
        }

        /* Eisagwgh twn updated records sto relCat */
        if ( updateRelCat( relInfo ) != AMINIREL_OK ) {
            printf( "ton hpie h update relcat\n" )  ;
            return_val =  AMINIREL_GE;
            cleanup();
            return return_val;
        }

        /* kai sto attrCat */
        if ( updateAttrCat( attrInfo ) != AMINIREL_OK ) {
            printf( "ton hpie h update attrcat\n" )  ;
            return_val =  AMINIREL_GE;
            cleanup();
            return return_val;
        }


        /* Telos, dhmioyrgoyme to eurethrio */

        if ( AM_CreateIndex( relName, attrInfo->indexno, attrInfo->attrtype, attrInfo->attrlength ) != AME_OK ) {
            AM_PrintError( "Could not Create Index in UT_buildindex() " );
            return_val = AMINIREL_GE;
            cleanup();
            return return_val;
        }

        /*
           Twra pou dhmioyrghsame to eyrethrio, prepei oses eggrafes yparxoun sto arxeio ths sxeshs na perastoun sto
           eurethrio!
        */

        /* Desmeuoume xwro gia to xwro pou tha apothikeuetai to kathe record tou arxeiou */
        if (( record = malloc( relInfo->relwidth ) ) == NULL ) {
            printf( MEM_ERROR );
            return_val = AMINIREL_GE;
            cleanup();
            return return_val;
        }

        memset( record, 0, relInfo->relwidth );

        /* Anoigoume to eurethrio */
        if (( indexFileDesc = AM_OpenIndex( relName, attrInfo->indexno ) ) < 0 ) {
            AM_PrintError( "Could not Open Index in UT_buildindex() " );
            return_val = AMINIREL_GE;
            cleanup();
            return return_val;
        }

        /* Anoigoume to arxeio ths sxeshs */

        if (( fileDesc = HF_OpenFile( relName ) ) < 0 ) {
            HF_PrintError( "Could not Open relation's file in UT_buildindex() " );
            return_val = AMINIREL_GE;
            cleanup();
            return return_val;
        }

        /* ksekiname me thn prwth eggrafh */
        if (( recId = HF_GetFirstRec( fileDesc, record, relInfo->relwidth ) ) < 0 ) {
            /* Yparxei h periptwsh to arxeio na mhn exei eggrafes */
            if ( recId != HFE_EOF ) {
                HF_PrintError( "Could not retrieve first Record from relation's file" );
                return_val = AMINIREL_GE;
            }

            cleanup();
            return return_val;
        }

        /* Eisagoume oles tis eggrafes tou arxeiou ths sxeshs, sto eurethrio */
        do {
            /* Thetoume ton pointer value sto swsto shmeio ths eggrafhs ap opou tha paroume tin timh mas */
            value = record + attrInfo->offset;

            /* Eisagoume thn eggrafh sto eurethrio */
            if ( AM_InsertEntry( indexFileDesc, attrInfo->attrtype, attrInfo->attrlength, value, recId ) != AME_OK ) {
                AM_PrintError( "Could not insert into index" );
                return_val = AMINIREL_GE;
            }
        }
        while (( recId = HF_GetNextRec( fileDesc, recId, record , relInfo->relwidth ) ) >= 0 );

        if ( recId != HFE_EOF ) {
            HF_PrintError( "Error: Cannot build index\n" );
            cleanup();
            return return_val;
        }

        return_val = AMINIREL_OK;
    }

    cleanup();
    return return_val;
}
Exemple #26
0
String SVGAnimationElement::fromValue() const
{
    return getAttribute(SVGNames::fromAttr);
}
bool HTMLElement::draggable() const
{
    return equalIgnoringCase(getAttribute(draggableAttr), "true");
}
Exemple #28
0
bool SVGAnimationElement::isAdditive() const
{
    static const AtomicString sum("sum");
    const AtomicString &value = getAttribute(SVGNames::additiveAttr);
    return value == sum || animationMode() == ByAnimation;
}
Exemple #29
0
String HTMLAnchorElement::target() const
{
    return getAttribute(targetAttr);
}
const AtomicString& HTMLTableColElement::width() const {
  return getAttribute(widthAttr);
}