Example #1
0
String QtEnumIMProtocol::getBigIconPath()
{
	String protocol = getDefaultProtocolImage();//VOXOX - CJC - 2009.07.29 
	protocol = protocol.toLowerCase();

	String result = ":pics/protocols/big/" + protocol + ".png";

	return result;
}
Example #2
0
boolean String::equalsIgnoreCase( const String &s2 ) const
{
  if ( this == &s2 )
    return true; //1;
  else if ( _length != s2._length )
    return false; //0;

  return strcmp(toLowerCase()._buffer, s2.toLowerCase()._buffer) == 0;
}
Example #3
0
AssetEntry::AssetEntry(String assetPath, String assetName, String extension, Resource *resource) : UIElement() {

    this->resource = resource;
	this->assetPath = assetPath;

	if(assetName.length() > 20)
		assetName = assetName.substr(0,20)+"...";

	selectShape = new UIRect(120, 100);
	selectShape->visible = false;
	selectShape->setAnchorPoint(-1.0, -1.0, 0.0);
	addChild(selectShape);
	selectShape->processInputEvents = true;
	selectShape->setColor(0.0, 0.0, 0.0, 0.5);
    selectShape->loadTexture("browserIcons/large_selector.png");
    selectShape->setBlendingMode(Renderer::BLEND_MODE_NORMAL);

	imageShape = new UIRect(64,64);
	imageShape->setAnchorPoint(-1.0, -1.0, 0.0);
	addChild(imageShape);
	
	extension = extension.toLowerCase();
	
	if(extension == "png") {
		imageShape->loadTexture(assetPath);
	} else if(extension == "ogg" || extension == "wav") {
		imageShape->loadTexture("browserIcons/sound_icon.png");
	} else if(extension == "entity") {
		imageShape->loadTexture("browserIcons/entity_icon.png");
	} else if(extension == "sprite") {
		imageShape->loadTexture("browserIcons/sprite_icon.png");
	} else if(extension == "ttf" || extension == "otf") {
		imageShape->loadTexture("browserIcons/font_icon.png");
	} else if(extension == "vert" || extension == "frag") {
		imageShape->loadTexture("browserIcons/shader_icon.png");
	} else if(extension == "mesh") {
		imageShape->loadTexture("browserIcons/mesh_icon.png");
    } else if(extension == "mat") {
		imageShape->loadTexture("browserIcons/materials_icon.png");
    } else if(extension == "material_resource") {
		imageShape->loadTexture("browserIcons/material_resource_icon.png");
    }
	
	imageShape->setPosition(28, 10);
    imageShape->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
    
    String name = assetName;
    if(name.length() > 15) {
        name = name.substr(0, 15)+"...";
    }
	nameLabel = new UILabel(name, 11);
	addChild(nameLabel);
    nameLabel->setPosition((120.0-nameLabel->getWidth())/2.0, 80);
    
}
Example #4
0
    bool has_arg(String arg)
    {
        arg = arg.toLowerCase();
        for(size_t i = 0; i < argv.size(); i++)
        {
            if(argv[i].toLowerCase() == arg)
                return true;
        }

        return false;
    }
