void PusherClient::subscribePrivate(const String& channel) 
{
    String message;
    getStringTableItem(7, message);
	
	{
		String stringVar;
		
		{
			String auth;
			getStringTableItem(1, stringVar);
			getAuthString(channel, auth);	
			message.replace(stringVar, auth);
			LogPrintLn(message);
		}
		
		getStringTableItem(0, stringVar);
		message.replace(stringVar, channel);
		LogPrintLn(message);	
	}
	
	String subscribeEventName;
	getStringTableItem(5, subscribeEventName);
    triggerEvent(subscribeEventName, message);
}
/*************************************************************************
//show the parameter of ssid, password, channel, encryption in AP mode
		
		return:
			mySAP:<SSID>,<password>,<channel>,<encryption>

***************************************************************************/
String WIFI::showSAP()
{
    _cell.println("AT+CWSAP?");  
      String data;
      unsigned long start;
	start = millis();
    while (millis()-start<3000) {
       if(_cell.available()>0)
       {
       char a =_cell.read();
       data=data+a;
       }
       if (data.indexOf("OK")!=-1 || data.indexOf("ERROR")!=-1 )
       {
           break;
       }
    }
      char head[4] = {0x0D,0x0A};   
      char tail[7] = {0x0D,0x0A,0x0D,0x0A};        
      data.replace("AT+CWSAP?","");
      data.replace("+CWSAP","mySAP");
      data.replace("OK","");
	  data.replace(tail,"");
      data.replace(head,"");
      
          return data;
}
Example #3
0
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
{
    // To preserve comments, remove only the text nodes, then add a single text node.

    Vector<RefPtr<Node> > textNodes;
    for (Node* n = firstChild(); n; n = n->nextSibling()) {
        if (n->isTextNode())
            textNodes.append(n);
    }
    ExceptionCode ec;
    size_t size = textNodes.size();
    for (size_t i = 0; i < size; ++i)
        removeChild(textNodes[i].get(), ec);

    // Normalize line endings.
    // Add an extra line break if the string starts with one, since
    // the code to read default values from the DOM strips the leading one.
    String value = defaultValue;
    value.replace("\r\n", "\n");
    value.replace('\r', '\n');
    if (value[0] == '\n')
        value = "\n" + value;

    insertBefore(document()->createTextNode(value), firstChild(), ec);

    setNonDirtyValue(value);
}
void HTMLTextAreaElement::setValueCommon(const String& newValue)
{
    m_wasModifiedByUser = false;
    // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
    // We normalize line endings coming from JavaScript here.
    String normalizedValue = newValue.isNull() ? "" : newValue;
    normalizedValue.replace("\r\n", "\n");
    normalizedValue.replace('\r', '\n');

    // Return early because we don't want to move the caret or trigger other side effects
    // when the value isn't changing. This matches Firefox behavior, at least.
    if (normalizedValue == value())
        return;

    m_value = normalizedValue;
    setInnerTextValue(m_value);
    setLastChangeWasNotUserEdit();
    updatePlaceholderVisibility(false);
    setNeedsStyleRecalc();
    setFormControlValueMatchesRenderer(true);

    // Set the caret to the end of the text value.
    if (document().focusedElement() == this) {
        unsigned endOfString = m_value.length();
        setSelectionRange(endOfString, endOfString);
    }

    setTextAsOfLastFormControlChangeEvent(normalizedValue);
}
Example #5
0
void HTMLTextAreaElement::setNonDirtyValue(const String& value)
{
    // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
    // We normalize line endings coming from JavaScript here.
    String normalizedValue = value.isNull() ? "" : value;
    normalizedValue.replace("\r\n", "\n");
    normalizedValue.replace('\r', '\n');

    // Return early because we don't want to move the caret or trigger other side effects
    // when the value isn't changing. This matches Firefox behavior, at least.
    if (normalizedValue == this->value())
        return;

    m_value = normalizedValue;
    updatePlaceholderVisibility(false);
    setNeedsStyleRecalc();
    setNeedsValidityCheck();
    m_isDirty = false;
    setFormControlValueMatchesRenderer(true);

    // Set the caret to the end of the text value.
    if (document()->focusedNode() == this) {
        unsigned endOfString = m_value.length();
        setSelectionRange(endOfString, endOfString);
    }

    notifyFormStateChanged(this);
}
Example #6
0
Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
	FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
	bool exists = f && f->is_open();

	String tempFile = get_user_data_dir();
	if (!exists)
		return FAILED;

	if (p_path.begins_with("res://")) {
		if (PackedData::get_singleton()->has_path(p_path)) {
			print("Unable to play %S using the native player as it resides in a .pck file\n", p_path.c_str());
			return ERR_INVALID_PARAMETER;
		} else {
			p_path = p_path.replace("res:/", ProjectSettings::get_singleton()->get_resource_path());
		}
	} else if (p_path.begins_with("user://"))
		p_path = p_path.replace("user:/", get_user_data_dir());

	memdelete(f);

	print("Playing video: %S\n", p_path.c_str());
	if (_play_video(p_path, p_volume, p_audio_track, p_subtitle_track))
		return OK;
	return FAILED;
}
Example #7
0
void TextFieldInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event)
{
    // Make sure that the text to be inserted will not violate the maxLength.

    // We use RenderTextControlSingleLine::text() instead of InputElement::value()
    // because they can be mismatched by sanitizeValue() in
    // HTMLInputElement::subtreeHasChanged() in some cases.
    unsigned oldLength = numGraphemeClusters(element()->innerTextValue());

    // selectionLength represents the selection length of this text field to be
    // removed by this insertion.
    // If the text field has no focus, we don't need to take account of the
    // selection length. The selection is the source of text drag-and-drop in
    // that case, and nothing in the text field will be removed.
    unsigned selectionLength = element()->focused() ? numGraphemeClusters(plainText(element()->document()->frame()->selection()->selection().toNormalizedRange().get())) : 0;
    ASSERT(oldLength >= selectionLength);

    // Selected characters will be removed by the next text event.
    unsigned baseLength = oldLength - selectionLength;
    unsigned maxLength = static_cast<unsigned>(isTextType() ? element()->maxLength() : HTMLInputElement::maximumLength); // maxLength can never be negative.
    unsigned appendableLength = maxLength > baseLength ? maxLength - baseLength : 0;

    // Truncate the inserted text to avoid violating the maxLength and other constraints.
    String eventText = event->text();
    eventText.replace("\r\n", " ");
    eventText.replace('\r', ' ');
    eventText.replace('\n', ' ');

    event->setText(limitLength(eventText, appendableLength));
}
/*************************************************************************
//show the current connection mode(sigle or multiple)
		
		return:		string of connection mode
			0	-	sigle
			1	-	multiple

***************************************************************************/
String WIFI::showMux(void)
{
    String data;
    _cell.println("AT+CIPMUX?");  

      unsigned long start;
	start = millis();
    while (millis()-start<3000) {
       if(_cell.available()>0)
       {
       char a =_cell.read();
       data=data+a;
       }
       if (data.indexOf("OK")!=-1)
       {
           break;
       }
    }
          char head[4] = {0x0D,0x0A};   
          char tail[7] = {0x0D,0x0A,0x0D,0x0A};        
          data.replace("AT+CIPMUX?","");
          data.replace("+CIPMUX","showMux");
          data.replace("OK","");
		  data.replace(tail,"");
          data.replace(head,"");
          
          return data;
}
void HTMLTextAreaElement::setValue(const String& value)
{
    // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
    // We normalize line endings coming from JavaScript here.
    String normalizedValue = value.isNull() ? "" : value;
    normalizedValue.replace("\r\n", "\n");
    normalizedValue.replace('\r', '\n');

    // Return early because we don't want to move the caret or trigger other side effects
    // when the value isn't changing. This matches Firefox behavior, at least.
    if (normalizedValue == this->value())
        return;

    m_value = normalizedValue;
    setValueMatchesRenderer();
    if (inDocument())
        document()->updateRendering();
    if (renderer())
        renderer()->updateFromElement();

    // Set the caret to the end of the text value.
    if (document()->focusedNode() == this) {
        unsigned endOfString = m_value.length();
        setSelectionRange(endOfString, endOfString);
    }

    setChanged();
    notifyFormStateChanged(this);
}
Example #10
0
String hmtlCharacterFilter(const String& input)
{
    String out = input;
    out.replace("&", "&amp;");
    out.replace("\"", "&quot;");
    out.replace(QString::fromWCharArray(L"ä"), "&auml;");
    out.replace(QString::fromWCharArray(L"Ä"), "&Auml;");
    out.replace(QString::fromWCharArray(L"ö"), "&ouml;");
    out.replace(QString::fromWCharArray(L"Ö"), "&Ouml;");
    out.replace(QString::fromWCharArray(L"å"), "&aring;");
    out.replace(QString::fromWCharArray(L"Å"), "&Aring;");
    return out;
}
Example #11
0
String TicketflySDBeacon::TicketInfoParser (String TicketString, int typeReturn){ 
  String TicketNumberRetrieve = "", TicketNameRetrieve = "", TicketTypeRetrieve = "";
  int lengthString, commaIndex1, commaIndex2;
  TicketString.replace(" ", "");
  lengthString = TicketString.length();
  commaIndex1 = TicketString.indexOf(',');
  commaIndex2 = TicketString.indexOf(',', commaIndex1+1);
    switch (typeReturn){
      case 1:
        TicketNumberRetrieve = TicketString.substring (0, commaIndex1);
        return TicketNumberRetrieve;
        break;
      case 2:
        TicketNameRetrieve = TicketString.substring (commaIndex1+1, commaIndex2);
        return TicketNameRetrieve;
        break;
      case 3:
        TicketTypeRetrieve = TicketString.substring (commaIndex2+1, lengthString);
        return TicketTypeRetrieve;
        break;
      default:
        return "empty";
        Serial.println (F("this is not an acceptable input"));
        break;
    }
}
Example #12
0
String htmlTagFilter(const String& input)
{
    String out = input;
    out.replace("<", "&lt;");
    out.replace(">", "&gt;");
    return out;
}
Example #13
0
static String _escape_string(const String &p_str) {

	String ret = p_str;
	ret = ret.replace("&", "&amp;");
	ret = ret.replace("<", "&gt;");
	ret = ret.replace(">", "&lt;");
	ret = ret.replace("'", "&apos;");
	ret = ret.replace("\"", "&quot;");
	for (char i = 1; i < 32; i++) {

		char chr[2] = { i, 0 };
		ret = ret.replace(chr, "&#" + String::num(i) + ";");
	}
	ret = ret.utf8();
	return ret;
}
Example #14
0
/**
NormaliseDestFile: Normalise the destination file

@internalComponent
@released

@param aFile - Input file name
*/
void Sis2Iby::NormaliseDestFile(String& aFile)
{
    TUint pos = 0;

    /** Comment by KunXu to fix DEF122540 on 18 Jun 2008
    pos = aFile.find("$:");
    if(pos != String::npos)
    {
    	aFile.replace(pos, 2, "");
    }

    pos = aFile.find("!:");
    if(pos != String::npos)
    {
    	aFile.replace(pos, 2, "");
    }
    **/

    /** Add by KunXu to fix DEF122540 on 18 Jun 2008 **/
    /** Ignore any drive indication in the filename to generate an iby file **/
    /** Begin **/
    pos = aFile.find(":");
    if (1 == pos)
    {
        char chFirst = aFile[0];
        if ('$' == chFirst || '!' == chFirst || (chFirst >='a' && chFirst <='z') || (chFirst >='A' && chFirst <='Z'))
        {
            aFile.replace(0, 2, "");
        }
    }
    /** End **/

    aFile = "\"" + aFile + "\"";
}
Example #15
0
//==============================================================================
bool Process::openDocument (const String& fileName, const String& parameters)
{
    String cmdString (fileName.replace (" ", "\\ ",false));
    cmdString << " " << parameters;

    if (URL::isProbablyAWebsiteURL (fileName)
         || cmdString.startsWithIgnoreCase ("file:")
         || URL::isProbablyAnEmailAddress (fileName))
    {
        // create a command that tries to launch a bunch of likely browsers
        const char* const browserNames[] = { "xdg-open", "/etc/alternatives/x-www-browser", "firefox", "mozilla", "konqueror", "opera" };

        StringArray cmdLines;

        for (int i = 0; i < numElementsInArray (browserNames); ++i)
            cmdLines.add (String (browserNames[i]) + " " + cmdString.trim().quoted());

        cmdString = cmdLines.joinIntoString (" || ");
    }

    const char* const argv[4] = { "/bin/sh", "-c", cmdString.toUTF8(), 0 };

    const int cpid = fork();

    if (cpid == 0)
    {
        setsid();

        // Child process
        execve (argv[0], (char**) argv, environ);
        exit (0);
    }

    return cpid >= 0;
}
Example #16
0
//==============================================================================
static File resolveXDGFolder (const char* const type, const char* const fallbackFolder)
{
    File userDirs ("~/.config/user-dirs.dirs");
    StringArray confLines;

    if (userDirs.existsAsFile())
    {
        FileInputStream in (userDirs);

        if (in.openedOk())
            confLines.addLines (in.readEntireStreamAsString());
    }

    for (int i = 0; i < confLines.size(); ++i)
    {
        const String line (confLines[i].trimStart());

        if (line.startsWith (type))
        {
            // eg. resolve XDG_MUSIC_DIR="$HOME/Music" to /home/user/Music
            const File f (line.replace ("$HOME", File ("~").getFullPathName())
                          .fromFirstOccurrenceOf ("=", false, false)
                          .trim().unquoted());

            if (f.isDirectory())
                return f;
        }
    }

    return File (fallbackFolder);
}
bool PusherClient::connect()
{   
	String stringVar0; 
	String path; 
	String host; 
	String key;
	
	getStringTableItem(0, stringVar0);
    getStringTableItem(3, path);	
    getStringTableItem(4, host);	
    getPusherInfoItem(1, key);	
    path.replace(stringVar0, key);

    if (!_client.connect(host, path, 80))
	{
		LogPrintLn(logMessageTablePusherClient, 0);
		return false;
	}	
	
#if (ENABLE_AUTH == 1)
	while(_socketid.length() == 0)
	{
		delay(100);
		monitor();
	}
#endif
	
	LogPrintLn(logMessageTablePusherClient, 1);
	return true;
}
Example #18
0
  static bool canFileBeReincluded (File const& f)
  {
    String content (f.loadFileAsString());

    for (;;)
    {
      content = content.trimStart();

      if (content.startsWith ("//"))
        content = content.fromFirstOccurrenceOf ("\n", false, false);
      else if (content.startsWith ("/*"))
        content = content.fromFirstOccurrenceOf ("*/", false, false);
      else
        break;
    }

    StringArray lines;
    lines.addLines (content);
    lines.trim();
    lines.removeEmptyStrings();

    const String l1 (lines[0].removeCharacters (" \t").trim());
    const String l2 (lines[1].removeCharacters (" \t").trim());

    bool result;
    if (l1.replace ("#ifndef", "#define") == l2)
      result = false;
    else
      result = true;

    return result;
  }
