Exemplo n.º 1
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());
     }
 }
Exemplo n.º 2
0
        /**
         * Interpret an "at" with a given container.
         * @param container Container to look through.
         * @param index The index in the container.
         * @return the element at an index in the container.
         */
        Element InterpretContainer_( Container container, Number index)
        {

            if (index.IntValue() < container.NumberOfElements() && index.IntValue() >= 0)
            {
                 return container.Get(index.IntValue());         
            }
            else
            {
                 std::stringstream ss;
                 ss << "the index given is out of range: index=" << index.IntValue() << ", max=" << container.NumberOfElements();
                 return Error(ss.str());
            }
        }