static void DisplayCmpDoc(wxString &  Name)
/*******************************************/
/* Routine de recherche et d'affichage de la doc du composant Name
	La liste des doc est pointee par MList
*/
{
ModList * Mod = MList;

	if ( ! Mod )
	{
		Name.Empty(); return;
	}

	/* Recherche de la description */
	while ( Mod )
	{
		if( ! Mod->m_Name.IsEmpty() && (Mod->m_Name.CmpNoCase(Name) == 0) ) break;
		Mod = Mod->Next;
	}

	if ( Mod )
	{
		Name = ! Mod->m_Doc.IsEmpty() ? Mod->m_Doc  : wxT("No Doc");
		Name += wxT("\nKeyW: ");
		Name += ! Mod->m_KeyWord.IsEmpty() ? Mod->m_KeyWord : wxT("No Keyword");
	}

	else Name = wxEmptyString;
}
// Reads a wxString from a file. File must be open. File is closed automatically.
bool cbRead(wxFile& file, wxString& st, wxFontEncoding encoding)
{
    st.Empty();
    if (!file.IsOpened())
        return false;

    int len = file.Length();
    if (!len)
    {
        file.Close();
        return true;
    }

    char* buff = new char[len+1];
    if (!buff) // remark by killerbot : this is useless, since when out of mem --> exception (this is not malloc you know)
    {
        file.Close();
        return false;
    }
    file.Read((void*)buff, len);
    file.Close();
    buff[len]='\0';

    DetectEncodingAndConvert(buff, st, encoding);
    delete [] buff;

    return true;
}
Exemple #3
0
bool CUserItem::getAsString( wxString& strUser )
{
    wxString wxstr;
    strUser.Empty();
        
    strUser += wxString::Format( _("%ld;"), getUserID() );
    strUser += getUser();
    strUser += _(";");
    // Protect password
    wxstr = getPassword();
    for ( int i=0; i<wxstr.Length(); i++ ) {
        strUser += _("*");
    }
    //strUser += getPassword();
    strUser += _(";");
    strUser += getFullname();
    strUser += _(";");
    vscp_writeFilterToString( getFilter(), wxstr );
    strUser += wxstr;
    strUser += _(";");
    vscp_writeMaskToString( getFilter(), wxstr );
    strUser += wxstr;
    strUser += _(";");
    strUser += getUserRightsAsString();
    strUser += _(";");
    strUser += getAllowedRemotesAsString();
    strUser += _(";");
    strUser += getAllowedEventsAsString();
    strUser += _(";");
    strUser += wxBase64Encode( getNote().mbc_str(), strlen( getNote().mbc_str() ) ); 	
    //strUser += getNote();
    
    return true;
}
Exemple #4
0
bool CCanalConfObj::runWizard( wxWindow* parent,
                                    wxString& inputConfigString,
                                    uint32_t inputConfigFlags,
                                    wxString& resultConfigString, 
                                    uint32_t *presultConfigFlags )
{
    // Clear configuration data
    resultConfigString.Empty();

    CanalConfigWizard wizard( parent );
    wizard.CreateControls( this, inputConfigString, inputConfigFlags );
    wizard.Run(); 

    int pos = 0;
    while ( ( NULL != wizard.m_pgConfig[ pos ] ) && ( pos < MAX_PARAMETERS ) ) {
        resultConfigString += wizard.m_pgConfig[ pos ]->m_strValue;
        pos++;
        if ( ( NULL != wizard.m_pgConfig[ pos ] ) )  resultConfigString += _( ";" );
    }

    pos = 0;
    while ( ( NULL != wizard.m_pgConfigFlags[ pos ] ) && ( pos < MAX_FLAGS ) ) {
        *presultConfigFlags |= wizard.m_pgConfigFlags[ pos ]->m_value;
        pos++;
    }

    wizard.Destroy();
    return true;
}
Exemple #5
0
void SjLogGui::ExplodeMessage(const wxString& all___, unsigned long& severity, unsigned long& time, wxString& msg, wxString& scope)
{
	wxString temp;

	// get and strip severity
	temp = all___.BeforeFirst(wxT('|'));
	temp.ToULong(&severity);
	msg = all___.AfterFirst(wxT('|'));

	// get and strip time
	temp = msg.BeforeFirst(wxT('|'));
	temp.ToULong(&time);
	msg = msg.AfterFirst(wxT('|'));

	// now "msg" is message and optional scope enclosured by "[]"
	scope.Empty();
	int p = msg.Find(wxT('['), true/*from end*/);
	if( p!=-1 )
	{
		scope = msg.Mid(p+1);
		if( scope.Len()>=1 && scope.Last()==wxT(']') )
		{
			scope = scope.Left(scope.Len()-1);
			msg = msg.Left(p).Trim();
		}
	}

	// some finalizing translations (some stuff is logged before the translation system is available)
	if( msg.StartsWith(wxT("Loading "), &temp) )
	{
		msg.Printf(_("Loading %s"), temp.c_str());
	}
}
void NETLIST_EXPORTER::sprintPinNetName( wxString& aResult,
                                    const wxString& aNetNameFormat, NETLIST_OBJECT* aPin,
                                    bool aUseNetcodeAsNetName )
{
    int netcode = aPin->GetNet();

    // Not wxString::Clear(), which would free memory.  We want the worst
    // case wxString memory to grow to avoid reallocation from within the
    // caller's loop.
    aResult.Empty();

    if( netcode != 0 && aPin->GetConnectionType() == PAD_CONNECT )
    {
        if( aUseNetcodeAsNetName )
        {
            aResult.Printf( wxT("%d"), netcode );
        }
        else
        {
        aResult = aPin->GetNetName();

        if( aResult.IsEmpty() )     // No net name: give a name from net code
            aResult.Printf( aNetNameFormat.GetData(), netcode );
        }
    }
}
Exemple #7
0
void D_PAD::ReturnStringPadName( wxString& text ) const
{
#if 0   // m_Padname is not ASCII and not UTF8, it is LATIN1 basically, whatever
        // 8 bit font is supported in KiCad plotting and drawing.

    // Return pad name as wxString, assume it starts as a non-terminated
    // utf8 character sequence

    char    temp[sizeof(m_Padname)+1];      // a place to terminate with '\0'

    strncpy( temp, m_Padname, sizeof(m_Padname) );

    temp[sizeof(m_Padname)] = 0;

    text = FROM_UTF8( temp );

#else

    text.Empty();

    for( int ii = 0;  ii < PADNAMEZ && m_Padname[ii];  ii++ )
    {
        // m_Padname is 8 bit KiCad font junk, do not sign extend
        text.Append( (unsigned char) m_Padname[ii] );
    }
#endif
}
const wxString& RESPONSE::PlainEnglish( void )
{
    static wxString return_string;

    return_string.Empty();

    return ( return_string );
}
Exemple #9
0
void inifile_trim( wxString& buffer )
{
	buffer.Trim(false);			// trims left side.

	if( buffer.Length() <= 1 )	// this I'm not sure about... - air
	{
		buffer.Empty();
		return;
	}

	if( buffer.Left( 2 ) == L"//" )
	{
		buffer.Empty();
		return;
	}

	buffer.Trim(true);			// trims right side.
}
void D_PAD::StringPadName( wxString& text ) const
{
    text.Empty();

    for( int ii = 0;  ii < PADNAMEZ && m_Padname[ii];  ii++ )
    {
        // m_Padname is 8 bit KiCad font junk, do not sign extend
        text.Append( (unsigned char) m_Padname[ii] );
    }
}
Exemple #11
0
bool CUserList::getUserAsString( CUserItem *pUserItem, wxString& strUser )
{
    wxString wxstr;
    strUser.Empty();
    
    // Check pointer
    if ( NULL == pUserItem ) return false;
    
    return pUserItem->getAsString( strUser );    
}
void BatchCommands::Split(const wxString & str, wxString & command, wxString & param)
{
   int splitAt;

   command.Empty();
   param.Empty();

   if (str.IsEmpty()) {
      return;
   }

   splitAt = str.Find(wxT(':'));
   if (splitAt < 0) {
      return;
   }

   command = str.Mid(0, splitAt);
   param = str.Mid(splitAt + 1);

   return;
}
static void DisplayCmpDoc( wxString& aName )
{
    FOOTPRINT_INFO* module_info = MList.GetModuleInfo( aName );

    if( !module_info )
    {
        aName.Empty();
        return;
    }

    aName  = _( "Description: " ) + module_info->GetDoc();
    aName += _( "\nKey words: " ) + module_info->GetKeywords();
}
Exemple #14
0
bool SjColumnMixer::GetQuickInfo(const wxString& url,
                                 wxString& trackName, wxString& leadArtistName, wxString& albumName,
                                 long& playtimeMs)
{
	int  m;
	bool ok = FALSE;

	m_tempInfo.m_trackName.Empty();
	m_tempInfo.m_leadArtistName.Empty();
	m_tempInfo.m_playtimeMs = 0;

	// first, try the "A-Z" module (normally the largest module)
	if( m_libraryModule )
	{
		ok = m_libraryModule->GetTrackInfo(url, m_tempInfo, SJ_TI_QUICKINFO, FALSE/*no log*/);
	}

	// then, try the other modules
	if( !ok )
	{
		for( m = 0; m < m_moduleCount; m++ )
		{
			wxASSERT(m_modules[m]);
			if( m_modules[m] != m_libraryModule )
			{
				ok = m_modules[m]->GetTrackInfo(url, m_tempInfo, SJ_TI_QUICKINFO, FALSE/*no log*/);
				if( ok )
				{
					break;
				}
			}
		}
	}

	// done so far
	if( ok )
	{
		trackName = m_tempInfo.m_trackName;
		leadArtistName = m_tempInfo.m_leadArtistName;
		albumName = m_tempInfo.m_albumName;
		playtimeMs = m_tempInfo.m_playtimeMs;
		return TRUE;
	}
	else
	{
		trackName = url;
		leadArtistName.Empty();
		playtimeMs = 0;
		return FALSE;
	}
}
Exemple #15
0
 wxString& talker_id( const wxString &sentence )
{
   static wxString return_string;

   return_string.Empty();

   if ( sentence.Len() >= 3 )
   {
      if ( sentence[ 0 ] == '$' )
      {
         return_string = sentence.Mid( 1, 2 );
      }
   }

   return( return_string );
}
Exemple #16
0
bool CUserList::getAllUsers( wxString& strAllusers )
{
    wxString wxstr;
    strAllusers.Empty();
    
    VSCPUSERHASH::iterator it;
    for( it = m_userhashmap.begin(); it != m_userhashmap.end(); ++it ) {
        wxString key = it->first;
        CUserItem *pUserItem = it->second;
        if ( getUserAsString( pUserItem, wxstr ) ) {
            strAllusers += wxstr;
            strAllusers += _("\r\n");
        }
    }
    
    return true;
}
void CDialogVolumeAddNew::OnOK(wxCommandEvent &e)
{
  wxString sCopyFrom = m_pChoiceKit->GetStringSelection();
  m_sName = m_pText->GetValue();
  bool bError = true;
  {
    wxBusyCursor xxx;
    if(m_pVolumes->Create(sCopyFrom,m_sName))
    {
      bError = false;
      e.Skip();
    }
  }

  if(bError) // we want wxBusyCursor out of scope here
  {
    m_sName.Empty();
    mainApp::ShowError(m_pVolumes->GetLastError(),this);
  }
}
Exemple #18
0
bool CscopePlugin::CreateListFile(wxString &list_file)
{
    cbProject *prj = Manager::Get()->GetProjectManager()->GetActiveProject();
    if (! prj) return false;

    std::vector< wxFileName > files;
    m_view->GetWindow()->SetMessage(_("Creating file list..."), 5);

    for (FilesList::iterator it = prj->GetFilesList().begin(); it != prj->GetFilesList().end(); ++it)
    {
        wxFileName fn( (*it)->file.GetFullPath() );

        // To prevent cscope from going into an infinite loop while parsing the file list,
        // only keep track of existing files (in case it was removed with an external tool like git).
        if (fn.IsFileReadable())
            files.push_back(fn);
    }

	//create temporary file and save the file-list there
	wxFileName projectfilename(prj->GetFilename());

	list_file = prj->GetBasePath() + projectfilename.GetName() + _T(".cscope_file_list");

	wxFFile file(list_file, _T("w+b"));
	if (!file.IsOpened())
	{
		wxLogMessage(_("Failed to open temporary file ") + list_file);
		list_file.Empty();
		return false;
	}

	//write the content of the files into the temporary file
	wxString content;
	for (size_t i=0; i< files.size(); i++)
		content << _T("\"") + files[i].GetFullPath() << _T("\"\n");

	file.Write( content );
	file.Flush();
	file.Close();
	return true;
}
Exemple #19
0
const wxString& SENTENCE::Field( int desired_field_number ) const
{
//   ASSERT_VALID( this );

   static wxString return_string;
   return_string.Empty();

   int index                = 1; // Skip over the $ at the begining of the sentence
   int current_field_number = 0;
   int string_length        = 0;

   string_length = Sentence.Len();

   while( current_field_number < desired_field_number && index < string_length )
   {
      if ( Sentence[ index ] == ',' || Sentence[ index ] == '*' )
      {
         current_field_number++;
      }

      if( Sentence[ index ] == '*')
          return_string += Sentence[ index ];

      index++;
   }

   if ( current_field_number == desired_field_number )
   {
      while( index < string_length    &&
             Sentence[ index ] != ',' &&
             Sentence[ index ] != '*' &&
             Sentence[ index ] != 0x00 )
      {
         return_string += Sentence[ index ];
         index++;
      }
   }


   return( return_string );
}
Exemple #20
0
const wxString& GLL::PlainEnglish( void )
{
//   ASSERT_VALID( this );

   static wxString return_string;

   return_string.Empty();
/*
   char temp_string[ 128 ];

   sprintf( temp_string, "At %d, you were at Latitude %ld %s, Longitude %ld %s.",
            (const char *) UTCTime,
            Position.Latitude.Latitude,
            ( Position.Latitude.Northing == North ) ? "North" : "South",
            Position.Longitude.Longitude,
            ( Position.Longitude.Easting == East ) ? "East" : "West" );

   return_string = temp_string;
*/
   return( return_string );
}
bool CscopePlugin::CreateListFile(wxString &list_file)
{
    cbProject *prj = Manager::Get()->GetProjectManager()->GetActiveProject();
    if (! prj) return false;

    std::vector< wxFileName > files;
	m_view->GetWindow()->SetMessage(_T("Creating file list..."), 5);

    for ( unsigned int k = 0 ; k < static_cast<unsigned int>(prj->GetFilesCount()) ; ++k )
    {
        wxFileName fn( prj->GetFile(k)->file.GetFullPath() );
        files.push_back(fn);
    }

	//create temporary file and save the file-list there
	wxFileName projectfilename(prj->GetFilename());

	list_file = prj->GetBasePath() +
                projectfilename.GetName() +
                _T(".cscope_file_list");

	wxFFile file(list_file, _T("w+b"));
	if (!file.IsOpened())
	{
		wxLogMessage(_T("Failed to open temporary file ") + list_file);
		list_file.Empty();
		return false;
	}

	//write the content of the files into the temporary file
	wxString content;
	for (size_t i=0; i< files.size(); i++)
		content << _T("\"") + files[i].GetFullPath() << _T("\"\n");

	file.Write( content );
	file.Flush();
	file.Close();
	return true;
}
Exemple #22
0
size_t nwxProcess::ProcessIO(
  wxInputStream *pIn, 
  wxString &sLine,
  bool bErrStream)
{
  size_t nRtn = 0;
  size_t nLen;
  char *pBuffer;
  char *pEnd;
  const int BUFFER_SIZE = 512;
  char sBuffer[BUFFER_SIZE + 1];
  char EOL = '\n';
  if(pIn->CanRead())
  {
    nRtn = pIn->Read(sBuffer,BUFFER_SIZE).LastRead();
    sBuffer[nRtn] = 0;
    if(nRtn)
    {
      pBuffer = &sBuffer[0];
      for(pEnd = strchr(pBuffer,EOL);
          pEnd != NULL;
          pEnd = strchr(pBuffer,EOL))
      {
        *pEnd = 0;
        sLine.Append(pBuffer);
        sLine.Append(wxChar(EOL));
        *pEnd = EOL; // restore
        nLen = sLine.Len();
        ProcessLine(sLine.utf8_str(), nLen, bErrStream);
        sLine.Empty();
        pBuffer = pEnd;
        pBuffer++;
      }
      sLine += pBuffer;
    }
  }
  return nRtn;
}
Exemple #23
0
bool GetToken(wxInputStream& input, wxString& result, unsigned int& lineNumber)
{

    result.Empty();

    SkipWhitespace(input, lineNumber);

    // Reached the end of the file.
    if (input.Eof())
    {
        return false;
    }

    char c = input.GetC();

    if (c == '\"')
    {

        // Quoted string, search for the end quote.

        do
        {
            result += c;
            c = input.GetC();
        }
        while (input.IsOk() && c != '\"');

        result += c;
        return true;

    }

    char n = input.Peek();

    if (IsDigit(c) || (c == '.' && IsDigit(n)) || (c == '-' && IsDigit(n)))
    {

        bool hasDecimal = false;

        while (!IsSpace(c))
        {

            result.Append(c);

            if (input.Eof())
            {
                return true;
            }

            c = input.Peek();

            if (!IsDigit(c) && c != '.')
            {
                return true;
            }

            input.GetC();

            if (c == '\n')
            {
                ++lineNumber;
                return true;
            }

        }

    }
    else
    {

        if (IsSymbol(c))
        {
            result = c;
            return true;
        }

        while (!IsSpace(c) && !input.Eof())
        {

            result.Append(c);

            if (IsSymbol(input.Peek()))
            {
                break;
            }

            c = input.GetC();

            if (c == '\n')
            {
                ++lineNumber;
                return true;
            }

        }

    }

    return true;

}
Exemple #24
0
wxmailto_status Contact::GetRFC2822Address(wxString& address) const
{
	wxmailto_status status;
	address.Empty();

	if (CONTACT_GROUP==m_contact_type)
	{
		if (m_name.IsEmpty())
			return LOGERROR(ID_CONTACT_GROUP_WITHOUT_NAME);

		address.Append(m_name);
		address.Append(":");

		wxString child_address;
		wxBool first = true;
		ContactList::iterator iter;
		for (iter=m_children->begin(); iter!=m_children->end(); ++iter)
		{
			const Contact* current = *iter;
			if (!current) continue;
			current = current->GetCurrentValidContact();
			if (!current)
				return LOGERROR(ID_CONTACT_NO_VALID_ADDRESS_FOR_PERIOD);

 			if (ID_OK != (status=current->GetRFC2822Address(child_address)))
				return status;

			if (!first)
			{
				address.Append(", ");
			}
			address.Append(m_name);
			first = false;
		}
		address.Append(";");
	}
	else if (CONTACT_PERSON==m_contact_type)
	{
		if (m_email.IsEmpty()) //ToDo: Handle mail groups
			return LOGERROR(ID_CONTACT_WITHOUT_EMAIL);

		if (!m_name.IsEmpty())
		{
			address.Append("\"");
			address.Append(m_name);
			address.Append("\" ");
		}
	
		address.Append("<");
		address.Append(m_email);
		address.Append(">");
	
		if (!m_comment.IsEmpty())
		{
			address.Append(" (");
			address.Append(m_comment);
			address.Append(" )");
		}
	}
	else
	{
		return LOGERROR(ID_CONTACT_INVALID_TYPE);
	}

	return ID_OK;
}
Exemple #25
0
bool wxRegKey::QueryValue(const wxString& szValue,
                          wxString& strValue,
                          bool WXUNUSED_IN_WINCE(raw)) const
{
    if ( CONST_CAST Open(Read) )
    {

        // first get the type and size of the data
        DWORD dwType=REG_NONE, dwSize=0;
        m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
                                        RegValueStr(szValue),
                                        RESERVED,
                                        &dwType, NULL, &dwSize);
        if ( m_dwLastError == ERROR_SUCCESS )
        {
            if ( !dwSize )
            {
                // must treat this case specially as GetWriteBuf() doesn't like
                // being called with 0 size
                strValue.Empty();
            }
            else
            {
                m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
                                                RegValueStr(szValue),
                                                RESERVED,
                                                &dwType,
                                                (RegString)(wxChar*)wxStringBuffer(strValue, dwSize),
                                                &dwSize);

                // expand the var expansions in the string unless disabled
#ifndef __WXWINCE__
                if ( (dwType == REG_EXPAND_SZ) && !raw )
                {
                    DWORD dwExpSize = ::ExpandEnvironmentStrings(strValue.t_str(), NULL, 0);
                    bool ok = dwExpSize != 0;
                    if ( ok )
                    {
                        wxString strExpValue;
                        ok = ::ExpandEnvironmentStrings(strValue.t_str(),
                                                        wxStringBuffer(strExpValue, dwExpSize),
                                                        dwExpSize
                                                        ) != 0;
                        strValue = strExpValue;
                    }

                    if ( !ok )
                    {
                        wxLogLastError(wxT("ExpandEnvironmentStrings"));
                    }
                }
#endif
                // __WXWINCE__
            }

            if ( m_dwLastError == ERROR_SUCCESS )
            {
                // check that it was the right type
                wxASSERT_MSG( !IsNumericValue(szValue),
                              wxT("Type mismatch in wxRegKey::QueryValue().") );

              return true;
            }
        }
    }

    wxLogSysError(m_dwLastError, _("Can't read value of '%s'"),
                  GetFullName(this, szValue));
    return false;
}