Example #1
0
  void MzTabModification::fromCellString(const String& s)
  {
    String lower = s;
    lower.toLower().trim();
    if (lower == "null")
    {
      setNull(true);
    }
    else
    {
      if (!lower.hasSubstring("-")) // no positions? simply use s as mod identifier
      {
        mod_identifier_.set(String(s).trim());
      }
      else
      {
        String ss = s;
        ss.trim();
        std::vector<String> fields;
        ss.split("-", fields);

        if (fields.size() != 2)
        {
          throw Exception::ConversionError(__FILE__, __LINE__, __PRETTY_FUNCTION__, String("Can't convert to MzTabModification from '") + s);
        }
        mod_identifier_.fromCellString(fields[1].trim());

        std::vector<String> position_fields;
        fields[0].split("|", position_fields);

        for (Size i = 0; i != position_fields.size(); ++i)
        {
          Size spos = position_fields[i].find_first_of("[");

          if (spos == std::string::npos) // only position information and no parameter
          {
            pos_param_pairs_.push_back(std::make_pair(position_fields[i].toInt(), MzTabParameter()));
          }
          else
          {
            // extract position part
            Int pos = String(position_fields[i].begin(), position_fields[i].begin() + spos).toInt();

            // extract [,,,] part
            MzTabParameter param;
            param.fromCellString(position_fields[i].substr(spos));
            pos_param_pairs_.push_back(std::make_pair(pos, param));
          }
        }
      }
    }
  }
Example #2
0
uint16_t stod(String in) {
    char c;
    uint16_t w = 0;
    in = in.trim();
    
    for (uint8_t i=0; i<in.length(); i++) {
        c = in.charAt(i);
        w *= 10; 
        if ((c>='0') && (c<='9')) w |= (c-'0');
        else;
    }
    return w;
}
void NewhavenDisplay::stringPadRight(String &str, const int length_total)
{
  str.trim();
  if (str.length() > length_total)
  {
    str = str.substring(0,length_total);
  }
  String padding = String(padding_char_);
  while (str.length() < length_total)
  {
    str += padding;
  }
}
Example #4
0
void Quadrotor::waitForStartCommand()
{
   String message = "";

   while (!message.equals("Start"))
   {
      delay(100);
      message = bluetooth->readLine();
      message.trim();
   }

   Serial.println("Received Start command");
}
Example #5
0
  void TextFile::load(const String & filename, bool trim_lines, Int first_n)
  {
    ifstream is(filename.c_str(), ios_base::in | ios_base::binary);
    if (!is)
    {
      throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
    }

    clear();

    String str;
    bool had_enough = false;
    while (getline(is, str, '\n') && !had_enough)
    {
      // platform specific line endings:
      // Windows LE: \r\n
      //    we now have a line with \r at the end: get rid of it
      if (str.size() >= 1 && *str.rbegin() == '\r')
        str = str.substr(0, str.size() - 1);

      // Mac (OS<=9): \r
      //    we just read the whole file into a string: split it
      StringList lines;
      if (str.hasSubstring("\r"))
        lines = StringList::create(str, '\r');
      else
        lines.push_back(str);

      // Linux&MacOSX: \n
      //    nothing to do

      for (Size i = 0; i < lines.size(); ++i)
      {
        str = lines[i];
        if (trim_lines)
        {
          push_back(str.trim());
        }
        else
        {
          push_back(str);
        }

        if (first_n > -1 && (Int)(size()) == first_n)
        {
          had_enough = true;
          break;
        }
      }
    }
  }
