Пример #1
0
void SQLite::deletingSelectedUpletConn(SQLiteStatement *pStmt0, wxString uplet) {
    // méthode ad hoc : suppose uplet bien "formé", cad 4 token - entre autres !
    map <string, string> paramsDic;
    wxString host, port, dbname, user, password;
    wxStringTokenizer tokenizer(uplet, sep, wxTOKEN_STRTOK);
    int ijk = 0;
    while ( tokenizer.HasMoreTokens()) {
        switch (ijk)
        {
            case 0: { paramsDic["host"] = wxString(tokenizer.GetNextToken()); break; }
            case 1: { paramsDic["port"] = wxString(tokenizer.GetNextToken()); break; }
            case 2: { paramsDic["dbname"] = wxString(tokenizer.GetNextToken()); break; }
            case 3: { paramsDic["user"] = wxString(tokenizer.GetNextToken()); break; }
        }
        ijk = ijk + 1;
    }
    
    sql = "delete from ";
    sql.Append(tblName);
    sql.Append(" WHERE host='"); sql.Append(paramsDic["host"]);
    sql.Append("' AND port='"); sql.Append(paramsDic["port"]);
    sql.Append("' AND dbname='"); sql.Append(paramsDic["dbname"]);
    sql.Append("' AND user='******';");
    pStmt0->SqlStatement(string(sql.mb_str()));
}
Пример #2
0
void wxPropertyValue::WritePropertyClause(wxString& stream)  // Write this expression as a top-level clause
{
  if (m_type != wxPropertyValueList)
    return;

  wxPropertyValue *node = m_value.first;
  if (node)
  {
    node->WritePropertyType(stream);
    stream.Append( wxT("(") );
    node = node->m_next;
    bool first = true;
    while (node)
    {
      if (!first)
        stream.Append( wxT("  ") );
      node->WritePropertyType(stream);
      node = node->m_next;
      if (node)
        stream.Append( wxT(",\n" ) );
      first = false;
    }
    stream.Append( wxT(").\n\n") );
  }
}
Пример #3
0
int SQLite::existConn(SQLiteStatement *pStmt0) {
    // **** une connexion ? 0 : non ; >0 : oui
    sql = "SELECT * FROM ";
    sql.Append(tblName);
    sql.Append(";");
    pStmt0->Sql(string(sql.mb_str()));
    return pStmt0->GetNumberOfRows();
}
Пример #4
0
void SQLite::deletingConnTbl(SQLiteStatement *pStmt0) {
    cout << "delConnTbl-in" << endl;
    sql = "DELETE FROM ";
    sql.Append(tblName);
    sql.Append(";");
    cout << "sql : " << sql << endl;
    pStmt0->SqlStatement(string(sql.mb_str()));
    cout << "delConnTbl-out" << endl;
}
void NmeaConverter_pi::SendNMEASentence(wxString sentence)
{
    sentence.Trim();
    wxString Checksum = ComputeChecksum(sentence);
    sentence = sentence.Append(wxT("*"));
    sentence = sentence.Append(Checksum);
    sentence = sentence.Append(wxT("\r\n"));
    PushNMEABuffer(sentence);
}
Пример #6
0
int AutoCompData::BuildMemberList( const wxString& name, wxString& list ) const
{
   // First find the object...
   const AutoCompClass* found = FindClassOrObject( name );
   if ( !found )
      return 0;

   // TODO: Should we add members of dupes?

   // Now loop till we run out of base classes.
   wxArrayString tempArray;
   wxString temp;
   size_t len = 0;
   while ( found )
   {
      for ( int i=0; i < found->GetFunctions().GetCount(); i++ ) 
      {
         temp = found->GetFunctions()[i]->GetMethodName() + IDENT_FUNCTION;
         len += temp.Len() + 1;
         tempArray.Add( temp );
      }

      for ( int i=0; i < found->GetVars().GetCount(); i++ ) 
      {
         temp = found->GetVars()[i]->GetName() + IDENT_VAR;
         len += temp.Len() + 1;
         tempArray.Add( temp );
      }

      const wxString& base = found->GetBase();
      if ( base.IsEmpty() )
         break;

      found = FindClassOrObject( base );
   }

   wxString last, member;
   tempArray.Sort( CmpStringNoCase );
   list.Alloc( len - 1 );
   for ( int i=0; i < tempArray.GetCount(); i++ ) {
      member = tempArray[i];
      if ( member.CmpNoCase( last ) == 0 )
         continue;
      list.Append( member );
      list.Append( ' ' );
      last = member;
   }
   list.RemoveLast();
   list.Shrink();

   return (int)tempArray.GetCount();
}
Пример #7
0
SQLiteStatement *SQLite::ptrTableConnParams() {
    SQLiteDatabase *pDatabase0 = new SQLiteDatabase(dbfile, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL); //!!! SQLITE_OPEN_CREATE nécessaire pour création
    SQLiteStatement *pStmt0 = new SQLiteStatement(pDatabase0);
    
    sql = "SELECT * FROM sqlite_master WHERE type='table' AND name='";
    sql.Append(tblName);
    sql.Append("';");
    pStmt0->Sql(string(sql.mb_str()));
    if (pStmt0->GetNumberOfRows() != 1) {
        sql = "CREATE TABLE ";
        sql.Append(tblName);
        sql.Append(" (def integer, host VARCHAR(64), port VARCHAR(64), dbname VARCHAR(64), user VARCHAR(64), password VARCHAR(64));");
        pStmt0->SqlStatement(string(sql.mb_str()));
    }
    return pStmt0;
}
Пример #8
0
// utility function: read a wxString from a wxInputStream
static void ReadString(wxString& str, wxInputStream* s, wxMBConv& conv)
{
    size_t streamSize = s->GetSize();

    if (streamSize == ~(size_t)0)
    {
        const size_t bufSize = 4095;
        char buffer[bufSize+1];
        size_t lastRead;

        do
        {
            s->Read(buffer, bufSize);
            lastRead = s->LastRead();
            buffer[lastRead] = 0;
            str.Append(wxString(buffer, conv));
        }
        while (lastRead == bufSize);
    }
    else
    {
        char* src = new char[streamSize+1];
        s->Read(src, streamSize);
        src[streamSize] = 0;
        str = wxString(src, conv);
        delete[] src;
    }
}
Пример #9
0
wxArrayString SQLite::gettingAllUpletConn(SQLiteStatement *pStmt0) {
    sql = "SELECT def, host, port, dbname, user FROM ";
    sql.Append(tblName);
    sql.Append(" order by def desc;");
    pStmt0->Sql(string(sql.mb_str()));
    wxArrayString uplets;
    while(pStmt0->FetchRow()) {
        wxString buf;
        buf.Append(pStmt0->GetColumnString(1)); buf.Append(sep);
        buf.Append(pStmt0->GetColumnString(2)); buf.Append(sep);
        buf.Append(pStmt0->GetColumnString(3)); buf.Append(sep);
        buf.Append(pStmt0->GetColumnString(4)); buf.Append(sep);
        uplets.Add(buf);
    }
    return uplets;
}
Пример #10
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
}
Пример #11
0
int SQLite::existDefUpletConn(SQLiteStatement *pStmt0) {
    // **** une connexion par défaut existe ? 0 : non ; >0 : rowid de l'uplet de connexion par défaut
    int rowidDef = 0;
    
    sql = "SELECT rowid, def FROM ";
    sql.Append(tblName);
    sql.Append(" where def="); sql.Append(wxString::Format(wxT("%d"), 1)); sql.Append(";");
    pStmt0->Sql(string(sql.mb_str()));
    if (pStmt0->GetNumberOfRows() == 0) {
        return rowidDef;
    } else if (pStmt0->GetNumberOfRows() == 1) {
        while(pStmt0->FetchRow()) {
            return pStmt0->GetColumnInt(0);
        }
    }
    return -9999;
}
Пример #12
0
	void treePrint(wxString name, bool bDirs=TRUE)
	{
#if 0
		for (int i=0; i<m_iTreeLevel*5; i++) 
			m_textCtrlInfo->AppendText(" ");

		m_textCtrlInfo->AppendText("|--" + name + "\n");
#else
		for (int i=0; i<m_iTreeLevel*5; i++) 
			m_strInfo.Append(" ");

		if (bDirs)
			m_strInfo.Append("|--" + name + "\n");
		else
			m_strInfo.Append("|--*" + name + "\n");
#endif
	}
