Example #1
0
void WebInspectorServer::didReceiveUnrecognizedHTTPRequest(WebSocketServerConnection* connection, PassRefPtr<HTTPRequest> request)
{
    // request->url() contains only the path extracted from the HTTP request line
    // and URL is poor at parsing incomplete URLs, so extract the interesting parts manually.
    String path = request->url();
    size_t pathEnd = path.find('?');
    if (pathEnd == notFound)
        pathEnd = path.find('#');
    if (pathEnd != notFound)
        path.truncate(pathEnd);

    // Ask for the complete payload in memory for the sake of simplicity. A more efficient way would be
    // to ask for header data and then let the platform abstraction write the payload straight on the connection.
    Vector<char> body;
    String contentType;
    bool found = platformResourceForPath(path, body, contentType);

    HTTPHeaderMap headerFields;
    headerFields.set("Connection", "close");
    headerFields.set("Content-Length", String::number(body.size()));
    if (found)
        headerFields.set("Content-Type", contentType);

    // Send when ready and close immediately afterwards.
    connection->sendHTTPResponseHeader(found ? 200 : 404, found ? "OK" : "Not Found", headerFields);
    connection->sendRawData(body.data(), body.size());
    connection->shutdownAfterSendOrNow();
}
Example #2
0
void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, MutableStylePropertySet* style)
{
    if (!value.isEmpty()) {
        // Have to quote so the locale id is treated as a string instead of as a CSS keyword.
        addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, quoteCSSString(value));

        // FIXME: Remove the following UseCounter code when we collect enough
        // data.
        UseCounter::count(document(), UseCounter::LangAttribute);
        if (isHTMLHtmlElement(*this))
            UseCounter::count(document(), UseCounter::LangAttributeOnHTML);
        else if (isHTMLBodyElement(*this))
            UseCounter::count(document(), UseCounter::LangAttributeOnBody);
        String htmlLanguage = value.string();
        size_t firstSeparator = htmlLanguage.find('-');
        if (firstSeparator != kNotFound)
            htmlLanguage = htmlLanguage.left(firstSeparator);
        String uiLanguage = defaultLanguage();
        firstSeparator = uiLanguage.find('-');
        if (firstSeparator != kNotFound)
            uiLanguage = uiLanguage.left(firstSeparator);
        firstSeparator = uiLanguage.find('_');
        if (firstSeparator != kNotFound)
            uiLanguage = uiLanguage.left(firstSeparator);
        if (!equalIgnoringCase(htmlLanguage, uiLanguage))
            UseCounter::count(document(), UseCounter::LangAttributeDoesNotMatchToUILocale);
    } else {
        // The empty string means the language is explicitly unknown.
        addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, CSSValueAuto);
    }
}
Example #3
0
StringName ConnectDialog::get_dst_method_name() const {

	String txt = dst_method->get_text();
	if (txt.find("(") != -1)
		txt = txt.left(txt.find("(")).strip_edges();
	return txt;
}
Example #4
0
PassRefPtr<SecurityOrigin> SecurityOrigin::createFromDatabaseIdentifier(const String& databaseIdentifier)
{ 
    // Make sure there's a first separator
    int separator1 = databaseIdentifier.find(SeparatorCharacter);
    if (separator1 == -1)
        return create(KURL());
        
    // Make sure there's a second separator
    int separator2 = databaseIdentifier.find(SeparatorCharacter, separator1 + 1);
    if (separator2 == -1)
        return create(KURL());
        
    // Make sure there's not a third separator
    if (databaseIdentifier.reverseFind(SeparatorCharacter) != separator2)
        return create(KURL());
        
    // Make sure the port section is a valid port number or doesn't exist
    bool portOkay;
    int port = databaseIdentifier.right(databaseIdentifier.length() - separator2 - 1).toInt(&portOkay);
    if (!portOkay && separator2 + 1 == static_cast<int>(databaseIdentifier.length()))
        return create(KURL());
    
    if (port < 0 || port > 65535)
        return create(KURL());
        
    // Split out the 3 sections of data
    String protocol = databaseIdentifier.substring(0, separator1);
    String host = databaseIdentifier.substring(separator1 + 1, separator2 - separator1 - 1);
    return create(KURL(KURL(), protocol + "://" + host + ":" + String::number(port)));
}
Example #5
0
void ContextGL_X11::set_use_vsync(bool p_use) {
	static bool setup = false;
	static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = NULL;
	static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA = NULL;
	static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;

	if (!setup) {
		setup = true;
		String extensions = glXQueryExtensionsString(x11_display, DefaultScreen(x11_display));
		if (extensions.find("GLX_EXT_swap_control") != -1)
			glXSwapIntervalEXT  = (PFNGLXSWAPINTERVALEXTPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalEXT");
		if (extensions.find("GLX_MESA_swap_control") != -1)
			glXSwapIntervalMESA = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalMESA");
		if (extensions.find("GLX_SGI_swap_control") != -1)
			glXSwapIntervalSGI  = (PFNGLXSWAPINTERVALSGIPROC) glXGetProcAddressARB((const GLubyte*)"glXSwapIntervalSGI");
	}
	int val = p_use ? 1:0;
	if (glXSwapIntervalMESA) {
		glXSwapIntervalMESA(val);
	}
	else if (glXSwapIntervalSGI) {
		glXSwapIntervalSGI(val);
	}
	else if (glXSwapIntervalEXT) {
		GLXDrawable drawable = glXGetCurrentDrawable();
		glXSwapIntervalEXT(x11_display, drawable, val);
	}
	else return;
	use_vsync = p_use;
}
void AnimationPlayerEditor::_file_selected(String p_file) {

	ERR_FAIL_COND(!player);

	Ref<Resource> res = ResourceLoader::load(p_file,"Animation");
	ERR_FAIL_COND(res.is_null());
	ERR_FAIL_COND( !res->is_type("Animation") );
	if (p_file.find_last("/")!=-1) {

		p_file=p_file.substr( p_file.find_last("/")+1, p_file.length() );

	}
	if (p_file.find_last("\\")!=-1) {

		p_file=p_file.substr( p_file.find_last("\\")+1, p_file.length() );

	}

	if (p_file.find(".")!=-1)
		p_file=p_file.substr(0,p_file.find("."));

	undo_redo->create_action("Load Animation");
	undo_redo->add_do_method(player,"add_animation",p_file,res);
	undo_redo->add_undo_method(player,"remove_animation",p_file);
	if (player->has_animation(p_file)) {
		undo_redo->add_undo_method(player,"add_animation",p_file,player->get_animation(p_file));

	}
	undo_redo->add_do_method(this,"_animation_player_changed",player);
	undo_redo->add_undo_method(this,"_animation_player_changed",player);
	undo_redo->commit_action();

}
SMILTime SVGSMILElement::parseClockValue(const String& data)
{
    if (data.isNull())
        return SMILTime::unresolved();

    String parse = data.stripWhiteSpace();

    DEFINE_STATIC_LOCAL(const AtomicString, indefiniteValue, ("indefinite"));
    if (parse == indefiniteValue)
        return SMILTime::indefinite();

    double result = 0;
    bool ok;
    size_t doublePointOne = parse.find(':');
    size_t doublePointTwo = parse.find(':', doublePointOne + 1);
    if (doublePointOne == 2 && doublePointTwo == 5 && parse.length() >= 8) {
        result += parse.substring(0, 2).toUIntStrict(&ok) * 60 * 60;
        if (!ok)
            return SMILTime::unresolved();
        result += parse.substring(3, 2).toUIntStrict(&ok) * 60;
        if (!ok)
            return SMILTime::unresolved();
        result += parse.substring(6).toDouble(&ok);
    } else if (doublePointOne == 2 && doublePointTwo == kNotFound && parse.length() >= 5) {
        result += parse.substring(0, 2).toUIntStrict(&ok) * 60;
        if (!ok)
            return SMILTime::unresolved();
        result += parse.substring(3).toDouble(&ok);
    } else
        return parseOffsetValue(parse);

    if (!ok || !SMILTime(result).isFinite())
        return SMILTime::unresolved();
    return result;
}
Example #8
0
static String f2sp0(float p_float) {

	String num = rtoss(p_float);
	if (num.find(".") == -1 && num.find("e") == -1) {
		num += ".0";
	}
	return num;
}
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 #10
0
bool VPathNode::fromString( const String &pString )
{
    // Split Data.
    // {Position} {Rotation} {Weight}
    const char *baseData = StringUnit::getUnit( pString.c_str(), 0, "\t" );

    Point3F  pos;
    AngAxisF aa;
    F32      weight;

    // Scan Base.
    dSscanf( baseData, "%g %g %g %g %g %g %g %g", &pos.x, &pos.y, &pos.z,
                                                  &aa.axis.x, &aa.axis.y, &aa.axis.z, &aa.angle,
                                                  &weight );

    // Apply Changes.
    setLocalPosition( pos );
    setLocalRotation( QuatF( aa ) );
    setWeight( weight );

    // Fetch Orientation Data.
    String orientationData = StringUnit::getUnit( pString.c_str(), 1, "\t" );

    // Fetch Orientation Type.
    String orientationTypeString = orientationData;
    if ( orientationData.find( " " ) )
    {
        // Use First Word.
        orientationTypeString = orientationData.substr( 0, orientationData.find( " " ) );
    }

    // Set Orientation Type.
    const eOrientationType &orientationType = getOrientationTypeEnum( orientationTypeString.c_str() );
    switch( orientationType )
    {
        case k_OrientationFree : 
            {
                // Apply Mode.
                setOrientationMode( orientationType );

            } break;

        case k_OrientationToPoint:
            {
                // Fetch Point.
                Point3F lookAtPoint;
                // Buffer String.
                dSscanf( orientationData.c_str(), "%*s %f %f %f", &lookAtPoint.x, &lookAtPoint.y, &lookAtPoint.z );

                // Apply Mode.
                setOrientationMode( orientationType, lookAtPoint );

            } break;
    }

    return true;
}
Example #11
0
	bool operator<(const _ConstantSort &p_c) const {

		String left_a = name.find("_") == -1 ? name : name.substr(0, name.find("_"));
		String left_b = p_c.name.find("_") == -1 ? p_c.name : p_c.name.substr(0, p_c.name.find("_"));
		if (left_a == left_b)
			return value < p_c.value;
		else
			return left_a < left_b;
	}
Example #12
0
void AnimationNode::add_input(const String &p_name) {
	//root nodes can't add inputs
	ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != NULL)
	Input input;
	ERR_FAIL_COND(p_name.find(".") != -1 || p_name.find("/") != -1);
	input.name = p_name;
	inputs.push_back(input);
	emit_changed();
}
void MediaFragmentURIParser::parseFragments()
{
    if (!m_url.hasFragmentIdentifier())
        return;
    String fragmentString = m_url.fragmentIdentifier();
    if (fragmentString.isEmpty())
        return;

    unsigned offset = 0;
    unsigned end = fragmentString.length();
    while (offset < end) {
        // http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#processing-name-value-components
        // 1. Parse the octet string according to the namevalues syntax, yielding a list of 
        //    name-value pairs, where name and value are both octet string. In accordance 
        //    with RFC 3986, the name and value components must be parsed and separated before
        //    percent-encoded octets are decoded.
        size_t parameterStart = offset;
        size_t parameterEnd = fragmentString.find('&', offset);
        if (parameterEnd == notFound)
            parameterEnd = end;

        size_t equalOffset = fragmentString.find('=', offset);
        if (equalOffset == notFound || equalOffset > parameterEnd) {
            offset = parameterEnd + 1;
            continue;
        }

        // 2. For each name-value pair:
        //  a. Decode percent-encoded octets in name and value as defined by RFC 3986. If either
        //     name or value are not valid percent-encoded strings, then remove the name-value pair
        //     from the list.
        String name = decodeURLEscapeSequences(fragmentString.substring(parameterStart, equalOffset - parameterStart));
        String value;
        if (equalOffset != parameterEnd)
            value = decodeURLEscapeSequences(fragmentString.substring(equalOffset + 1, parameterEnd - equalOffset - 1));
        
        //  b. Convert name and value to Unicode strings by interpreting them as UTF-8. If either
        //     name or value are not valid UTF-8 strings, then remove the name-value pair from the list.
        bool validUTF8 = false;
        if (!name.isEmpty() && !value.isEmpty()) {
            name = name.utf8(StrictConversion).data();
            validUTF8 = !name.isEmpty();

            if (validUTF8) {
                value = value.utf8(StrictConversion).data();
                validUTF8 = !value.isEmpty();
            }
        }
        
        if (validUTF8)
            m_fragments.append(std::make_pair(name, value));

        offset = parameterEnd + 1;
    }
}
String YouTubePluginReplacement::youTubeURL(const String& srcString)
{
    URL srcURL = m_parentElement->document().completeURL(stripLeadingAndTrailingHTMLSpaces(srcString));

    bool isYouTubeShortenedURL = false;
    URL youTubeURL = processAndCreateYouTubeURL(srcURL, isYouTubeShortenedURL);
    if (srcURL.isEmpty() || youTubeURL.isEmpty())
        return srcString;

    // Transform the youtubeURL (youtube:VideoID) to iframe embed url which has the format: http://www.youtube.com/embed/VideoID
    const String& srcPath = srcURL.path();
    const String& videoID = youTubeURL.string().substring(youTubeURL.protocol().length() + 1);
    size_t locationOfVideoIDInPath = srcPath.find(videoID);

    size_t locationOfPathBeforeVideoID = notFound;
    if (locationOfVideoIDInPath != notFound) {
        ASSERT(locationOfVideoIDInPath);
    
        // From the original URL, we need to get the part before /path/VideoId.
        locationOfPathBeforeVideoID = srcString.find(srcPath.substring(0, locationOfVideoIDInPath));
    } else if (srcPath.lower() == "/watch") {
        // From the original URL, we need to get the part before /watch/#!v=VideoID
        locationOfPathBeforeVideoID = srcString.find("/watch");
    } else
        return srcString;

    ASSERT(locationOfPathBeforeVideoID != notFound);

    const String& srcURLPrefix = srcString.substring(0, locationOfPathBeforeVideoID);
    String query = srcURL.query();

    // By default, the iframe will display information like the video title and uploader on top of the video. Don't display
    // them if the embeding html doesn't specify it.
    if (!query.isEmpty() && !query.contains("showinfo"))
        query.append("&showinfo=0");
    else
        query = "showinfo=0";
    
    // Append the query string if it is valid. Some sites apparently forget to add "?" for the query string, in that case,
    // we will discard the parameters in the url.
    // See: <rdar://problem/11535155>
    StringBuilder finalURL;
    if (isYouTubeShortenedURL)
        finalURL.append("http://www.youtube.com");
    else
        finalURL.append(srcURLPrefix);
    finalURL.appendLiteral("/embed/");
    finalURL.append(videoID);
    if (!query.isEmpty()) {
        finalURL.appendLiteral("?");
        finalURL.append(query);
    }
    return finalURL.toString();
}
Example #15
0
String SVGURIReference::getTarget(const String& url)
{
    if (url.startsWith("url(")) { // URI References, ie. fill:url(#target)
        size_t start = url.find('#') + 1;
        size_t end = url.reverseFind(')');
        return url.substring(start, end - start);
    } else if (url.find('#') != notFound) { // format is #target
        size_t start = url.find('#') + 1;
        return url.substring(start, url.length() - start);
    } else // The url doesn't have any target.
        return String();
}
Example #16
0
static int numberOfReplacedElementsBeforeOffset(AtkText* text, unsigned offset)
{
    GOwnPtr<char> textForObject(webkitAccessibleTextGetText(text, 0, offset));
    String textBeforeOffset = String::fromUTF8(textForObject.get());

    int count = 0;
    size_t index = textBeforeOffset.find(objectReplacementCharacter, 0);
    while (index < offset && index != WTF::notFound) {
        index = textBeforeOffset.find(objectReplacementCharacter, index + 1);
        count++;
    }
    return count;
}
String mimeTypeFromDataURL(const String& url)
{
    ASSERT(protocolIs(url, "data"));
    size_t index = url.find(';');
    if (index == kNotFound)
        index = url.find(',');
    if (index != kNotFound) {
        if (index > 5)
            return url.substring(5, index - 5).lower();
        return "text/plain"; // Data URLs with no MIME type are considered text/plain.
    }
    return "";
}
Example #18
0
String SVGURIReference::getTarget(const String& url)
{
    if (url.startsWith("url(")) { // URI References, ie. fill:url(#target)
        unsigned int start = url.find('#') + 1;
        unsigned int end = url.reverseFind(')');

        return url.substring(start, end - start);
    } else if (url.find('#') > -1) { // format is #target
        unsigned int start = url.find('#') + 1;
        return url.substring(start, url.length() - start);
    } else // Normal Reference, ie. style="color-profile:changeColor"
        return url;
}
Example #19
0
BlobLocator* Database::newLocator(const String& name, const String& path)
{
	if (path.empty())
		NIT_THROW(EX_INVALID_PARAMS);

	size_t pos;

	pos = path.find('/');

	bool ok = true;

	if (pos == path.npos)
		ok = false;

	String dbName;
	String tblName;
	String blobColumn;
	String idColumn = "rowid";

	if (ok)
	{
		tblName = path.substr(0, pos);
		blobColumn = path.substr(pos+1);

		pos = tblName.find('.');

		if (pos != tblName.npos)
		{
			dbName = tblName.substr(0, pos);
			tblName = tblName.substr(pos + 1);
		}

		pos = blobColumn.find('.');

		if (pos != blobColumn.npos)
		{
			idColumn = blobColumn.substr(pos + 1);
			blobColumn = blobColumn.substr(0, pos);
		}
	}

	ok = ok && !tblName.empty();
	ok = ok && !blobColumn.empty();
	ok = ok && !idColumn.empty();

	if (!ok)
		NIT_THROW_FMT(EX_INVALID_PARAMS, "invalid db locator path: '%s: %s'", name.c_str(), path.c_str());

	return new BlobLocator(name, this, tblName, blobColumn, idColumn, dbName);
}
void AnimationPlayerEditor::_dialog_action(String p_file) {

    switch (current_option) {
    case RESOURCE_LOAD: {
        ERR_FAIL_COND(!player);

        Ref<Resource> res = ResourceLoader::load(p_file, "Animation");
        ERR_FAIL_COND(res.is_null());
        ERR_FAIL_COND(!res->is_type("Animation"));
        if (p_file.find_last("/") != -1) {

            p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length());

        }
        if (p_file.find_last("\\") != -1) {

            p_file = p_file.substr(p_file.find_last("\\") + 1, p_file.length());

        }

        if (p_file.find(".") != -1)
            p_file = p_file.substr(0, p_file.find("."));

        undo_redo->create_action(TTR("Load Animation"));
        undo_redo->add_do_method(player, "add_animation", p_file, res);
        undo_redo->add_undo_method(player, "remove_animation", p_file);
        if (player->has_animation(p_file)) {
            undo_redo->add_undo_method(player, "add_animation", p_file, player->get_animation(p_file));

        }
        undo_redo->add_do_method(this, "_animation_player_changed", player);
        undo_redo->add_undo_method(this, "_animation_player_changed", player);
        undo_redo->commit_action();
        break;
    }
    case RESOURCE_SAVE: {

        String current = animation->get_item_text(animation->get_selected());
        if (current != "") {
            Ref<Animation> anim = player->get_animation(current);

            ERR_FAIL_COND(!anim->cast_to<Resource>())

            RES current_res = RES(anim->cast_to<Resource>());

            _animation_save_in_path(current_res, p_file);
        }
    }
    }
}
Example #21
0
StringList StringList::split(const String &s, const String &pattern)
{
  StringList l;

  int previousOffset = 0;
  for(int offset = s.find(pattern); offset != -1; offset = s.find(pattern, offset + 1)) {
    l.append(s.substr(previousOffset, offset - previousOffset));
    previousOffset = offset + 1;
  }

  l.append(s.substr(previousOffset, s.size() - previousOffset));

  return l;
}
Example #22
0
void DuplicateAmpersand(String& str)
{
	String::size_type pos= str.find(_T('&'), 0);

	while (pos != String::npos)
	{
		str.insert(pos, _T("&"));
		pos += 2;

		if (pos >= str.length())
			break;

		pos = str.find(_T('&'), pos);
	}
}
Example #23
0
    //---------------------------------
    void Utils::stringFindAndReplace ( String &source, const String searchString, const String replaceString )
    {
        size_t found = source.find ( searchString );
        if ( found != String::npos )
        {
            size_t searchStrLength = searchString.length();
            size_t replaceStrLength = replaceString.length();
            do
            {
                source.replace ( found, searchStrLength, replaceString );
                found = source.find (searchString, found + replaceStrLength );
            } while ( found != String::npos );
        }

    }