Example #6
0
int WikiParser::renderInternal(const String &Source, String &Html)
{
	String Tmp;
	String Text=Source;
	Text.replace("\r\n","\n");

	extractNoWiki(Text);
	extractSourcecode(Text);
	extractDiagrams(Text);

	String Line;

	Array Rows;
	Rows.explode(Text,"\n");
	Array Match;

	for (size_t j=0;j<Rows.size();j++) {
		Line=Rows[j];
		nobr=false;
		parseHeadlines(Line);
		parseLinks(Line);
		parseDoxygen(Line);

		if (parseOL(Line)) continue;
		if (parseUL(Line)) continue;
		if (parseIndent(Line)) continue;


		parseTable(Line);
		parseAutoPRE(Line);		// Zeilen mit Space am Anfang?

		// An bestimmten Stellen wollen wir am Ende kein <br>

		if (Line.pregMatch("/^.*<\\/li>$/i")) nobr=true;
		if (Line.pregMatch("/^.*<nobr>$/i")) {
			Line.pregReplace("/<nobr>$/i","");
			nobr=true;
		}

		Line.trim();
		ret+=Line;
		if (!nobr) ret+="<br>";
		ret+="\n";
	}
	finalize();

	if (indexenabled) buildIndex(Html);	// Index hinzufügen
	Html+=ret;
	return 1;

}
Example #7
0
// logo color purple
int startColorAnimation(String colorName) {
    if (colorName.indexOf(",") != -1) {
        return startDualColorAnimation(colorName);
    }

    colorName.trim();
    Color color = colorFromName(colorName);

    Animation *anim = new ColorAnimation{context, color, CLOUD_ANIMATION_TIME};
    abortCurrentAnimations();
    addAnimation(anim);

    return 0;
}
Example #8
0
	void Uri::extractURIFromString(const AnyString& raw)
	{
		// Cleanup before anything
		clear();

		// trim the string for unwanted and useless char
		// making a copy for the helper class
		String copy = raw;
		copy.trim();

		// Go ahead !
		if (not copy.empty())
			BuildSession(pInfos, copy).run();
	}
Example #9
0
void Quadrotor::shutdownSequence()
{
   unsigned long currentTime;
   unsigned long previousTime = millis();
   float deltaTime;
   struct RPYData orientation;
   String message;
   int count = 0;
   // slowly decrease the height
   int height = controller->getAltitudeController()->getSetpoint();
   while (height > 1)
   {
      currentTime = millis();
      if (currentTime - previousTime >= SAMPLE_RATE)
      {		
         ++count;
         // get the delta time in seconds for calculations
         deltaTime = (currentTime - previousTime) / 1000.0;
         previousTime = currentTime;

         // get current orientation
         RETURN_CODE retVal = orientationManager->getCurrentOrientation(deltaTime, orientation);
		   if (retVal == SUCCESS)
		   {
			   // use the current orientation to adjust the motors
			   controller->flightControl(orientation, deltaTime);
			   // check for commands via bluetooth
			   message = bluetooth->readLine();
            // remove any whitespace
			   message.trim();

			   // handle the message if present
			   if (!message.equals("")) handleMessage(message);

            // every half a second lower the quadrotor an inch
			   if (count >= (int)floor(0.5 * 1000.0 / SAMPLE_RATE))
			   {
               count = 0;
               controller->getAltitudeController()->setSetpoint(--height);
			   }
		   }
      }
      // wait for 30ms to complete
   }
   // shut off motors
   motor1->setSpeed(0.0);
   motor2->setSpeed(0.0);
   motor3->setSpeed(0.0);
   motor4->setSpeed(0.0);
}
Example #10
0
    bool convert(const String &input, UUID &outResult, bool ignoreWhiteSpace)
    {
      String temp = input;
      if (ignoreWhiteSpace)
        temp.trim();

#ifndef _WIN32
      temp.trimLeft("{");
      temp.trimRight("}");
#endif //ndef _WIN32

      if (0 == uuid_parse(temp.c_str(), outResult.mUUID)) return true;
      return false;
    }
Example #11
0
    bool convert(const String &input, double &outResult, bool ignoreWhiteSpace)
    {
      String temp = input;
      if (ignoreWhiteSpace)
        temp.trim();

      try {
        double result = std::stod(temp);
        outResult = result;
      } catch(...) {
        return false;
      }
      return true;
    }