Example #19
0
Value::Text DictionaryValue::asText() const
{
    Text result;
    QTextStream s(&result);
    s << "{";

    bool isFirst = true;
    bool hadNewline = false;

    // Compose a textual representation of the array elements.
    for (Elements::const_iterator i = _elements.begin(); i != _elements.end(); ++i)
    {
        String const label = i->first.value->asText() + ": ";
        String content = i->second->asText();
        bool const multiline = content.contains('\n');
        if (!isFirst)
        {
            if (hadNewline || multiline) s << "\n";
            s << ",";
        }
        hadNewline = multiline;
        s << " " << label << content.replace("\n", "\n" + String(label.size() + 2, ' '));
        isFirst = false;
    }

    s << " }";
    return result;
}
Example #20
0
    void parseRawUri(String rawUri, QChar sep, resourceclassid_t defaultResourceClass)
    {
        LOG_AS("Uri::parseRawUri");

        clearCachedResolved();

        scheme = extractScheme(rawUri); // scheme removed
        if(sep != '/') rawUri.replace(sep, '/'); // force slashes as separator
        path = rawUri;
        strPath = path.toString(); // for legacy code

        if(!scheme.isEmpty())
        {
            if(defaultResourceClass == RC_NULL || App_FileSystem().knownScheme(scheme))
            {
                // Scheme is accepted as is.
                return;
            }
            LOG_RES_WARNING("Unknown scheme \"%s\" for path \"%s\", using default scheme instead") << scheme << strPath;
        }

        // Attempt to guess the scheme by interpreting the path?
        if(defaultResourceClass == RC_UNKNOWN)
        {
            defaultResourceClass = DD_GuessFileTypeFromFileName(strPath).defaultClass();
        }

        if(VALID_RESOURCECLASSID(defaultResourceClass))
        {
            FS1::Scheme &fsScheme = App_FileSystem().scheme(ResourceClass::classForId(defaultResourceClass).defaultScheme());
            scheme = fsScheme.name();
        }
    }