Пример #13
0
map <string, string> SQLite::gettingDefUpletConn(SQLiteStatement *pStmt0) {
    sql = "SELECT rowid, def, host, port, dbname, user, password FROM ";
    sql.Append(tblName);
    sql.Append(" where def=");
    sql.Append(wxString::Format(wxT("%d"), 1));
    sql.Append(";");
    pStmt0->Sql(string(sql.mb_str()));
    map <string, string> paramsDic;
    while(pStmt0->FetchRow()) {
        paramsDic["host"] = pStmt0->GetColumnString(2);
        paramsDic["port"] = pStmt0->GetColumnString(3);
        paramsDic["dbname"] = pStmt0->GetColumnString(4);
        paramsDic["user"] = pStmt0->GetColumnString(5);
        paramsDic["password"] = pStmt0->GetColumnString(6);
    }
    return paramsDic;
}
Пример #14
0
void ConnectionHandler::DistributeNMEAMessage( wxString &message, wxString &sourcePort )
{
    for ( size_t i = 0; i < Connections.Count(); i++ )
    {
        SerialConnection *conn = Connections[i];
        if ( sourcePort != conn->GetPortName() ) //Not repeat to self
            conn->SendNMEAMessage( message, sourcePort );
    }
    p_plugin->SendSentenceToCore( message.Append( _T("\r\n") ) );
}
void nmeaSendObj::SplitStringAlphaDigit(wxString theStr, wxString &alpha, long &digiti)
{
    wxString digit;
    for ( unsigned int i = 0; i < theStr.length(); i++ )
        if ( VarAlpha.Find(theStr.Mid(i,1)) != wxNOT_FOUND )
            alpha.Append( theStr.Mid(i,1) );
        else if ( VarDigit.Find(theStr.Mid(i,1)) != wxNOT_FOUND )
            digit.Append( theStr.Mid(i,1) );
    if(!digit.ToLong(&digiti)) { digiti=-1; }    
}
Пример #16
0
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] );
    }
}
Пример #17
0
bool CGUISetupFrame::getDesktopDir(wxString& dir) const
{
	bool ret = ::wxGetEnv(HOME_ENV, &dir);

	if (!ret)
		return false;

	dir.Append(DESKTOP_DIR);

	return wxDir::Exists(dir);
}
Пример #18
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;
}
Пример #19
0
void ctlSQLGrid::AppendColumnHeader(wxString &str, wxArrayInt columns)
{
	if(settings->GetColumnNames())
	{
		bool CopyQuoting = (settings->GetCopyQuoting() == 1 || settings->GetCopyQuoting() == 2);
		size_t i;

		for(i = 0; i < columns.Count() ; i++)
		{
			long columnPos = columns.Item(i);
			if(i > 0)
				str.Append(settings->GetCopyColSeparator());

			if(CopyQuoting)
				str.Append(settings->GetCopyQuoteChar());
			str.Append(GetColumnName(columnPos));
			if(CopyQuoting)
				str.Append(settings->GetCopyQuoteChar());

		}
		str.Append(END_OF_LINE);
	}
}
Пример #20
0
//----------------------------------------------------------------------------------------
wxChar *GetExtendedDBErrorMsg(wxChar *ErrFile, int ErrLine)
{
    static wxString msg;
    wxString tStr;
    if (ErrFile || ErrLine)
    {
        msg += _T("File: ");
        msg += ErrFile;
        msg += _T("   Line: ");
        tStr.Printf(_T("%d"),ErrLine);
        msg += tStr.GetData();
        // msg += _T("\n");
    }
    msg.Append (_T("\nODBC errors:\n"));
    // msg += _T("\n");
    /* Scan through each database connection displaying
    * any ODBC errors that have occurred. */
    wxDbList *pDbList;
    for (pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext)
    {
        // Skip over any free connections
        if (pDbList->Free)
            continue;
        // Display errors for this connection
        for (int i = 0; i < DB_MAX_ERROR_HISTORY; i++)
        {
            if (pDbList->PtrDb->errorList[i])
            {
                msg.Append(pDbList->PtrDb->errorList[i]);
                if (wxStrcmp(pDbList->PtrDb->errorList[i],wxEmptyString) != 0)
                    msg.Append(_T("\n"));
            }
        }
    }
    msg += _T("\n");
    return (wxChar*) (const wxChar*) msg;
}  // GetExtendedDBErrorMsg
Пример #21
0
map <string, string> SQLite::gettingSelectedUpletConn(SQLiteStatement *pStmt0, wxString uplet) {
    // méthode ad hoc : suppose uplet bien "formé", cad 4 token - entre autres !
    map <string, string> paramsDic;
    wxString host, port, dbname, user, password;
    wxStringTokenizer tokenizer(uplet, sep, wxTOKEN_STRTOK);
    int ijk = 0;
    while ( tokenizer.HasMoreTokens() )
    {
        switch (ijk)
        {
            case 0: { paramsDic["host"] = wxString(tokenizer.GetNextToken()); break; }
            case 1: { paramsDic["port"] = wxString(tokenizer.GetNextToken()); break; }
            case 2: { paramsDic["dbname"] = wxString(tokenizer.GetNextToken()); break; }
            case 3: { paramsDic["user"] = wxString(tokenizer.GetNextToken()); break; }
        }
        ijk = ijk + 1;
    }
    
    sql = "SELECT host, port, dbname, user, password FROM ";
    sql.Append(tblName);
    sql.Append(" WHERE host='"); sql.Append(paramsDic["host"]);
    sql.Append("' AND port='"); sql.Append(paramsDic["port"]);
    sql.Append("' AND dbname='"); sql.Append(paramsDic["dbname"]);
    sql.Append("' AND user='******';");
    pStmt0->Sql(string(sql.mb_str()));
    
    if (pStmt0->GetNumberOfRows() == 1) {
        while(pStmt0->FetchRow()) {
            paramsDic["password"] = wxString(pStmt0->GetColumnString(4));
        }
    } else {
        wxMessageBox(wxT("ERREUR FATALE"), wxT("OK"));
    };
    
    return paramsDic;
}
Пример #22
0
void SQLite::settingDefUpletConn(SQLiteStatement *pStmt0, int rowid, int def) {
    // **** changer la connexion par défaut
    sql = "update ";
    sql.Append(tblName);
    sql.Append(" set def=");
    sql.Append(wxString::Format(wxT("%d"), def));
    sql.Append(" where rowid=");
    sql.Append(wxString::Format(wxT("%d"), abs(rowid)));
    sql.Append(";");
    pStmt0->SqlStatement(string(sql.mb_str()));
}
Пример #23
0
bool wxsCoder::ApplyChangesEditor(cbEditor* Editor,const wxString& Header,const wxString& End,wxString& Code,bool CodeHasHeader,bool CodeHasEnd,wxString& EOL)
{
	cbStyledTextCtrl* Ctrl = Editor->GetControl();
	int FullLength = Ctrl->GetLength();

    if ( EOL.IsEmpty() )
    {
        // Detecting EOL style in source
        for ( int i=0; i<FullLength; i++ )
        {
            wxChar ch = Ctrl->GetCharAt(i);
            if ( ch==_T('\n') || ch==_T('\r') )
            {
                EOL = ch;
                if ( ++i < FullLength )
                {
                    wxChar ch2 = Ctrl->GetCharAt(i);
                    if ( (ch2==_T('\n') || ch2==_T('\r')) && ch!=ch2 )
                    {
                        EOL.Append(ch2);
                    }
                }
                break;
            }
        }
    }

    // Searching for beginning of section to replace
	Ctrl->SetSearchFlags(wxSCI_FIND_MATCHCASE);
	Ctrl->SetTargetStart(0);
	Ctrl->SetTargetEnd(FullLength);
	int Position = Ctrl->SearchInTarget(Header);

	if ( Position == -1 )
	{
	    Manager::Get()->GetLogManager()->DebugLog(F(_("wxSmith: Couldn't find code with header:\n\t\"%s\"\nin file '%s'"),
			#if wxCHECK_VERSION(2, 9, 0)
			Header.wx_str(),
			Editor->GetFilename().wx_str()));
			#else
			Header.c_str(),
			Editor->GetFilename().c_str()));
			#endif
		return false;
	}
