当前位置: 首页>>代码示例>>C++>>正文


C++ rString::c_str方法代码示例

本文整理汇总了C++中rString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ rString::c_str方法的具体用法?C++ rString::c_str怎么用?C++ rString::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rString的用法示例。


在下文中一共展示了rString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RegisterType

/// <summary>
/// Registers a type of logging message.
/// <para>This function should be run once for each type of message the programmer creates.</para>
/// <para>If a parent is supplied the supplied <paramref name="name"/> will be a child to this parent. If a parent
/// is registered with <see cref="Logger::RegisterInterest"/> the childs logging messages will
/// also be seen.</para>
/// <para><paramref name="parent"/> can be left empty if a parent is not desired.</para>
/// <remarks>The parent name supplied with <paramref name="parent"/> needs to be registered before
/// any children can be added</remarks>
/// </summary>
/// <param name="name">Name of the logging message</param>
/// <param name="parent">Parent of the supplied name (optional)</param>
void Logger::RegisterType ( const rString& name, const rString& parent )
{
	if ( parent != "" )
	{
		// If a parent is supplied, find it
		rMap<std::string, LogType>::iterator it = LogTypes.find ( parent.c_str( ) );

		// Check if parent was found
		if ( it != LogTypes.end() )
		{
			// Create LogType, emplace it and record the child in the parent.
			LogType lt;
			lt.Parent = parent;
			LogTypes.emplace ( name.c_str( ), lt );
			it->second.Children.push_back ( name );
		}
		else
		{
			cerr << Colors::BRed << "Failed to find parent log type for log type: " << name << Colors::Reset <<
				 endl;
			return;
		}
	}
	else
	{
		// No parent was supplied so create LogType with no parent.
		LogType lt;
		lt.Parent = "";
		LogTypes.emplace ( name.c_str( ), lt );
	}
}
开发者ID:Robograde,项目名称:Robograde,代码行数:43,代码来源:Logger.cpp

示例2: CreateSample

//+---------------------------------------------------+
//|bool CreateSample(const rString &path, AudioBuffer* &buffer, const SDL_AudioSpec* sysSpec)
//\---------------------------------------------------+
bool SoundSDL::CreateSample(const rString &path, AudioBuffer* &buffer, const SDL_AudioSpec* sysSpec)
{
	///Load the wav and recieve the buffer containing the audio data
	if(!m_AudioFile->LoadSample(path.c_str(), m_BufferData))
	{
		fprintf(stderr, "Failed to load sample %s\n", path.c_str());
		return false;
	}

	buffer->chunkSize = buffer->spec.size;

	///Create audio converter using the data from the wav header
	int ret = RebuildAudioCVT(m_BufferData, sysSpec);
	if(ret < 0)
	{
		fprintf(stderr, "Failed to build converter: %s\n", path.c_str());
		return false;
	}

	//Convert the loaded data into matching engine format
	//If ret == 1 the loaded audio needs not to be converted
	if(ret == 1)
	{
		if(!ConvertBufferData(buffer, m_AudioCVT))
		{
			fprintf(stderr, "Failed to convert audio: %s\n", path.c_str());
			return false;
		}
	}

	return true;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:35,代码来源:SoundSDL.cpp

示例3: CreateShaderProgram

unsigned int rOpenGLGraphicsDevice::CreateShaderProgram(const rString& vertex, const rString& fragment){
    GLuint vertexShader;
    GLuint fragmentShader;
    GLuint programObject;
    GLint linked;


    vertexShader = CompileShader(GL_VERTEX_SHADER, vertex.c_str());

    if (!vertexShader)
	    return 0;

    fragmentShader = CompileShader(GL_FRAGMENT_SHADER, fragment.c_str());

    if (!fragmentShader){
	    glDeleteShader(vertexShader);
	    return 0;
    }

    programObject = glCreateProgram();

    if (!programObject)
	    return 0;

    glAttachShader(programObject, vertexShader);
    glAttachShader(programObject, fragmentShader);

    glLinkProgram(programObject);
    glGetProgramiv(programObject, GL_LINK_STATUS, &linked);

    if (!linked){
	GLint infoLen = 0;
	glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);

	if (infoLen > 1){
	     char* infoLog = new char[infoLen];

	     glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
	     m_lastError.assign(infoLog, infoLen);         

	     delete [] infoLog;
	}

	glDeleteProgram(programObject);
	return 0;
    }

    glDeleteShader(vertexShader);
    glDeleteShader(fragmentShader);

    m_lastError.clear();
    return programObject;
}
开发者ID:aedotcom,项目名称:recondite,代码行数:53,代码来源:rOpenGLGraphicsDevice.cpp