Example #21
0
static String matchLabelsAgainstString(const Vector<String>& labels, const String& stringToMatch)
{
    if (stringToMatch.isEmpty())
        return String();

    String mutableStringToMatch = stringToMatch;

    // Make numbers and _'s in field names behave like word boundaries, e.g., "address2"
    replace(mutableStringToMatch, RegularExpression("\\d", TextCaseSensitive), " ");
    mutableStringToMatch.replace('_', ' ');

    OwnPtr<RegularExpression> regExp(createRegExpForLabels(labels));
    // Use the largest match we can find in the whole string
    int pos;
    int length;
    int bestPos = -1;
    int bestLength = -1;
    int start = 0;
    do {
        pos = regExp->match(mutableStringToMatch, start);
        if (pos != -1) {
            length = regExp->matchedLength();
            if (length >= bestLength) {
                bestPos = pos;
                bestLength = length;
            }
            start = pos + 1;
        }
    } while (pos != -1);

    if (bestPos != -1)
        return mutableStringToMatch.substring(bestPos, bestLength);
    return String();
}
Example #22
0
void HTMLElement::setInnerText(const String& text, ExceptionCode& ec)
{
    if (ieForbidsInsertHTML()) {
        ec = NO_MODIFICATION_ALLOWED_ERR;
        return;
    }
    if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag) ||
            hasLocalName(headTag) || hasLocalName(htmlTag) || hasLocalName(tableTag) ||
            hasLocalName(tbodyTag) || hasLocalName(tfootTag) || hasLocalName(theadTag) ||
            hasLocalName(trTag)) {
        ec = NO_MODIFICATION_ALLOWED_ERR;
        return;
    }

    // FIXME: This doesn't take whitespace collapsing into account at all.

    if (!text.contains('\n') && !text.contains('\r')) {
        if (text.isEmpty()) {
            removeChildren();
            return;
        }
        replaceChildrenWithText(this, text, ec);
        return;
    }

    // FIXME: Do we need to be able to detect preserveNewline style even when there's no renderer?
    // FIXME: Can the renderer be out of date here? Do we need to call updateStyleIfNeeded?
    // For example, for the contents of textarea elements that are display:none?
    RenderObject* r = renderer();
    if (r && r->style()->preserveNewline()) {
        if (!text.contains('\r')) {
            replaceChildrenWithText(this, text, ec);
            return;
        }
        String textWithConsistentLineBreaks = text;
        textWithConsistentLineBreaks.replace("\r\n", "\n");
        textWithConsistentLineBreaks.replace('\r', '\n');
        replaceChildrenWithText(this, textWithConsistentLineBreaks, ec);
        return;
    }

    // Add text nodes and <br> elements.
    ec = 0;
    RefPtr<DocumentFragment> fragment = textToFragment(text, ec);
    if (!ec)
        replaceChildrenWithFragment(this, fragment.release(), ec);
}
void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventBehavior eventBehavior, SetValueCommonOption setValueOption)
{
    // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
    // We normalize line endings coming from JavaScript here.
    String normalizedValue = newValue.isNull() ? "" : newValue;
    normalizedValue.replace("\r\n", "\n");
    normalizedValue.replace('\r', '\n');

    // Return early because we don't want to trigger other side effects
    // when the value isn't changing.
    // FIXME: Simple early return doesn't match the Firefox ever.
    // Remove these lines.
    if (normalizedValue == value()) {
        if (setValueOption == SetSeletion) {
            setNeedsValidityCheck();
            if (isFinishedParsingChildren()) {
                // Set the caret to the end of the text value except for initialize.
                unsigned endOfString = m_value.length();
                setSelectionRange(endOfString, endOfString, SelectionHasNoDirection, NotDispatchSelectEvent, ChangeSelectionIfFocused);
            }
        }
        return;
    }

    m_value = normalizedValue;
    setInnerEditorValue(m_value);
    if (eventBehavior == DispatchNoEvent)
        setLastChangeWasNotUserEdit();
    updatePlaceholderVisibility();
    setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::ControlValue));
    m_suggestedValue = String();
    setNeedsValidityCheck();
    if (isFinishedParsingChildren()) {
        // Set the caret to the end of the text value except for initialize.
        unsigned endOfString = m_value.length();
        setSelectionRange(endOfString, endOfString, SelectionHasNoDirection, NotDispatchSelectEvent, ChangeSelectionIfFocused);
    }

    notifyFormStateChanged();
    if (eventBehavior == DispatchNoEvent) {
        setTextAsOfLastFormControlChangeEvent(normalizedValue);
    } else {
        if (eventBehavior == DispatchInputAndChangeEvent)
            dispatchFormControlInputEvent();
        dispatchFormControlChangeEvent();
    }
}
Example #24
0
void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement1, const String& replacement2)
{
    Frame* frame = document->frame();
    if (!frame)
        return;

    String message = viewportErrorMessageTemplate(errorCode);
    if (!replacement1.isNull())
        message.replace("%replacement1", replacement1);
    if (!replacement2.isNull())
        message.replace("%replacement2", replacement2);

    if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == TruncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound)
        message.append(" Note that ';' is not a separator in viewport values. The list should be comma-separated.");

    document->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, document->url().string(), parserLineNumber(document));
}
Example #25
0
void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement1, const String& replacement2)
{
    Frame* frame = document->frame();
    if (!frame)
        return;

    String message = viewportErrorMessageTemplate(errorCode);
// SAMSUNG_CHANGES >> MPSG100005911  Removing URL exposure in logs
    String blockUrlDisplay = "";
    if (!replacement1.isNull())
        message.replace("%replacement1", replacement1);
    if (!replacement2.isNull())
        message.replace("%replacement2", replacement2);

    frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, parserLineNumber(document), blockUrlDisplay);