Example #5
0
int String::lastIndexOf(String index_string, int from, String::CaseSensitivity cs)
{
	if (from > this->size() - 1)
		assert(false);
	
	size_t found;
	String sub = this->substr(from, this->length());
	
	if (cs == String::NotCaseSensitive)
	{
		sub.toLowerCase();
		index_string.toLowerCase();
	}
	
	found = sub.rfind(index_string);
	if (found != std::string::npos)
		return int(found);
	
	return -1;
}
inline bool NameManager::isReserved(String name) {
	name = name.toLowerCase();

	HashSetIterator<String> iter = reservedNames->iterator();
	while (iter.hasNext()) {
		if (name.indexOf(iter.next()) != -1)
			return true;
	}

	return false;
}
Example #7
0
int DrumMachine::getDrumPatternIx(String drumSound) {
    auto sound = drumSound.toLowerCase();
    if (sound.contains("kick"))
        return 0;
    else if (sound.contains("snare") || sound.contains("clap"))
        return 1;
    else if (sound.contains("hat"))
        return 2;
    else
        return -1;
}
Example #8
0
void AdminWebServer::check(void)
{
  Admin = KingOfPopAdmin.available();
  this->timeOut();
  if (Admin)
  {
    this->upTime();
    String prompt = this->getPrompt();
    this->authenticate(prompt);
    if (!authenticated)
    {
      return;
    }
    data = prompt;
    String command = prompt.toLowerCase();
    if (command == "quit")
    {
      this->disconnect();
    }
    else if (command == "cancel")
    {
      comstep = 0;
      pos = 0;
      Accounts.cancelSession();
    }
    switch (pos)
    {
    case 0 : 
      this->mainMenu(command); 
      break;
    case 1 : 
      this->addAccount(command); 
      break;
    case 2 : 
      this->listAllAccounts(command);
      break;
    case 3 : 
      this->editAccount(command);
      break;
    case 4 : 
      this->checkBalance(command);
      break;
    case 5 : 
      this->creditAccount(command);
      break;
    case 6 :
      this->chargeAccount(command);
      break;
    case 7 :
      this->adminTools(command);
      break;
    }
  }
}
Example #9
0
void String::remove(String remove_string, String::CaseSensitivity cs)
{
	size_t found = 0;
	String sub = *this;
	
	if (cs == String::NotCaseSensitive)
	{
		sub.toLowerCase();
		remove_string.toLowerCase();
	}
	
	while (found != std::string::npos) 
	{
		found = sub.rfind(remove_string);
		if (found != std::string::npos)
		{
			this->erase(int(found), remove_string.length());
			sub.erase(int(found), remove_string.length());
		}
	}
}
bool NameManager::isProfane(String name) {
	uint16 i;

	name = name.toLowerCase();

	for (i = 0; i < profaneNames->size(); i++) {
		if (name.indexOf(profaneNames->get(i)) != -1)
			return true;
	}

	return false;
}
static void parseWildcard (const String& pattern, StringArray& result)
{
    result.addTokens (pattern.toLowerCase(), ";,", "\"'");

    result.trim();
    result.removeEmptyStrings();

    // special case for *.*, because people use it to mean "any file", but it
    // would actually ignore files with no extension.
    for (int i = result.size(); --i >= 0;)
        if (result[i] == "*.*")
            result.set (i, "*");
}
Example #12
0
    String makeValidIdentifier (String s, bool capitalise, bool removeColons, bool allowTemplates)
    {
        if (s.isEmpty())
            return "unknown";

        if (removeColons)
            s = s.replaceCharacters (".,;:/@", "______");
        else
            s = s.replaceCharacters (".,;/@", "_____");

        int i;
        for (i = s.length(); --i > 0;)
            if (CharacterFunctions::isLetter (s[i])
                 && CharacterFunctions::isLetter (s[i - 1])
                 && CharacterFunctions::isUpperCase (s[i])
                 && ! CharacterFunctions::isUpperCase (s[i - 1]))
                s = s.substring (0, i) + " " + s.substring (i);

        String allowedChars ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ 0123456789");
        if (allowTemplates)
            allowedChars += "<>";

        if (! removeColons)
            allowedChars += ":";

        StringArray words;
        words.addTokens (s.retainCharacters (allowedChars), false);
        words.trim();

        String n (words[0]);

        if (capitalise)
            n = n.toLowerCase();

        for (i = 1; i < words.size(); ++i)
        {
            if (capitalise && words[i].length() > 1)
                n << words[i].substring (0, 1).toUpperCase()
                  << words[i].substring (1).toLowerCase();
            else
                n << words[i];
        }

        if (CharacterFunctions::isDigit (n[0]))
            n = "_" + n;

        if (CPlusPlusCodeTokeniser::isReservedKeyword (n))
            n << '_';

        return n;
    }