void GlyphArrangement::addFittedText (const Font& f,
                                      const String& text,
                                      const float x, const float y,
                                      const float width, const float height,
                                      Justification layout,
                                      int maximumLines,
                                      const float minimumHorizontalScale)
{
    // doesn't make much sense if this is outside a sensible range of 0.5 to 1.0
    jassert (minimumHorizontalScale > 0 && minimumHorizontalScale <= 1.0f);

    if (text.containsAnyOf ("\r\n"))
    {
        addLinesWithLineBreaks (text, f, x, y, width, height, layout);
    }
    else
    {
        const int startIndex = glyphs.size();
        const String trimmed (text.trim());
        addLineOfText (f, trimmed, x, y);
        const int numGlyphs = glyphs.size() - startIndex;

        if (numGlyphs > 0)
        {
            const float lineWidth = glyphs.getReference (glyphs.size() - 1).getRight()
                                      - glyphs.getReference (startIndex).getLeft();

            if (lineWidth > 0)
            {
                if (lineWidth * minimumHorizontalScale < width)
                {
                    if (lineWidth > width)
                        stretchRangeOfGlyphs (startIndex, numGlyphs, width / lineWidth);

                    justifyGlyphs (startIndex, numGlyphs, x, y, width, height, layout);
                }
                else if (maximumLines <= 1)
                {
                    fitLineIntoSpace (startIndex, numGlyphs, x, y, width, height,
                                      f, layout, minimumHorizontalScale);
                }
                else
                {
                    splitLines (trimmed, f, startIndex, x, y, width, height,
                                maximumLines, lineWidth, layout, minimumHorizontalScale);
                }
            }
        }
    }
}
Example #13
0
bool D2Container::parseFile(wchar_t const* path, D2Data* d2data)
{
  sub.clear();
  WIN32_FILE_ATTRIBUTE_DATA attr;
  if (!GetFileAttributesEx(path, GetFileExInfoStandard, &attr))
    return false;
  uint64 lastWrite = uint64(attr.ftLastWriteTime.dwLowDateTime) | (uint64(attr.ftLastWriteTime.dwHighDateTime) << 32);
  if (lastWrite <= lastUpdate)
    return false;
  lastUpdate = lastWrite;
  for (int i = 0; i < items.length(); i++)
    items[i]->release();
  items.clear();
  LocalPtr<File> file = File::wopen(path, File::READ);
  String line;
  String header(WideString::format(L"%s / %s", parent->name, name));
  while (file->gets(line))
  {
    line.trim();
    if (line.empty()) continue;
    LocalPtr<json::Value> value = json::Value::parse(TempFile(File::memfile(line.c_str(), line.length(), false)));
    if (value && value->type() == json::Value::tObject
              && value->hasProperty("itemColor", json::Value::tNumber)
              && value->hasProperty("image", json::Value::tString)
              && value->hasProperty("title", json::Value::tString)
              && value->hasProperty("description", json::Value::tString)
              && value->hasProperty("header", json::Value::tString)
              && value->hasProperty("sockets", json::Value::tArray))
    {
      D2Item* item = new D2Item(this);
      item->invColor = value->get("itemColor")->getInteger();
      item->image = value->get("image")->getString();
      item->title = value->get("title")->getString();
      item->description = value->get("description")->getString();
      item->header = value->get("header")->getString();
      if (!item->header.length())
        item->header = header;
      json::Value* sockets = value->get("sockets");
      for (uint32 i = 0; i < sockets->length(); i++)
      {
        json::Value* sock = sockets->at(i);
        if (sock->type() == json::Value::tString)
          item->sockets.push(sock->getString());
      }
      item->parse(d2data);
      items.push(item);
    }
  }
  return true;
}
Example #14
0
    bool convert(const String &input, double &outResult, bool ignoreWhiteSpace)
    {
      String temp = input;
      if (ignoreWhiteSpace)
        temp.trim();

      try {
        double result = boost::lexical_cast<double>(temp);
        outResult = result;
      } catch(...) {
        return false;
      }
      return true;
    }