Example #24
0
float WebVTTParser::parseFloatPercentageValue(const String& value, bool& isValidSetting)
{
    // '%' must be present and at the end of the setting value.
    if (value.find('%', 1) != value.length() - 1) {
        isValidSetting = false;
        return 0;
    }

    unsigned position = 0;

    StringBuilder floatNumberAsString;
    floatNumberAsString.append(WebVTTParser::collectDigits(value, &position));

    if (value[position] == '.') {
        floatNumberAsString.append(".");
        position++;

        floatNumberAsString.append(WebVTTParser::collectDigits(value, &position));
    }
    float number = floatNumberAsString.toString().toFloat(&isValidSetting);

    if (isValidSetting && (number <= 0 || number >= 100))
        isValidSetting = false;

    return number;
}
static bool verifyCustomHandlerURL(const String& baseURL, const String& url, ExceptionCode& ec)
{
    // The specification requires that it is a SYNTAX_ERR if the "%s" token is
    // not present.
    static const char token[] = "%s";
    int index = url.find(token);
    if (-1 == index) {
        ec = SYNTAX_ERR;
        return false;
    }

    // It is also a SYNTAX_ERR if the custom handler URL, as created by removing
    // the "%s" token and prepending the base url, does not resolve.
    String newURL = url;
    newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1);

    URL base(ParsedURLString, baseURL);
    URL kurl(base, newURL);

    if (kurl.isEmpty() || !kurl.isValid()) {
        ec = SYNTAX_ERR;
        return false;
    }

    return true;
}
Example #26
0
//--------------------------------------------------------------
void processPoint(const String& point, Uint32& v, Uint32& vt, Uint32& vn)
{
	Uint32 occ = point.countOccurrence('/');

	switch(occ)
	{
	case 0:
		sscanf(point.getValue(), "%u", &v);
		vt = 1;
		vn = 1;
	break;
	case 1:
		sscanf(point.getValue(), "%u/%u", &v, &vt);
		vn = 1;
	break;
	case 2:
		if(point.getChar(point.find('/')+1) == '/') // find "//" pattern
		{
			sscanf(point.getValue(), "%u//%u", &v, &vn);
			vt = 1;
		}
		else
		{
			sscanf(point.getValue(), "%u/%u/%u", &v, &vt, &vn);
		}
	break;
	default:
		fprintf(stdout, "wut?\n");
	break;
	}
}
Example #27
0
void HTMLAnchorElement::setHost(const String& value)
{
    if (value.isEmpty())
        return;
    KURL url = href();
    if (!url.canSetHostOrPort())
        return;

    size_t separator = value.find(':');
    if (!separator)
        return;

    if (separator == notFound)
        url.setHostAndPort(value);
    else {
        unsigned portEnd;
        unsigned port = parsePortFromStringPosition(value, separator + 1, portEnd);
        if (!port) {
            // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes
            // specifically goes against RFC 3986 (p3.2) and
            // requires setting the port to "0" if it is set to empty string.
            url.setHostAndPort(value.substring(0, separator + 1) + "0");
        } else {
            if (isDefaultPortForProtocol(port, url.protocol()))
                url.setHostAndPort(value.substring(0, separator));
            else
                url.setHostAndPort(value.substring(0, portEnd));
        }
    }
    setHref(url.string());
}
Example #28
0
static bool name_contains_class(const String& name) {
  if (name) {
    int pos = name.find("::");
    return pos != 0 && pos != String::npos && pos + 2 < name.size();
  }
  return false;
}
RenderWindow* GTKGLSupport::createWindow(bool autoCreateWindow, 
                                         GLRenderSystem* renderSystem, 
					 const String& windowTitle)
{
    if (autoCreateWindow)
    {
        ConfigOptionMap::iterator opt = mOptions.find("Full Screen");
        if (opt == mOptions.end())
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't find full screen options!", "GTKGLSupport::createWindow");
        bool fullscreen = (opt->second.currentValue == "Yes");
 
        opt = mOptions.find("Video Mode");
        if (opt == mOptions.end())
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Can't find video mode options!", "GTKGLSupport::createWindow");
        String val = opt->second.currentValue;
        String::size_type pos = val.find('x');
        if (pos == String::npos)
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Invalid Video Mode provided", "GTKGLSupport::createWindow");
 
        unsigned int w = StringConverter::parseUnsignedInt(val.substr(0, pos));
        unsigned int h = StringConverter::parseUnsignedInt(val.substr(pos + 1));
 
        return renderSystem->createRenderWindow(windowTitle, w, h, 32,
fullscreen);
    }
    else
    {
        // XXX What is the else?
                return NULL;
    }
}
Example #30
0
void FrameFactory::updateGenre(TextIdentificationFrame *frame) const
{
  StringList fields = frame->fieldList();
  StringList newfields;

  for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) {
    String s = *it;
    int end = s.find(")");

    if(s.startsWith("(") && end > 0) {
      // "(12)Genre"
      String text = s.substr(end + 1);
      bool ok;
      int number = s.substr(1, end - 1).toInt(&ok);
      if(ok && number >= 0 && number <= 255 && !(ID3v1::genre(number) == text))
        newfields.append(s.substr(1, end - 1));
      if(!text.isEmpty())
        newfields.append(text);
    }
    else {
      // "Genre" or "12"
      newfields.append(s);
    }
  }

  if(newfields.isEmpty())
    fields.append(String::null);

  frame->setText(newfields);

}