Example #13
0
bool DateTime::parseHttpDate(String httpDate)
{
	char* ptr = (char*)httpDate.c_str();
	int first = httpDate.indexOf(',');
	if (first == -1 || httpDate.length() - first < 20) return false;
	first++; // Skip ','
	if (httpDate[first] == ' ') first ++;

	ptr += first;
	Day = (int8_t)os_strtol(ptr, &ptr, 10);
	if (*ptr == 0) return false;
	ptr++;
	char month[4] = {0};
	memcpy(month, ptr, 3);
	ptr += 4;
	if (*ptr == 0) return false;
	String mon = month;
	mon.toLowerCase();

	if (mon == "jan") Month = 0;
	else if (mon == "feb") Month = 1;
	else if (mon == "mar") Month = 2;
	else if (mon == "apr") Month = 3;
	else if (mon == "may") Month = 4;
	else if (mon == "jun") Month = 5;
	else if (mon == "jul") Month = 6;
	else if (mon == "aug") Month = 7;
	else if (mon == "sep") Month = 8;
	else if (mon == "oct") Month = 9;
	else if (mon == "nov") Month = 10;
	else if (mon == "dec") Month = 11;
	else return false;

	Year = (int16_t)os_strtol(ptr, &ptr, 10);
	if (*ptr == 0) return false;
	if (Year < 69)
		Year += 2000;
	else if (Year < 100)
		Year += 1900;

	Hour = (int8_t)os_strtol(ptr, &ptr, 10);
	if (*ptr != ':') return false;
	ptr++;
	Minute = (int8_t)os_strtol(ptr, &ptr, 10);
	if (*ptr != ':') return false;
	ptr++;
	Second = (int8_t)os_strtol(ptr, &ptr, 10);
	Milliseconds = 0;

	return true;
}
Example #14
0
String QtEnumIMProtocol::getNetworkIconPath( EnumPresenceState::PresenceState presenceState )
{
	bool	bValid		 = true;
	String path		 = "";
	String presenceName = EnumPresenceState::toString( presenceState ).c_str();
	
	presenceName = presenceName.toLowerCase();

	//if ( isIMProtocol() )//VOXOX CHANGE by Rolando - 2009.07.27 
	if ( isIconPresenceBased() )
	{
		String protocolName = getDefaultProtocolImage();
		protocolName = protocolName.toLowerCase();

		switch( presenceState )
		{
		case EnumPresenceState::PresenceStateOnline:
			path = ":/pics/status/networks/" + protocolName + "_" + presenceName + ".png";
			break;

		case EnumPresenceState::PresenceStateUnknown:
			//Leave blank.  TODO: do we want a default icon path?
			break;

		default:
			path = ":/pics/status/networks/" + protocolName + "_" + presenceName + ".png";
		}
	}
	else
	{
		if(presenceName != "unknown" )
		{
			path = ":/pics/status/" + presenceName + ".png";
		}
	}

	return path;
}
float PowerupObjectImplementation::getPowerupStat(const String& attribName) {

	for(int i = 0; i < modifiers.size(); ++i) {
		PowerupStat* stat = &modifiers.get(i);

		if(attribName.toLowerCase() ==
				stat->getAttributeToModify().toLowerCase()) {

			return stat->getValue() / 100.f;
		}
	}

	return 0;
}
Example #16
0
std::string WengoAccountParser::createEncyptionKey( const std::string& userId, const std::string& did )
{
	VoxMd5 md5;

	String input = userId;
	input = input.toLowerCase();
	input += did;

	String tempMd5 = md5.toString( input.c_str(), input.size() );

	std::string key = tempMd5.substr( 0, 16 );

	return key;
}
Example #17
0
int String::count(String contain_string, String::CaseSensitivity cs)
{
	size_t found;
	std::string temp_str;
	int contains_count = 0;
	String sub = *this;
	
	if (cs == String::NotCaseSensitive)
	{
		sub.toLowerCase();
		contain_string.toLowerCase();
	}
	
	for (int i = 0; i < sub.length(); i++)
	{
		temp_str = sub.substr(i, contain_string.length());
		found = temp_str.find(contain_string);
		if (found != std::string::npos)
			contains_count++;
	}
	
	return contains_count;
}
Example #18
0
String MyFunctionRequestHandler::parseFileName(String& path) {
  String filename;
  int lastIndex = path.lastIndexOf('\\');
  if (lastIndex < 0) {
    lastIndex = path.lastIndexOf('/');
  }
  if (lastIndex > 0) {
    filename = path.substring(lastIndex + 1);
  } else {
    filename = path;
  }

  filename.toLowerCase();
  return filename;
}
Example #19
0
    String sub_arg(String arg, size_t index)
    {
        arg = arg.toLowerCase();
        for(size_t i = 0; i < argv.size(); i++)
        {
            if(argv[i].toLowerCase() == arg)
            {
                if(i+1+index < argv.size())
                    return argv[i+1+index];
                else return "";
            }
        }

        return "";
    }
