/*Produce a permutation from a inversetable.Store the permutation in permutation variable. * all this is in the structure permu.*/ int _permutation(permu *permutation) { int *permu = permutation->permutation; int *inversetable = permutation->inversetable; int length = permutation->length; int i; int insert,inverseNum; for(i=0;i< length;i++){ insert = length - i;/*The number will be inserted into the array.*/ inverseNum = *(inversetable + i);/*The amount how many numbers bigger before.*/ _rshift(permu,length,inverseNum,i);/*Empty the place where we want to insert number.*/ *(permu+inverseNum) = insert;/*Insert.*/ } return 1; }
QVariant ZStringFormatter::transform(QVariant val){ if(method() == ZFMT_METHOD_STR_CONCAT){ //! concat( with ) return _concat(val,arg("with",ZML_DEFAULT_PARAM_NAME)); }else if(method() == ZFMT_METHOD_STR_DOWNCASE){ //! downcase return _downcase(val); }else if(method() == ZFMT_METHOD_STR_ELIDE){ //! elide( [maxLength [, placeholder]] ) if(arg("placeholder").isValid()) return _elide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt(), arg("placeholder").toString()); else return _elide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt()); }else if(method() == ZFMT_METHOD_STR_LEFT){ //! left( length ) return _left(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_LEFTOF){ //! leftOf( delimiter ) return _leftOf(val, arg("delimiter",ZML_DEFAULT_PARAM_NAME).toString()); }else if(method() == ZFMT_METHOD_STR_LELIDE){ //! lelide( [maxLength [, placeholder]] ) if(arg("placeholder").isValid()) return _lelide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt(), arg("placeholder").toString()); else return _lelide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt()); }else if(method() == ZFMT_METHOD_STR_LPAD){ //! lpad( length [, symbol] ) if(arg("symbol").isValid()) return _lpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt(), arg("symbol").toChar()); else return _lpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_LSHIFT){ //! lshift( places ) return _lshift(val, arg("places", ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_LTRIM){ //! ltrim( [pattern] ) if(arg("pattern").isValid()) return _ltrim(val, arg("pattern",ZML_DEFAULT_PARAM_NAME).toString()); else return _ltrim(val); }else if(method() == ZFMT_METHOD_STR_RELIDE){ //! relide( [maxLength [, placeholder]] ) if(arg("placeholder").isValid()) return _relide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt(), arg("placeholder").toString()); else return _relide(val, arg("maxLength",ZML_DEFAULT_PARAM_NAME).toInt()); }else if(method() == ZFMT_METHOD_STR_REPEAT){ //! repeat( times ) return _repeat(val, arg("times",ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_REVERSE){ //! reverse return _reverse(val); }else if(method() == ZFMT_METHOD_STR_RIGHT){ //! right( length ) return _right(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_RIGHTOF){ //! rightOf( delimiter ) return _rightOf(val, arg("delimiter",ZML_DEFAULT_PARAM_NAME).toString()); }else if(method() == ZFMT_METHOD_STR_RPAD){ //! rpad( length [, symbol] ) if(arg("symbol").isValid()) return _rpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt(), arg("symbol").toChar()); else return _rpad(val, arg("length",ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_RSHIFT){ //! rshift( places ) return _rshift(val, arg("places",ZML_DEFAULT_PARAM_NAME).toUInt()); }else if(method() == ZFMT_METHOD_STR_RTRIM){ //! rtrim( [pattern] ) if(arg("pattern").isValid()) return _rtrim(val, arg("pattern",ZML_DEFAULT_PARAM_NAME).toString()); else return _rtrim(val); }else if(method() == ZFMT_METHOD_STR_SCASE){ //! capitalize return _sentenceCase(val); }else if(method() == ZFMT_METHOD_STR_SQUEEZE){ //! squeeze( [symbol] ) if(arg("symbol").isValid()) return _squeeze(val, arg("symbol",ZML_DEFAULT_PARAM_NAME).toChar()); else return _squeeze(val); }else if(method() == ZFMT_METHOD_STR_TCASE){ //! titleize return _titleCase(val); }else if(method() == ZFMT_METHOD_STR_TRIM){ //! trim( [pattern] ) if(arg("pattern").isValid()) return _trim(val, arg("pattern",ZML_DEFAULT_PARAM_NAME).toString()); else return _trim(val); }else if(method() == ZFMT_METHOD_STR_UPCASE){ //! upcase return _upcase(val); } return val; }