Пример #24
0
//////////////////////////////////////////////////////////////////////////
//读取文件内容
void ThreadWork::readFileData( wxString &path, wxString &data )
{
	wxFFile f( path, "rb" );
	if( !f.IsOpened() )
		return;

	wxChar *chr = new wxChar;
	unsigned long int i = 1;
	unsigned long int fileLength = f.Length();
	for( i; i <= fileLength; i++ )
	{
		f.Read( chr, 1 );
		if( *chr != 0 )
			data.Append( *chr );
		else
			break;
		f.Seek( i );
	}
}
Пример #25
0
//--------------------------------------------------------------------------------
void CUIEdPane::RemoveViewerTemp(wxString path,bool removeAll)
{
#ifdef _DEBUG
    return;
#endif

    if (!path.EndsWith(L"\\") && !path.EndsWith(L"/"))
        path.Append(L"/");

    wxDir dir(path);

    wxString file;
    bool doing=dir.GetFirst(&file,L"",wxDIR_FILES);

    while (doing)
    {
        if (file.Lower().StartsWith(VIEWER_TEMP) || removeAll)
        {
#ifdef I3D_OS_WINDOWS
            SetFileAttributes((path+file).c_str(),FILE_ATTRIBUTE_NORMAL);
#else
            chmod((path+file).mb_str(),S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
#endif
            wxRemoveFile(path+file);
        }

        doing=dir.GetNext(&file);
    }
    doing=dir.GetFirst(&file,L"",wxDIR_DIRS);

    while (doing)
    {
        if (file.IsSameAs(VIEWER_TEMP,false) || removeAll)
        {
            RemoveViewerTemp(path+file,true);
            wxFileName::Rmdir(path+file);
        }
        else
            RemoveViewerTemp(path+file,false);

        doing=dir.GetNext(&file);
    }
}
//=====================================================================================
/*static*/ bool ChatPanel::UnpackChatMessage( const Socket::Packet& inPacket, wxString& message, int& color )
{
	if( inPacket.GetType() != Socket::Packet::CHAT_MESSAGE )
		return false;

	const wxInt32* data = ( const wxInt32* )inPacket.GetData();

	if( inPacket.ByteSwap() )
		color = wxINT32_SWAP_ALWAYS( data[0] );
	else
		color = data[0];

	message = "";
	int messageLength = ( inPacket.GetSize() - 1 ) / sizeof( wxInt32 );
	for( int i = 1; i <= messageLength; i++ )
	{
		wxInt32 word = inPacket.ByteSwap() ? wxINT32_SWAP_ALWAYS( data[i] ) : data[i];
		wxUniChar uniChar( word );
		message.Append( uniChar );
	}

	return true;
}
Пример #27
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;

}
Пример #28
0
/**
 * レス内に画像があれば<img>タグを付ける
 */