Example #20
0
InputStream* ZipFile::getInputStream( const String& name )
{
	String str = stripPath( name );
	String namelower = str.toLowerCase();

	for ( int i = 0 ; i < (int)m_this->entries.size() ; ++i )
	{
		ZipFileImpl::Entry& entry = m_this->entries[i];
		if ( entry.name == namelower )
		{
			entry.used = true;
			return new MemoryInputStream( this, m_this->data.begin()+entry.begin, entry.size, m_this->name+"/"+entry.name );
		}
	}

	return new FileInputStream( name );
}
bool AbilityList::contains(const String& element) {
	String lowCase = element.toLowerCase();

	for (int i = 0; i < vector.size(); ++i) {
		Ability* ability = vector.get(i);

		if (ability == NULL)
			continue;

		String skill = ability->getAbilityName().toLowerCase();

		if (lowCase == skill)
			return true;
	}

	return false;
}
int StructurePermissionList::revokeAllPermissions(const String& playerName, bool caseSensitive) {
	Locker locker(&lock);

	if(playerName == ownerName)
		return CANTCHANGEOWNER;

	for (int i = 0; i < permissionLists.size(); ++i) {
		SortedVector<String>* list = &permissionLists.get(i);

		if (caseSensitive)
			list->drop(playerName);
		else
			list->drop(playerName.toLowerCase());
	}

	return REVOKED;
}
Example #23
0
AssetEntry::AssetEntry(String assetPath, String assetName, String extension) : UIElement() {

	this->assetPath = assetPath;

	if(assetName.length() > 20)
		assetName = assetName.substr(0,20)+"...";

	selectShape = new ScreenShape(ScreenShape::SHAPE_RECT, 120, 100);
	selectShape->visible = false;
	selectShape->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
	addChild(selectShape);
	selectShape->processInputEvents = true;
	selectShape->setColor(0.0, 0.0, 0.0, 0.5);

	imageShape = new ScreenShape(ScreenShape::SHAPE_RECT, 64,64);
	imageShape->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
	addChild(imageShape);
	
	extension = extension.toLowerCase();
	
	if(extension == "png") {
		imageShape->loadTexture(assetPath);
	} else if(extension == "ogg" || extension == "wav") {
		imageShape->loadTexture("Images/sound_thumb.png");
	} else if(extension == "entity2d") {
		imageShape->loadTexture("Images/entity_thumb.png");
	} else if(extension == "entity2d") {
		imageShape->loadTexture("Images/entity_thumb.png");
	} else if(extension == "sprite") {
		imageShape->loadTexture("Images/sprite_thumb.png");		
	} else if(extension == "ttf" || extension == "otf") {
		imageShape->loadTexture("Images/font_icon.png");
	} else if(extension == "vert" || extension == "frag") {
		imageShape->loadTexture("Images/shader_thumb.png");
	}

	
	imageShape->setPosition(28, 10);
	
	nameLabel = new ScreenLabel(assetName, 10);
	addChild(nameLabel);
	nameLabel->color.a = 0.5;
	nameLabel->setPositionMode(ScreenEntity::POSITION_CENTER);
	nameLabel->setPosition(60, 90);
}
int StructurePermissionList::revokePermission(const String& listName, const String& playerName, bool caseSensitive) {
	Locker locker(&lock);

	if(playerName == ownerName)
		return CANTCHANGEOWNER;

	if (!permissionLists.contains(listName))
		return LISTNOTFOUND;

	SortedVector<String>* list = &permissionLists.get(listName);

	if (caseSensitive)
		list->drop(playerName);
	else
		list->drop(playerName.toLowerCase());

	return REVOKED;
}
Example #25
0
HttpParseResult HttpRequest::parsePostData(HttpServer *server, pbuf* buf)
{
	int start = 0;
	tmpbuf += NetUtils::pbufStrCopy(buf, 0, buf->tot_len);
	// First enter
	if (requestPostParameters == NULL)
	{
		int headerEnd = NetUtils::pbufFindStr(buf, "\r\n\r\n");
		if (headerEnd == -1) return eHPR_Failed;
		if (headerEnd + getContentLength() > NETWORK_MAX_HTTP_PARSING_LEN)
		{
			debugf("NETWORK_MAX_HTTP_PARSING_LEN");
			return eHPR_Failed;
		}
		requestPostParameters = new HashMap<String, String>();
		start = headerEnd + 4;
		tmpbuf = tmpbuf.substring(start, tmpbuf.length());
	}

	//parse if it is FormUrlEncoded - otherwise keep in buffer
	String contType = getContentType();
	contType.toLowerCase();
	if (contType.indexOf(ContentType::FormUrlEncoded) != -1)
	{
		tmpbuf = extractParsingItemsList(tmpbuf, 0, tmpbuf.length(), '&', ' ', requestPostParameters);
	}

	postDataProcessed += buf->tot_len - start ;

	if (postDataProcessed == getContentLength())
	{
		return eHPR_Successful;
	}
	else if (postDataProcessed > getContentLength())
	{
		//avoid bufferoverflow if client announces non-correct content-length
		debugf("NETWORK_MAX_HTTP_PARSING_LEN");
		return eHPR_Failed;
	}
	else
	{
		return eHPR_Wait;
	}
}
bool PlanetManagerImplementation::validateRegionName(const String& name) {
	String lowerCase = name.toLowerCase();
	Locker locker(_this.getReferenceUnsafeStaticCast());

	if (hasRegion(name) || hasRegion(lowerCase))
		return false;

	for (int i = 0; i < regionMap.getTotalRegions(); ++i) {
		String regionName = regionMap.getRegion(i)->getRegionName();

		if (regionName.beginsWith("@")) {
			String fullName = StringIdManager::instance()->getStringId(regionName.hashCode()).toString().toLowerCase();

			if ((!fullName.isEmpty()) && (lowerCase == fullName || fullName.contains(lowerCase) || lowerCase.contains(fullName)))
				return false;
		}
	}

	return true;
}
void ChatRoomImplementation::broadcastMessageCheckIgnore(BaseMessage* msg, String& senderName) {
	Locker locker(_this.get());
	String lowerName = senderName.toLowerCase();
	PlayerManager* playerManager = server->getPlayerManager();
	ManagedReference<CreatureObject*> sender = NULL;
	bool privileged = false;
	ManagedReference<PlayerObject*> senderPlayer = NULL;

	if (playerManager == NULL)
		return;

	sender = playerManager->getPlayer(lowerName);

	if (sender == NULL)
		return;

	senderPlayer = sender->getPlayerObject();

	if (senderPlayer == NULL)
		return;

	if (senderPlayer->isPrivileged())
		privileged = true;


	for (int i = 0; i < playerList.size(); ++i) {
		ManagedReference<CreatureObject*> player = playerList.get(i);

		if (player){
			PlayerObject* ghost = player->getPlayerObject();
			if (ghost == NULL)
				continue;

			if (!ghost->isIgnoring(lowerName) || privileged) {
				player->sendMessage(msg->clone());
			}
		}
	}

	delete msg;
}
Example #28
0
String getCommand()
{
	int readByte = 0;
	String command = "";

	do
	{
		if (serial.available()) 
		{
			readByte = serial.read();
			//serial.write(readByte); //Debug: echo on
			command = command + (char)readByte;
		}
	} while ((readByte != 13) && (readByte != 10)); //Any kind of line end or CR char marks the end of the current command.

	//Normalizes the command:
	//String strResult(command.toLowerCase());
	command.trim();
	command.toLowerCase();
	return command;
}
Example #29
0
void listFiles( bool recurse, String dir, Vector<File>& files )
{
	Vector<String> fnames( Allocator<String>(__FILE__) );
	fnames.setSize( File(dir).list(0,0) );
	int n = File(dir).list( fnames.begin(), fnames.size() );
	if ( fnames.size() > n )
		fnames.setSize( n );

	for ( int i = 0 ; i < fnames.size() ; ++i )
	{
		String fname = fnames[i];
		File file( dir, fname );
		if ( file.isFile() && !fname.toLowerCase().endsWith(".mp3") )
		{
			files.add( file );
		}
		else if ( file.isDirectory() && recurse )
		{
			listFiles( recurse, file.getPath(), files );
		}
	}
}
Example #30
0
int startGifAnimation(String name) {
    name.trim();
    if (name.length() == 0) {
        return -1;
    }

    name.toLowerCase();
    if (!name.endsWith(".gif")) {
        name += ".gif";
    }
    String pathname = String(GIF_DIRECTORY) + name;

    if (!isValidFile(pathname)) {
        return -2;
    }

    Animation *anim = new GifAnimation{context, pathname, CLOUD_ANIMATION_TIME};
    abortCurrentAnimations();
    addAnimation(anim);

    return 0;
}