// SAMSUNG_CHANGES <<
}
Example #26
0
void OSBasics::removeItem(const String& pathString) {
#ifdef _WINDOWS
	 String _tmp = pathString.replace("/", "\\");
	 DeleteFile(_tmp.getWDataWithEncoding(String::ENCODING_UTF8));
#else
	remove(pathString.c_str());
#endif	
}
Example #27
0
//TODO: use callback when file not found?
String CApplication::useFile( const char* filename )
{
    String file;

    //if ( fileExists( filename ) )
    //  APPLOG.Write( "------------- '%s'  - %i", filename, fileExists2( filename ) );

    if ( fileExists2( filename ) )
    {
      file = filename;
      file.replace( '\\', '/' );
      if ( filesUsed.binary_search( file ) == -1 )
      {
        filesUsed.push_back( file );
        APPLOG.Write( "Using file '%s'", file.c_str() );
        //if ( (strstr(file.c_str(), ".gm")) == 0 )
        network->fileVerifier->AddFileForVerification( ( char* )file.c_str(), false );
      }
    }
    else
    {
      file = "../";
      file += DEFAULT_MODDIR;
      file += "/";
      file += filename;
      file.replace( '\\', '/' );
      if ( fileExists2( file.c_str() ) )
      {
        if ( filesUsed.binary_search( file ) == -1 )
        {
          filesUsed.push_back( file );
          APPLOG.Write( "File not found. Using default file '%s'", file.c_str() );

          //if ( (strstr(file.c_str(), ".gm")) == 0 )
          network->fileVerifier->AddFileForVerification( ( char* )file.c_str(), false );
        }
      }
      else
      {
        APPLOG.Write( "File not found '%s'", filename );
        //
      }
    }

    return file;
}
static YouTubePluginReplacement::KeyValueMap queryKeysAndValues(const String& queryString)
{
    YouTubePluginReplacement::KeyValueMap queryDictionary;
    
    size_t queryLength = queryString.length();
    if (!queryLength)
        return queryDictionary;
    
    size_t equalSearchLocation = 0;
    size_t equalSearchLength = queryLength;
    
    while (equalSearchLocation < queryLength - 1 && equalSearchLength) {
        
        // Search for "=".
        size_t equalLocation = queryString.find('=', equalSearchLocation);
        if (equalLocation == notFound)
            break;
        
        size_t indexAfterEqual = equalLocation + 1;
        if (indexAfterEqual > queryLength - 1)
            break;
        
        // Get the key before the "=".
        size_t keyLocation = equalSearchLocation;
        size_t keyLength = equalLocation - equalSearchLocation;
        
        // Seach for the ampersand.
        size_t ampersandLocation = queryString.find('&', indexAfterEqual);
        
        // Get the value after the "=", before the ampersand.
        size_t valueLocation = indexAfterEqual;
        size_t valueLength;
        if (ampersandLocation != notFound)
            valueLength = ampersandLocation - indexAfterEqual;
        else
            valueLength = queryLength - indexAfterEqual;
        
        // Save the key and the value.
        if (keyLength && valueLength) {
            const String& key = queryString.substring(keyLocation, keyLength).lower();
            String value = queryString.substring(valueLocation, valueLength);
            value.replace('+', ' ');

            if (!key.isEmpty() && !value.isEmpty())
                queryDictionary.add(key, value);
        }
        
        if (ampersandLocation == notFound)
            break;
        
        // Continue searching after the ampersand.
        size_t indexAfterAmpersand = ampersandLocation + 1;
        equalSearchLocation = indexAfterAmpersand;
        equalSearchLength = queryLength - indexAfterAmpersand;
    }
    
    return queryDictionary;
}
Example #29
0
String RenameDialog::_substitute(const String &subject, const Node *node, int count) {

	String result = subject.replace("${COUNTER}", vformat("%0" + itos(spn_count_padding->get_value()) + "d", count));

	if (node) {
		result = result.replace("${NAME}", node->get_name());
		result = result.replace("${TYPE}", node->get_class());
	}

	int current = EditorNode::get_singleton()->get_editor_data().get_edited_scene();
	result = result.replace("${SCENE}", EditorNode::get_singleton()->get_editor_data().get_scene_title(current));

	Node *root_node = SceneTree::get_singleton()->get_edited_scene_root();
	if (root_node) {
		result = result.replace("${ROOT}", root_node->get_name());
	}

	Node *parent_node = node->get_parent();
	if (parent_node) {
		if (node == root_node) {
			// Can not substitute parent of root.
			result = result.replace("${PARENT}", "");
		} else {
			result = result.replace("${PARENT}", parent_node->get_name());
		}
	}

	return result;
}
Example #30
0
void HTMLAnchorElement::setSearch(const String& value)
{
    KURL url = href();
    String newSearch = (value[0] == '?') ? value.substring(1) : value;
    // Make sure that '#' in the query does not leak to the hash.
    url.setQuery(newSearch.replace('#', "%23"));

    setHref(url.string());
}