Example #15
0
String ProjectExporter::getUniqueConfigName (String nm) const
{
    String nameRoot (nm);
    while (CharacterFunctions::isDigit (nameRoot.getLastCharacter()))
        nameRoot = nameRoot.dropLastCharacters (1);

    nameRoot = nameRoot.trim();

    int suffix = 2;
    while (hasConfigurationNamed (name))
        nm = nameRoot + " " + String (suffix++);

    return nm;
}
Example #16
0
//GETリクエストをしてbody部分を受信
void CogleMasterConfig::httpGet(String url,char* body,int body_size){
  client.print(String("GET ")
                + url
                + " HTTP/1.1\r\n" 
                + "Host: " + COFIG_SERVER_API_HOST + "\r\n"
                + "Connection: close\r\n\r\n");
  delay(100);
  
  while(client.available()){
    String line = client.readStringUntil('\r');
    line.trim();
    //Serial.println( "line:"+line );
    if(line.length() == 0){
        //空行の後がbody
        String resp = "";
        while(client.available()){
          resp += client.readStringUntil('\r');
        }
        resp.trim();
        resp.toCharArray(body,body_size);
    }
  }      
}
Example #17
0
String XMLDoc::getXML(bool includePi) {
  m_doc->PutpreserveWhiteSpace(VARIANT_TRUE);
  BSTR b = getRoot()->Getxml();

  String XML = BSTRToString(b);

  ::SysFreeString(b);
  b = NULL;

  if(includePi) {
    XML = _T("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>") + XML;
  }
  return XML.trim();
}
Example #18
0
const String CtrlrMidiBufferStatus::hexString(const String &hex)
{
	String ret;
	MemoryBlock mb;
	mb.loadFromHexString (hex);
	uint8 *ptr = (uint8*)mb.getData();
	for (size_t i=0; i<mb.getSize(); i++)
	{
		const String bis = BigInteger (*(ptr+i)).toString(2, 8);
		ret << String::formatted ("[0x%.2x/%.3d/", *(ptr+i), *(ptr+i)) << bis.substring(0,4) << ":" << bis.substring(4,8) << "] ";
	}

	return (ret.trim());
}
Example #19
0
    bool convert(const String &input, UUID &outResult, bool ignoreWhiteSpace)
    {
      String temp = input;
      if (ignoreWhiteSpace)
        temp.trim();

      try {
        boost::uuids::string_generator gen;
        outResult = gen(temp);
      } catch (...) {
        return false;
      }
      return true;
    }
Example #20
0
 StringList ListTable::getList()
 {
   String stringit;
   list_.clear();
   for (Int i = 0; i < count(); ++i)
   {
     stringit = item(i)->text();
     if (stringit != "")
     {
       stringit.trim();
     }
     list_.push_back(stringit);
   }
   return list_;
 }
