示例#1
0
int CSourcesListBox::FindInSources( wxString sName, int nType )
{
	switch( nType )
	{
	case MUSIK_SOURCES_LIBRARY:
		return 0;
		break;
	case MUSIK_SOURCES_NOW_PLAYING:
		return 1;
		break;
	default:
		{
			wxString sFind;
			if( !GetTypeAsString( nType, sFind))
				return -1;
			sFind += sName;
			sFind.MakeLower();

			for ( size_t i = 0; i < m_SourcesList.GetCount(); i++ )
			{
				if ( sFind == m_SourcesList.Item( i ).Lower() )
					return i;
			}
		}
	}
	return -1;
}
示例#2
0
//--------------------------------------------------------------------------------------------------
/// Affiche les données du client sur la ligne de commande.
//--------------------------------------------------------------------------------------------------
void CClient::Affiche(void) const
{
	std::cout << "  " << GetNom() << "\n";
	std::cout << "  " << GetPrenom() << "\n";
	std::cout << "  " << GetAdresse() << "\n";
	std::cout << "  " << GetTelephone() << "\n";
	std::cout << "  " << GetTypeAsString() << "\n";
	std::cout << "\n";
}
示例#3
0
void CSourcesListBox::EndEditLabel( wxListEvent& event )
{
#if wxVERSION_NUMBER >= 2500
	if(event.IsEditCancelled())
		return;
#endif
    wxString sCheck = event.GetText();
	sCheck.Replace( wxT( " " ), wxT( "" ), TRUE );
	if ( sCheck.IsEmpty() )
		return; // do not want to rename to an empty string ( or one that only consists of spaces

	EMUSIK_SOURCES_TYPE nType = GetType( event.GetIndex() );

	wxString sType;
	if(!GetTypeAsString(nType,sType))
	{
		wxASSERT(FALSE);
		return;
	}
	//--- Musik Library entry edited ---//
	if ( nType == MUSIK_SOURCES_LIBRARY )
	{
 		
	}
	//--- Now Playing entry edited ---//
	else if ( nType == MUSIK_SOURCES_NOW_PLAYING )
	{
        
	}
	//--- "playlist with data in a file" renamed ---//
	else
	{
		//--- rename file ---//
		wxString sOldFile = OnGetItemText(event.GetIndex(),0);
		wxString sNewFile = event.GetText();
		
		SourcesToFilename( &sOldFile, nType );
		SourcesToFilename( &sNewFile, nType );

		wxRenameFile( sOldFile, sNewFile );
	}
	//--- rename in musiksources.dat ---//
	m_SourcesList.Item( event.GetIndex() ) = sType + event.GetText();
}
示例#4
0
std::string GenerateAttributesSizeFunction(Model &model) {
	std::stringstream stream;
	// Add prototype
	stream << "void CreateAttributesSizes(AttributesSizes &attributes_sizes) {\n";

	for (const auto &agent : model.GetAgents()) {
		for (const auto &field : agent.second.GetFields()) {
			if (!field.second.IsSendable())
				continue;
			stream << "\tattributes_sizes[std::pair<AgentType, Attribute>("
				   << agent.second.GetId() << "," << field.second.GetId()
				   << ")] = sizeof(" << GetTypeAsString(field.second.GetType())
				   << ");\n";
		}
	}
	stream << "}\n";

	return stream.str();
}
示例#5
0
std::string GetTypeAsString(const clang::QualType &type) {
	std::stringstream stream;
	std::string name = type.getAsString();
    // If it is an anonymous structure, print all the fields recursively
    if (name.substr(0,11) == "struct (ano") {
        stream << "struct { ";
		clang::RecordDecl* struct_decl = type.getTypePtr()->getAsStructureType()->getDecl();
		// Print the types of all the fields
        for (const auto* field : struct_decl->fields()) {
			std::string type = GetTypeAsString(field->getType().getCanonicalType());
			std::string name = field->getName();
            stream << type;
            stream << " " << name << "; ";
        }
        stream << "}";
	} else if (type.getTypePtr()->isBooleanType()) {
		return "bool";
	} else {
        stream << type.getAsString(); //just print the type
    }
	return stream.str();
}
示例#6
0
void CSourcesListBox::NewPlaylist( wxString sName, const MusikSongIdArray & arrSongIds, int nType )
{
	//--- check validity ---//
	wxString sCheck = sName;
	sCheck.Replace( wxT( " " ), wxT( "" ) );
	if ( sCheck == wxT( "" ) )
	{
		wxMessageBox( _( "Invalid playlist name." ), MUSIKAPPNAME_VERSION, wxOK | wxICON_INFORMATION );
		return;
	}
	sName.Trim();
	sName.Trim(false);
    bool bRes = false;
	switch ( nType )
	{
	case MUSIK_SOURCES_PLAYLIST_STANDARD:
    //--- create standard playlist ---//
		bRes = CreateStdPlaylist( sName, arrSongIds );
		break;
	//--- create dynamic playlist
	case MUSIK_SOURCES_PLAYLIST_DYNAMIC:
		bRes = CreateDynPlaylist( sName );
		break;
	case MUSIK_SOURCES_NETSTREAM:
		bRes = CreateNetStream( sName );
		break;
	default:
		wxASSERT(false);
	}
    if(bRes)
    {
        wxString sType;
        GetTypeAsString(nType, sType);
        int i = wxMax(m_CurSel,2);
        m_SourcesList.Insert( sType + sName ,i);
        Update();
    }
}	
示例#7
0
void CSourcesListBox::AddMissing( const wxArrayString & playlists ,EMUSIK_SOURCES_TYPE t)
{
	wxString sExt, sName, sAdd,sTypeExt;
	sTypeExt = GetExtFromType(t);
	GetTypeAsString( t, sAdd);
	for ( size_t i = 0; i < playlists.GetCount(); i++ )
	{
		sName = playlists.Item( i );

		sExt = sName.Right( 3 );
		sExt.MakeLower();
		if ( sExt != sTypeExt )
		{
			continue;
		}

		sName = sName.Left( sName.Length() - 4 );
		sName.Replace( wxT( "_" ), wxT( " " ), true );

		if ( FindInSources( sName, t ) == -1 )
			m_SourcesList.Add( sAdd + sName);
	}
}
示例#8
0
// This method calls an existing function with a parameter list
CFunctionCallAttempt CFunctionWrapper::CallFunction(std::string sFunctionName, ParameterList lParameterList)
{
    // The object we'll return to the script
    CReturnValue oReturnValue;

    // Loop through all the functions
    for(FunctionList::iterator iterator = m_lFunctionList.begin(); iterator != m_lFunctionList.end(); iterator++)
    {
        // Do we have a function name match?
        if((*iterator).m_sName == sFunctionName)
        {
            // Do we have enough parameters? (are the parameter lists equally big?)
            if((*iterator).m_lParameterTypes.size() != lParameterList.size())
            {
                // Setup the error message
                std::stringstream ssErrorMessage;
                ssErrorMessage << sFunctionName << " expects " << (*iterator).m_lParameterTypes.size() << " parameter(s), got " << lParameterList.size() << ".";

                return CFunctionCallAttempt(ssErrorMessage.str());
            }

            // Current parameter number
            int iCurrentParameterNumber = 1;

            // Check if every parameter has the correct type, only if the function is type sensitive
            if((*iterator).m_bTypeSensitive)
            {
                for(unsigned int i = 0; i < lParameterList.size(); i++, iCurrentParameterNumber++)
                {
                    if(lParameterList[i].m_eType != (*iterator).m_lParameterTypes[i])
                    {
                        // The types of this parameter differ
                        std::stringstream ssErrorMessage;
                        ssErrorMessage << "Parameter " << iCurrentParameterNumber << " has a bad type (expected " << GetTypeAsString((*iterator).m_lParameterTypes[i]) << ", got " << GetTypeAsString(lParameterList[i].m_eType) << ", in function call " << sFunctionName << ")";

                        return CFunctionCallAttempt(ssErrorMessage.str());
                    }
                }
            }

            // Call the actual function
            oReturnValue = (*iterator).m_pFunctionToCall(lParameterList);
            break;
        }
    }

    // Return a valid CFunctionCallAttempt object
    return CFunctionCallAttempt(oReturnValue);
}