コード例 #1
0
 Element InterpretSuperString_(SuperString str)
 {
     Element out = Nil();
     if (false == str.Value().empty())
     {
         out = SuperString(str.Value().substr(0, 1)); 
     }
     return out;
 }
コード例 #2
0
 /**
  * Interpret an "at" with a given super string.
  * @param container Container to look through.
  * @param index The index in the container.
  * @return the element at an index in the container.
  */
 Element InterpretSuperString_( SuperString str, Number index)
 {
     int const SIZE = static_cast<int>(str.Value().size());
     if (index.IntValue() < SIZE && index.IntValue() >= 0)
     {
          return SuperString(str.Value().substr(index.IntValue(), 1)); 
     }
     else
     {
          std::stringstream ss;
          ss << "the index given is out of range: index=" << index.IntValue() << ", max=" << SIZE;
          return Error(ss.str());
     }
 }
コード例 #3
0
Element LanguageBuiltinImplementation::Interpret_( Environment& environment
                                                 , std::vector<Element> const& parmsIn
                                                 , Element const& // additional_parameters
                                                 )
{
    Element out;

    if (false == parmsIn.empty())
    {
        Element parm1 = parmsIn[0];
        std::vector<Element> parms(parmsIn.begin() + 1, parmsIn.end());
        
        bool isSuperString = false;
        SuperString SS = CastToSuperString(parm1, isSuperString);

        bool isString = false;
        String S = CastToString(parm1, isString);
        
        std::string id;
        if (isSuperString)
        {
            id = SS.Value();
        }

        if (isString)
        { 
            id = S.Value();
        }

        Translator& translator = this->translators.Get(id);
        out = Translate_(environment, parms, translator);
    }

    return out;
}
コード例 #4
0
        int SizeOf_(Element const& element)
        {
            bool isA = false;
            int out = 0;
            switch(element.Type())
            {
                case Types::STRING: 
                {
                    String in  = CastToString(element, isA);
                    out = static_cast<int>(in.Value().size());
                    break;
                }

                case Types::SUPERSTRING: 
                {
                    SuperString in  = CastToSuperString(element, isA);
                    out = static_cast<int>(in.Value().size());
                    break;
                }

                case Types::CONTAINER:
                {
                    Container in = CastToContainer(element, isA);
                    out = in.NumberOfElements();
                    break;
                }
            };
            return out;  
        }
コード例 #5
0
 Element InterpretSuperString_(SuperString str)
 {
     Element out = Nil();
     std::string const INPUT(str.Value());
     if (false == INPUT.empty())
     {
         StringHolder temp = str.GetStringHolder();
         out = SuperString(StringHolder(temp, 1, INPUT.size() - 1));
     }
     return out;
 }