Example #1
0
bool String::operator < (const String& compareTo) const
{
	bool lessThan = false;
	if (GetSize() == compareTo.GetSize())
		return lessThan;
	return !(*this > compareTo);
}
Example #2
0
	/*!
	* \brief Changes the debugging name associated to a thread
	*
	* Changes the debugging name associated with a particular thread, and may helps with debugging tools.
	*
	* \param name The new name of the thread
	*
	* \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator)
	*
	* \see SetCurrentThreadName
	*/
	void Thread::SetName(const String& name)
	{
		NazaraAssert(m_impl, "Invalid thread");
		NazaraAssert(name.GetSize() < 16, "Thread name is too long");

		m_impl->SetName(name);
	}
Example #3
0
bool String::operator > (const String& compareTo) const
{
	bool greaterThan = false;
	if (GetSize() > compareTo.GetSize())
		greaterThan = true;
	return greaterThan;

}
Example #4
0
//Comparison operators: strings are equal when they are the same size
//and they contain the same characters
bool String::operator == (const String& compareTo) const
{
	bool sameSize = true;
	if (GetSize() == compareTo.GetSize() )
	{
		for (int i = 0; i < GetSize(); i++)
		{
			if (Text[i] != compareTo.Text[i])
			{
				sameSize = false;
				break;
			}
		}
	}
	else
		sameSize = false;

	return sameSize;
}
Example #5
0
//Concatentation operator appends appendix to this String and returns a new string
String String::operator + (const String& appendix) const
{

	// -1 for the '/0' in this
	int newStringLength = GetSize() + appendix.GetSize() + 1 ;

	String newString(newStringLength);

	for (int i = 0; i < GetSize(); i++)
		newString[i] = Text[i];

	int counter = 0;
	for (int i = GetSize(); i < newStringLength - 1; i++)
	{
		newString[i] = appendix.Text[counter];
		counter++;
	}
	
	newString[newStringLength - 1] = '\0';

	return newString;
}
	void LuaState::PushString(const String& str) const
	{
		lua_pushlstring(m_state, str.GetConstBuffer(), str.GetSize());
	}
Example #7
0
	/*!
	* \brief Changes the debugging name associated to the calling thread
	*
	* Changes the debugging name associated with the calling thread, and may helps with debugging tools.
	*
	* \param name The new name associated with this thread
	*
	* \remark Due to system limitations, thread name cannot exceed 15 characters (excluding null-terminator)
	*
	* \see SetName
	*/
	void Thread::SetCurrentThreadName(const String& name)
	{
		NazaraAssert(name.GetSize() < 16, "Thread name is too long");

		ThreadImpl::SetCurrentName(name);
	}
Example #8
0
File: Main.cpp Project: gabr/studia
int main(int argc, char* argv[])
{

    String story(7, '.');
    story.Print();
    cout << endl;

    char* sentence = "Wyimaginowane dolegliwosci sa nieuleczalne.";
    String story2a(sentence);
    story2a.Print();
    cout << endl;

    String story2b('c');
    story2b.Print();
    cout << endl;

    String story2c(story2a);
    story2c.Print();
    cout << endl;

    String story3a_1((char*)"Aaaaa");
    String story3a_2((char*)"Bbbbb");
    cout << ((story3a_1 == story3a_2) ? "equal" : "different") << endl;
    cout << ((story3a_1 != story3a_2) ? "not equal" : "no different") << endl;
    cout << "first is " << 
        ((story3a_1 > story3a_2) ? "bigger" : "smaller") << endl;
     cout << "first is " << 
        ((story3a_1 < story3a_2) ? "smaller" : "bigger") << endl;

     String story4a1("Hello ");
     String story4a2("world!");
     story4a1 = story4a1 + story4a2;
     story4a1.Print();
     cout << endl;

     String story4b("Ala ma ");
     char* kota = "kota.";
     story4b = kota + story4b;
     story4b.Print();
     cout << endl;

     String story4c("AB");
     story4c = story4c + "C";
     story4c.Print();
     cout << endl;

     String story5("1234567890");
     for (int i = 0; i < story5.GetSize(); i++)
     {
         cout << story5[i];
     }
     cout << endl;

     // TASK 6.
     String a;
     String b("string test");
     String c('K');
     String d(story2a);

     cout << "1: \""; a.Print(); cout << "\" length: " << a.GetSize() << endl;
     cout << "2: \""; b.Print(); cout << "\" length: " << b.GetSize() << endl;
     cout << "3: \""; c.Print(); cout << "\" length: " << c.GetSize() << endl;
     cout << "4: \""; d.Print(); cout << "\" length: " << d.GetSize() << endl;

     cout << endl << "Last letters:" << endl;
     cout << story[story.GetSize()-1] << endl;
     cout << story2a[story2a.GetSize()-1] << endl;
     cout << story2b[story2b.GetSize()-1] << endl;
     cout << story2c[story2c.GetSize()-1] << endl;
     cout << story3a_1[story3a_1.GetSize()-1] << endl;
     cout << story3a_2[story3a_2.GetSize()-1] << endl;
     cout << story4a1[story4a1.GetSize()-1] << endl;
     cout << story4a2[story4a2.GetSize()-1] << endl;
     cout << story4b[story4b.GetSize()-1] << endl;
     cout << story4c[story4c.GetSize()-1] << endl;
     cout << story5[story5.GetSize()-1] << endl;
     cout << a[a.GetSize()-1] << endl;
     cout << b[b.GetSize()-1] << endl;
     cout << c[c.GetSize()-1] << endl;
     cout << d[d.GetSize()-1] << endl;


    return 0;
}
	bool PluginManager::Mount(const String& pluginPath, bool appendExtension)
	{
		if (!Initialize())
		{
			NazaraError("Failed to initialize PluginManager");
			return false;
		}

		String path = pluginPath;
		if (appendExtension && !path.EndsWith(NAZARA_DYNLIB_EXTENSION))
			path += NAZARA_DYNLIB_EXTENSION;

		bool exists = false;
		if (!File::IsAbsolute(path))
		{
			for (const String& dir : s_directories)
			{
				String testPath;
				testPath.Reserve(dir.GetSize() + path.GetSize() + 10);

				testPath = dir;
				testPath += NAZARA_DIRECTORY_SEPARATOR;
				testPath += path;

				if (File::Exists(testPath))
				{
					path = testPath;
					exists = true;
					break;
				}
			}
		}
		else if (File::Exists(path))
			exists = true;

		if (!exists)
		{
			NazaraError("Failed to find plugin file");
			return false;
		}

		std::unique_ptr<DynLib> library(new DynLib);
		if (!library->Load(path))
		{
			NazaraError("Failed to load plugin");
			return false;
		}

		PluginLoad func = reinterpret_cast<PluginLoad>(library->GetSymbol("PluginLoad"));
		if (!func)
		{
			NazaraError("Failed to get symbol PluginLoad");
			return false;
		}

		if (!func())
		{
			NazaraError("Plugin failed to load");
			return false;
		}

		s_plugins[pluginPath] = library.release();

		return true;
	}