Changeset 3c1f60d in tol


Ignore:
Timestamp:
May 21, 2012, 4:04:02 PM (14 years ago)
Author:
Pedro Gea <pgea@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
26d815e
Parents:
48b43e8
Message:

Refs #1538 (en versión 3.2 -trunk-)
Se crean dichas funciones.

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@4708 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/text_type/txtgra.cpp

    r48b43e8 r3c1f60d  
    593593}
    594594
     595//--------------------------------------------------------------------
     596DeclareContensClass(BText, BTxtTemporary, BTxtJoinWith);
     597DefExtOpr(1, BTxtJoinWith, "TextJoinWith", 2, 2, "Set Text",
     598          I2("(Set texts, Text separator)",
     599             "(Set textos, Text separador)"),
     600          I2("Concatenates all the elements of a set of texts, "
     601         "using the specified separator between each element.",
     602             "Concatena todos los elementos de un conjunto de textos "
     603         "usando el separador indicado entre ellos."),
     604          BOperClassify::Text_);
     605
     606//--------------------------------------------------------------------
     607void BTxtJoinWith::CalcContens()
     608//--------------------------------------------------------------------
     609{
     610  BSet& set = Set(Arg(1));
     611  BText& separator = Text(Arg(2));
     612  contens_ = "";
     613  bool ok = true;
     614  for(BInt n=1; n<=set.Card(); n++)
     615  {
     616    if(n>1) { contens_ += separator; };
     617        if(set[n]->Grammar()==GraText()) { contens_ += Text(set[n]); }
     618    else { ok = false; }
     619  }
     620  if(!ok)
     621  {
     622    Error(I2("There are non Text objects in the set argument of "
     623             "function Text TextJoinWith",
     624             "Hay objetos de tipo distinto de Text en el conjunto "
     625             "argumento de la llamada a la función Text TextJoinWith"));
     626    contens_ = "";
     627  }
     628}
    595629
    596630//--------------------------------------------------------------------
    … …  
    873907             "(Text txt, Real desde, Real hasta)"),
    874908          I2("Returns the substring of a text between two bounds, both included.",
    875              "Devueve la subcadena comprendida entre dos límites ambos incluídos."),
     909             "Devueve la subcadena comprendida entre dos límites, ambos incluidos."),
    876910          BOperClassify::Text_);
    877911
    … …  
    883917}
    884918
     919//--------------------------------------------------------------------
     920DeclareContensClass(BText, BTxtTemporary, BTxtSub);
     921DefExtOpr(1, BTxtSub, "TextSub", 3, 3, "Text Real Real",
     922          I2("(Text txt, Real from, Real until)",
     923             "(Text txt, Real desde, Real hasta)"),
     924          I2("Returns the substring of a text between two bounds, both included. "
     925         "Negative character positions count from the end of the text.",
     926             "Devueve la subcadena comprendida entre dos límites, ambos incluidos."
     927         "Las posiciones negativas cuentan desde el final del texto."),
     928          BOperClassify::Text_);
     929
     930//--------------------------------------------------------------------
     931void BTxtSub::CalcContens()
     932//--------------------------------------------------------------------
     933{
     934    BInt        m   = (BInt)Real(Arg(2));
     935    BInt        n   = (BInt)Real(Arg(3));
     936    if(m<0) { m += 1+Text(Arg(1)).Length(); };
     937    if(n<0) { n += 1+Text(Arg(1)).Length(); };
     938    contens_.Copy(Text(Arg(1)),m-1,n-1);
     939}
    885940
    886941//--------------------------------------------------------------------
    … …  
    907962}
    908963
    909 
    910 
     964//--------------------------------------------------------------------
     965DeclareContensClass(BText, BTxtTemporary, BFirstTxtToLower);
     966DefExtOpr(1, BFirstTxtToLower, "FirstToLower", 1, 1, "Text",
     967          "(Text txt)",
     968          I2("Changes the first character of a text to lower case.",
     969             "Cambia el primer caracter a minúsculas."),
     970          BOperClassify::Text_);
     971
     972//--------------------------------------------------------------------
     973void BFirstTxtToLower::CalcContens()
     974//--------------------------------------------------------------------
     975{
     976  contens_=Text(Arg(1));
     977  char ch = contens_.Get(0);
     978  if(ch)
     979  {
     980    contens_.PutChar(0,(BChar)tolower(ch));
     981  }
     982}
    911983
    912984//--------------------------------------------------------------------
    … …  
    21092181}
    21102182
     2183//--------------------------------------------------------------------
     2184DeclareContensClass(BSet, BSetTemporary, BCharacters);
     2185DefExtOpr(1, BCharacters, "Characters", 1, 1,  "Text", "(Text txt)",
     2186          I2("Returns a set with the characters of the text.",
     2187       "Devuelve un conjunto con los caracteres del texto."),
     2188          BOperClassify::System_);
     2189
     2190//--------------------------------------------------------------------
     2191void BCharacters::CalcContens()
     2192//--------------------------------------------------------------------
     2193{
     2194  BText& txt = Text(Arg(1));
     2195  contens_.PrepareStore(txt.Length());
     2196  for(BInt i=0; i<txt.Length(); i++)
     2197  {
     2198    contens_.AddElement(new BContensText(txt.SubString(i, i)));
     2199  }
     2200}
    21112201
    21122202//--------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.