Example #21
0
void WikiParser::doxygenChapter(String &Line, const String &Name, const Array &Matches)
{
	String Tmp;
	Line="";
	for (int i=indentlevel;i>0;i--) Line+="</div>";
	indentlevel=0;
	Line+="<b>";
	Line+=Name;
	Line+="</b><div style=\"margin-left: 30px;\">";
	Tmp=Matches[1];
	Tmp.trim();
	if (Tmp.notEmpty()) Line+=Tmp;
	else nobr=true;
	indentlevel++;
}
Example #22
0
bool HttpRequest::extractParsingItemsList(pbuf* buf, int startPos, int endPos, char delimChar, char endChar,
													HashMap<String, String>* resultItems)
{
	bool continued = false;
	int delimItem, nextItem, startItem = startPos;
	while (startItem < endPos)
	{
		delimItem = NetUtils::pbufFindStr(buf, "=", startItem);
		if (delimItem == -1 || delimItem > endPos) break;
		nextItem = NetUtils::pbufFindChar(buf, delimChar, delimItem + 1);
		if (nextItem == -1)
			nextItem = NetUtils::pbufFindChar(buf, endChar, delimItem + 1);
		if (nextItem > endPos) break;

		if (nextItem == -1)
		{
			nextItem = endPos;
			continued = true;
		}

		String ItemName = NetUtils::pbufStrCopy(buf, startItem, delimItem - startItem);
		String ItemValue = NetUtils::pbufStrCopy(buf, delimItem + 1, nextItem - delimItem - 1);
		char* nam = uri_unescape(NULL, 0, ItemName.c_str(), -1);
		ItemName = nam;
		free(nam);
		char* val = uri_unescape(NULL, 0, ItemValue.c_str(), -1);
		ItemValue = val;
		free(val);
		ItemName.trim();
		if (!continued) ItemValue.trim();
		debugf("Item: Name = %s, Size = %d, Value = %s",ItemName.c_str(),ItemValue.length(),ItemValue.substring(0,80).c_str());
		(*resultItems)[ItemName] = ItemValue;
		startItem = nextItem + 1;
	}
	return continued;
}
String MDLHelper::removeSurroundingParentheses(const String& s, bool recursive)
{
    String result = s.trim();

    while (result.startsWithChar('(') && result.endsWithChar(')'))
    {
        result = result.substring(1, result.length() - 1).trim();
        if (!recursive)
        {
            return result;
        }
    }

    return result;
}
Example #24
0
// logo breathe sepia
// logo breathe rainbow
int startBreatheAnimation(String colorName) {

    colorName.trim();
    if (colorName.equals("rainbow")) {
        return startBreatheRainbowAnimation();
    }

    Color color = colorFromName(colorName);

    Animation *anim = new BreatheAnimation{context, color, CLOUD_ANIMATION_TIME};
    abortCurrentAnimations();
    addAnimation(anim);

    return 0;
}
Example #25
0
// Utilities
//
uint16_t stoh(String in) {
    char c;
    uint16_t w = 0;
    in = in.trim();
    
    for (uint8_t i=0; i<in.length(); i++) {
        c = in.charAt(i);
        w <<= 4; 
        if ((c>='0') && (c<='9')) w |= (c-'0');
        else if ((c>='A') && (c<='F')) w |= (c-'A'+0x0a);
        else if ((c>='a') && (c<='f')) w |= (c-'a'+0x0a);
        else;
    }
    return w;
}
Example #26
0
    bool convert(const String &input, Time &outResult, bool ignoreWhiteSpace)
    {
      String temp = input;
      if (ignoreWhiteSpace)
        temp.trim();

      try {
        Time result = boost::posix_time::time_from_string(input);
        if (result.is_not_a_date_time()) return false;
        outResult = result;
      } catch (boost::bad_lexical_cast &) {
        return  false;
      }
      return true;
    }
Example #27
0
void ScreenTask::execute(String command){

	String cmd = "SCREEN";
	String clearcmd = "CLEAR";

	if (command.substring(0, cmd.length()) == cmd){
		String originalCommand = command.substring(0);
		String message = command.substring(cmd.length());
		message.trim();
		this->println(message);
	}
	else if (command.substring(0, clearcmd.length()) == clearcmd){ 
		this->clear();
	}
}
Example #28
0
void Database::Statement::output(const Pair &pair)
{
	String key;
	LineSerializer keySerializer(&key);
	pair.serializeKey(keySerializer);
	key.trim();
	
	int parameter = parameterIndex(key);
	if(parameter != 0) 
	{
		mOutputParameter = parameter;
		++mOutputLevel;
		pair.serializeValue(*this);
		--mOutputLevel;
	}
}
Example #29
0
void XMLDoc::getValue(const XMLNodePtr     &node,     const TCHAR *tagName, String      &value, int instans) {
  VARIANT NodeValue = getVariant(node,tagName,instans);

  switch(NodeValue.vt) {
  case VT_BSTR:
    { _bstr_t b = NodeValue.bstrVal;
      value = (TCHAR*)b;
      value.trim();
    }
    break;

  default:
    value=EMPTYSTRING;
    break;
  }
}
bool PublicIpLookup::lookupIpAddress( String& ipAddress ) {

  WiFiRestClient restClient( "api.ipify.org" );

  int statusCode = restClient.get( "/?format=text", &ipAddress );
  if( statusCode == 200 ) {

    ipAddress.trim();
    return true;

  } else {

    ipAddress = "";
    return false;
  }
}