void XrossBoardUtil::AddImgTag(wxString& responseText) {

     if (regexImage.IsValid() && regexImage.Matches(responseText)) {
	  // 画像URLを保存する配列
	  wxArrayString array;
	  wxString text = responseText;
	  wxString tmp;
	  size_t start, len;

	  // デフォルト画像の読み込み
	  wxImage image;
	  wxBitmap bitmap;

          // load wxImage
	  if (!image.LoadFile(defaultIconImg)) 
	  {
	       wxMessageBox(wxT("画像ファイルの読み出しに失敗しました"),
			    wxT("wxMemoryFSHandler"),
			    wxICON_ERROR);
	       return;
	  }
	  // wxImage to wxBitmap
	  bitmap = wxBitmap(image);

	  if (!bitmap.Ok()) 
	  {
	       wxMessageBox(wxT("画像ファイルの読み出しに失敗しました"),
			    wxT("wxMemoryFSHandler"),
			    wxICON_ERROR);
	       return;
	  }

	  // HTMLに改行を加える
	  responseText.Append(wxT(BR));

	  for (tmp = text; regexImage.Matches(tmp);
	       tmp = tmp.SubString(start + len, tmp.Len())) 
	  {
	       // ex) tmp = http://hogehoge.jpg
	       regexImage.GetMatch(&start, &len, 0);
	       array.Add(tmp.SubString(start, start + len - 1));
	  }

	  if (array.GetCount() == 0)
	  {
	       // 画像ファイルがなければHTMLに改行を加えて終了
	       responseText.Append(wxT(BR));
	       return;
	  }

	  // XrossBoardのフレームを呼び出す
	  XrossBoard* wxXrossBoard = dynamic_cast<XrossBoard*>(wxWindow::FindWindowById(ID_WxXrossBoard));
	  std::set<wxString> hashedImageFileSet;
	  wxXrossBoard->GetHashedImageFileSet(hashedImageFileSet);

	  for (int i = 0; i < array.GetCount();i++) {


	       //
	       // array { 
	       //   "http://hogehogeA.jpg",
	       //   "http://hogehogeB.jpg",
	       //   "http://hogehogeC.jpg"
	       // };
	       //
	       // ex) <img src=\"memory:logo.pcx\">
	       const wxString url = array[i];
	       
	       PartOfURI uri;
	       if (XrossBoardUtil::SubstringURI(url, &uri))
	       {
		    const wxString ext = ::wxFileName(uri.path, wxPATH_UNIX).GetExt();
		    const wxBitmapType type = DetermineBitmapType(ext);
		    const wxString hashedName = GenerateMD5String(url) + wxT(".") + ext;

		    if (hashedImageFileSet.find( hashedName ) != hashedImageFileSet.end())
		    {
			 // すでにwxMemoryFSHandlerに登録済みのファイルなのでスキップする
			 continue;
		    }

		    wxString imageFilePath = ::wxGetHomeDir();
		    imageFilePath << wxFILE_SEP_PATH;
		    imageFilePath << XROSSBOARD_DIR;
		    imageFilePath << wxFILE_SEP_PATH;
		    imageFilePath << wxT("cache");
		    imageFilePath << wxFILE_SEP_PATH;
		    imageFilePath << GenerateMD5String(url);
		    imageFilePath << wxT(".");
		    imageFilePath << ext;

		    wxImage thumbnail;

		    if ( ::wxFileName(imageFilePath).FileExists() && thumbnail.LoadFile(imageFilePath))
		    {
			 const wxBitmap thumbnailBitmap = wxBitmap(thumbnail);

			 if (thumbnailBitmap.Ok())
			 {
			      // 画像ファイルが存在するならば
			      wxMemoryFSHandler::AddFile(hashedName, thumbnailBitmap, type);
			      hashedImageFileSet.insert(hashedName);
			      
			      const int height = thumbnailBitmap.GetHeight();
			      const int width  = thumbnailBitmap.GetWidth();

			      // 高さは150pで合わせる
			      const wxString thumbnailWidth = 
				   wxString::Format(wxT("\" width=%d height=150 /></p>"), width * 150 / height);
			      const wxString tag = wxT("<p><img src=\"memory:") + hashedName + thumbnailWidth;
			      responseText.Append(tag);
			 }
		    }
	       }
	       else
	       {
		    responseText.Append(wxT("<p><img src=\"memory:") + defaultIconImg + wxT("\" width=16 height=16 /></p>"));
	       }
	  }
	  // HTMLに改行を加える
	  responseText.Append(wxT(BR));
	  wxXrossBoard->SetHashedImageFileSet(hashedImageFileSet);
     }
}
Пример #29
0
void Tokenizer::ReadParentheses(wxString& str)
{
    static const size_t maxBufferLen = 4093;
    wxChar buffer[maxBufferLen + 3];
    buffer[0] = _T('$'); // avoid segfault error
    wxChar* realBuffer = buffer + 1;
    wxChar* p = realBuffer;

    int level = 0;

    while (NotEOF())
    {
        while (SkipComment())
            ;
        wxChar ch = CurrentChar();

        while (ch == _T('#')) // do not use if
        {
            const PreprocessorType type = GetPreprocessorType();
            if (type == ptOthers)
                break;
            HandleConditionPreprocessor(type);
            ch = CurrentChar();
        }

        const unsigned int startIndex = m_TokenIndex;

        switch(ch)
        {
        case _T('('):
            {
                ++level;
                *p = ch;
                ++p;
            }
            break;

        case _T(')'):
            {
                if (*(p - 1) <= _T(' '))
                    --p;
                --level;
                *p = ch;
                ++p;
            }
            break;

        case _T('\''):
        case _T('"'):
            {
                MoveToNextChar();
                SkipToStringEnd(ch);
                MoveToNextChar();
                const size_t writeLen = m_TokenIndex - startIndex;
                const size_t usedLen = p - realBuffer;
                if (usedLen + writeLen > maxBufferLen)
                {
                    if (writeLen > maxBufferLen)
                    {
                        TRACE(_T("ReadParentheses, Catch Exception 1: %d"), writeLen);
                        return;
                    }

                    if (p != realBuffer)
                    {
                        str.Append(realBuffer, usedLen);
                        p = realBuffer;
                    }

                    str.Append((const wxChar*)m_Buffer + startIndex, writeLen);
                }
                else
                {
                    memcpy(p, (const wxChar*)m_Buffer + startIndex, writeLen * sizeof(wxChar));
                    p += writeLen;
                }

                continue;
            }
            break;

        case _T(','):
            {
                if (*(p - 1) <= _T(' '))
                    --p;

                *p = _T(',');
                *++p = _T(' ');
                ++p;
            }
            break;

        case _T('*'):
            {
                if (*(p - 1) <= _T(' '))
                    --p;

                *p = _T('*');
                *++p = _T(' ');
                ++p;
            }
            break;

        case _T('&'):
            {
                if (*(p - 1) <= _T(' '))
                    --p;

                *p = _T('&');
                *++p = _T(' ');
                ++p;
            }
            break;

        case _T('='):
            {
                if (*(p - 1) <= _T(' '))
                {
                    *p = _T('=');
                    *++p = _T(' ');
                    ++p;
                }
                else
                {
                    switch (*(p - 1))
                    {
                    case _T('='):
                    case _T('!'):
                    case _T('>'):
                    case _T('<'):
                        {
                            *p = _T('=');
                            *++p = _T(' ');
                            ++p;
                        }

                    default:
                        {
                            *p = _T(' ');
                            *++p = _T('=');
                            *++p = _T(' ');
                            ++p;
                        }
                    }
                }
            }
            break;

        case _T(' '):
            {
                if (*(p - 1) != _T(' ') && *(p - 1) != _T('('))
                {
                    *p = _T(' ');
                    ++p;
                }
            }
            break;

        case _T('\r'):
        case _T('\t'):
            break;

        case _T('\n'): // we need keep the \n for records paras correct position
            if (*(p - 1) == _T(' '))
                --p;
            if (*(p - 1) != _T('('))
            {
                *p = ch;
                ++p;
            }
            break;

        default:
            {
                *p = ch;
                ++p;
            }
            break;
        }

        if (p >= realBuffer + maxBufferLen)
        {
            str.Append(realBuffer, p - realBuffer);
            p = realBuffer;
        }

        MoveToNextChar();

        if (level == 0)
            break;
    }

    if (p > realBuffer)
        str.Append(realBuffer, p - realBuffer);
    TRACE(_T("ReadParentheses(): %s, line=%d"), str.wx_str(), m_LineNumber);
    if (str.Len() > 512)
        TRACE(_T("ReadParentheses: Catch Exception 2?: %d"), str.Len());
}
Пример #30
0
void wxPropertyValue::WritePropertyType(wxString& stream)    // Write as any other subexpression
{
  wxString tmp;
  switch (m_type)
  {
    case wxPropertyValueInteger:
    {
      tmp.Printf( wxT("%ld"), m_value.integer );
      stream.Append( tmp );
      break;
    }
    case wxPropertyValueIntegerPtr:
    {
      tmp.Printf( wxT("%ld"), *m_value.integerPtr );
      stream.Append( tmp );
      break;
    }
    case wxPropertyValuebool:
    {
      if (m_value.integer)
        stream.Append( wxT("True") );
      else
        stream.Append( wxT("False") );
      break;
    }
    case wxPropertyValueboolPtr:
    {
      if (*m_value.integerPtr)
        stream.Append( wxT("True") );
      else
        stream.Append( wxT("False") );
      break;
    }
    case wxPropertyValueReal:
    {
      double d = m_value.real;
      tmp.Printf( wxT("%.6g"), d );
      stream.Append( tmp );
      break;
    }
    case wxPropertyValueRealPtr:
    {
      double d = *m_value.realPtr;
      tmp.Printf( wxT("%.6g"), d );
      stream.Append( tmp );
      break;
    }
    case wxPropertyValueString:
    {
      stream.Append( m_value.string );
      break;
    }
    case wxPropertyValueStringPtr:
    {
      wxFAIL_MSG( wxT("wxPropertyValue::WritePropertyType( wxPropertyValueStringPtr ) not implemented") );
      /*
      int i;
      int len = strlen(*(m_value.stringPtr));
      for (i = 0; i < len; i++)
      {
        char ch = *(m_value.stringPtr)[i];

      }
      */
      break;
    }
    case wxPropertyValueList:
    {
      if (!m_value.first)
        stream.Append( wxT("[]") );
      else
      {
        wxPropertyValue *expr = m_value.first;

        stream.Append( wxT("[") );
        while (expr)
        {
          expr->WritePropertyType(stream);
          expr = expr->m_next;
          if (expr)
        stream.Append( wxT(", ") );
        }
        stream.Append( wxT("]") );
      }
      break;
    }
   case wxPropertyValueNull: break;
  }
}