示例4:

rString gfx::MaterialBank::GetDir(rString& filename)
{
	bool found = false;
	for (int i = static_cast<int>(filename.size()); i > 0; i--)
	{
		if (filename.c_str()[i] == '/' || filename.c_str()[i] == '\\' )
			found = true;
		if (!found)
		{
			filename.erase(i);
		}

	}
	return filename;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:15,代码来源:MaterialBank.cpp

示例5: if

//Creates a shader with defines
void gfx::ShaderProgram::CreateShader ( ifstream* FileStream, GLenum shaderType, const rString& filename,bool print, ShaderDefineContainer& container )
{
    rString line;
    size_t found;
    rString shaderText;
	getline(*FileStream, line);
	shaderText += line;
	shaderText += "\n";
	shaderText += container.GetAllDefineLines();
    shaderText += container.GetDefinesShaderStage ( shaderType );
    bool end = false;
    while ( !end )
    {
        getline ( *FileStream, line );
        //search for the end of the shader
        found = line.find ( "#include " );
		if ( found != rString::npos )
        {
            int i = static_cast<int> ( found ) + 9; //found + "#include "
            rString s;
            while ( i < static_cast<int> ( line.length() ) )
            {
                s += line[i];
                i++;
            }
            rString str = GetDir ( rString ( filename.c_str() ) ) + s;
            shaderText += LoadText ( str.c_str() );
            shaderText += "\n";
        }
        else
        {
            found = line.find ( "#end_shader" );
			if ( found != rString::npos )
            {
                //break loop
                end = true;
                break;
            }
            else if ( FileStream->eof() )
            {
				Logger::Log( "Could not find end of file " + filename, "ShaderProgram", LogSeverity::ERROR_MSG );
                return;
            }
            else
            {
                shaderText += line;
                shaderText += '\n';
            }

        }

    }
    if ( shaderText.length() > 0 )
    {
		Shader* shader = tNew( Shader );
        shader->CreateFromString ( shaderText, shaderType, filename,print );
        m_Shaders.push_back ( shader );
        shaderText.clear();
    }
}
开发者ID:Robograde,项目名称:Robograde,代码行数:61,代码来源:ShaderProgram.cpp

示例6: ParseColorProperty

void ruiStylesheetLoader::ParseColorProperty(const rString& name, const rString& value){
	int r,g,b,a;

	if (sscanf(value.c_str(), "%i %i %i %i", &r, &g, &b, &a) == 4){
		m_currentStyle->SetColor(name, rColor(r,g,b,a));
	}
}
开发者ID:matthewcpp,项目名称:recondite,代码行数:7,代码来源:ruiStylesheetLoader.cpp

示例7: SetWindowClickThrough

	void GUIEngine::SetWindowClickThrough( const rString& name, bool clickThrough )
	{
		auto windowIt = m_Windows.find( name ) ;
		if( windowIt != m_Windows.end() )
			windowIt->second->SetClickThrough( clickThrough );
		else
			Logger::Log( "Couldn't get window: " + rString( name.c_str()) + ", it doesn't exist.", "GUIEngine", LogSeverity::ERROR_MSG  );
	}
开发者ID:Robograde,项目名称:Robograde,代码行数:8,代码来源:GUIEngine.cpp

示例8: Initialize

//+----------------------------------------------------------------------------+
//|bool Initialize(AudioEngine* engine, const rString &path, SoundType type)
//\----------------------------------------------------------------------------+
bool SoundSDL::Initialize(AudioEngine* engine, const rString &path, SoundType type)
{
	AudioEngineSDL* audioEngine = reinterpret_cast<AudioEngineSDL*>(engine);
	const SDL_AudioSpec* sysSpec = audioEngine->GetSystemSpec();
	m_AudioEngine = audioEngine;
	m_Type = type;
	m_Name = path;
	m_ChunkSize = sysSpec->size;

	m_AudioCVT = pNew(SDL_AudioCVT);
	m_BufferData = tNew(AudioBuffer);
	m_AudioFile = nullptr;

	///Check which file format the requested audiofile are
	///Only wav and ogg are supported

	///Is wave file
	if(path.find(".wav", 0) != std::string::npos)
	{ 
		m_AudioFile = pNew(WavFileReader);
	}
	///Is ogg file
	else if(path.find(".ogg", 0) != std::string::npos)
	{ 
		m_AudioFile = pNew(OggFileReader);
	}
	///Not supported format
	else
	{
		fprintf(stderr, "SoundSDL. Trying to load unsupported file format %s \n", path.c_str());
		return false;
	}

	m_AudioFile->Initialize();

	///Read as sample, read everything into buffer
	if(type == SoundType::SAMPLE)
	{
		CreateSample(path, m_BufferData, sysSpec);
	}
	///Read as stream, prepare for buffer streaming
	else if(type == SoundType::STREAM)
	{
		CreateStream(path, m_BufferData, sysSpec);
	}
	else
	{
		///This should not happend..
		fprintf(stderr, "SoundSDL. Unexpected error loading %s while setting sound type \n", path.c_str());
		return false;
	}

	return true;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:57,代码来源:SoundSDL.cpp

示例9: AddMappingWithName

bool KeyBindingCollection::AddMappingWithName( const rString& keyName, ActionIdentifier action, KeyBindingType keyBindType, bool overwrite,
											   bool clearConflicting, rString* errorString ) {
	SDL_Scancode scanCode = SDL_GetScancodeFromName( keyName.c_str() );
	if ( scanCode != SDL_SCANCODE_UNKNOWN ) {
		return AddMappingWithScancode( scanCode, action, keyBindType, overwrite, clearConflicting, errorString );
	} else {
		LogInput( "Failed to get scancode from name: " + keyName, "KeyBindings", LogSeverity::WARNING_MSG );
		if ( errorString != nullptr ) {
			*errorString = "Failed to get scancode from name: " + keyName;
		}
		return false;
	}
}
开发者ID:PeterMerkert,项目名称:input-toi,代码行数:13,代码来源:KeyBindingCollection.cpp

示例10: RegisterInterest

/// <summary>
/// Registers interest in a type of logging message that has been registered with
/// <see cref="Logger::RegisterType"/>.
/// <para>If a parent is registered all its children will also be registered</para>
/// </summary>
/// <param name="name">Path to the file to be read</param>
/// <param name="severityMask">Bitmask of type <see cref="LogSeverity::BitFlag"/></param>
void Logger::RegisterInterest ( const rString& name, int severityMask )
{
	rMap<std::string, LogType>::iterator it = LogTypes.find ( name.c_str( ) );
	if ( it != LogTypes.end() )
	{
		// Create interest entry with supplied severitymask and name.
		InterestEntry ie;
		ie.Parent = it->second.Parent;
		ie.SeverityMask = severityMask;
		InterestedLogTypes.emplace ( name.c_str( ), ie );
		// Add all children as well.
		for ( rVector<rString>::iterator chit = it->second.Children.begin();
			  chit != it->second.Children.end(); ++chit )
		{
			RegisterInterest ( *chit, severityMask );
		}
	}
	else
	{
		cerr 	<< Colors::BRed << "Failed to find log type " << name
				<< " interest not registered." << Colors::Reset << endl;
	}
}
开发者ID:Robograde,项目名称:Robograde,代码行数:30,代码来源:Logger.cpp

示例11: CreateStream

//+---------------------------------------------------+
//|bool CreateStream(const rString &path, AudioBuffer* &buffer, const SDL_AudioSpec* sysSpec)
//\---------------------------------------------------+
bool SoundSDL::CreateStream(const rString &path, AudioBuffer* &buffer, const SDL_AudioSpec* sysSpec)
{
	if(!m_AudioFile->OpenStream(path.c_str(), m_ChunkSize, buffer))
	{
		fprintf(stderr, "Failed to open wav stream %s\n", path.c_str());
		return false;
	}

	///Load the first chunk into memory
	if(!m_AudioFile->ReadStream(m_BufferData, m_ChunkSize))
	{
		fprintf(stderr, "Failed to stream data %s\n", m_Name.c_str());
		return false;
	}

	///Create audio converter using the data from the wav header
	int ret = RebuildAudioCVT(m_BufferData, sysSpec);
	if(ret < 0)
	{
		fprintf(stderr, "Failed to build converter: %s\n", path.c_str());
		return false;
	}

	//Convert the loaded data into matching engine format
	//If ret == 0 the loaded audio needs not to be converted
	if(ret == 1)
	{
		if(!ConvertBufferData(buffer, m_AudioCVT))
		{
			fprintf(stderr, "Failed to convert audio: %s\n", path.c_str());
			return false;
		}
	}

	return true;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:39,代码来源:SoundSDL.cpp

示例12:

rString gfx::ShaderProgram::GetDir ( rString filename )
{
    bool found = false;
    for ( int i = static_cast<int> ( filename.size() ); i > 0; i-- )
    {
        if ( filename.c_str() [i] == '/' )
        {
            found = true;
        }
        if ( !found )
        {
            filename.erase ( i );
        }
    }
    return filename;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:16,代码来源:ShaderProgram.cpp

示例13: GetParentString

rString Logger::GetParentString ( const rString& name, unsigned int treeHeight )
{
	if ( treeHeight == 0 )
	{
		return "";
	}
	rMap<std::string, LogType>::const_iterator pit = LogTypes.find ( name.c_str( ) );
	if ( pit == LogTypes.end() )
	{
		return name;
	}
	else if ( pit->second.Parent == "" )
	{
		return name;
	}
	return GetParentString ( pit->second.Parent, treeHeight - 1 ) + NameSeparator.c_str( ) + name;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:17,代码来源:Logger.cpp

示例14:

rString gfx::TextureAtlas::GetDir ( rString str )
{
    bool found = false;
    for ( int i = static_cast<int> ( str.size() ); i > 0; i-- )
    {
        if ( str.c_str() [i] == '/' )
        {
            found = true;
        }
        if ( !found )
        {
            str.erase ( i );
        }

    }
    return str;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:17,代码来源:TextureAtlas.cpp

示例15: GetPortFromString

unsigned short NetworkUtility::GetPortFromString( const rString& input )
{
	if ( input != "" && StringUtility::IsDigitsOnly(input) )
	{
		unsigned int port = 0;
		try 
		{
			port = static_cast<unsigned int>( std::stoul( input.c_str() ) );
		}
		catch ( ... ) 
		{
			return 0;
		}
		if ( port <= SHRT_MAX )
		{
			return port;
		}
		else
			return 0;
	}
	else 
		return 0;
}
开发者ID:Robograde,项目名称:Robograde,代码行数:23,代码来源:NetworkUtility.cpp


注:本文中的rString::c_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。