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


C++ String::AfterLast方法代码示例

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


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

示例1: Rename

bool MFolderFromProfile::Rename(const String& newName)
{
   CHECK( !m_folderName.empty(), false, _T("can't rename the root pseudo-folder") );

   String path = m_folderName.BeforeLast(_T('/')),
          name = m_folderName.AfterLast(_T('/'));

   String newFullName = path;
   if ( !path.empty() )
      newFullName += _T('/');
   newFullName += newName;

   // we can't use Exists() here as it tries to read a value from the config
   // group newFullName and, as a side effect of this, creates this group, so
   // Profile::Rename() below will then fail!
#if 0
   if ( Exists(newFullName) )
   {
      wxLogError(_("Cannot rename folder '%s' to '%s': the folder with "
                   "the new name already exists."),
                   m_folderName.c_str(), newName.c_str());

      return false;
   }
#endif // 0

   Profile_obj profile(path);
   CHECK( profile, false, _T("panic in MFolder: no profile") );
   if ( !profile->Rename(name, newName) )
   {
      wxLogError(_("Cannot rename folder '%s' to '%s': the folder with "
                   "the new name already exists."),
                   m_folderName.c_str(), newName.c_str());

      return false;
   }

   String oldName = m_folderName;
   m_folderName = newFullName;

   // TODO: MFolderCache should just subscribe to "Rename" events...
   MFolderCache::RenameAll(oldName, newFullName);

   // notify everybody about the change of the folder name
   MEventManager::Send(
     new MEventFolderTreeChangeData(oldName,
                                    MEventFolderTreeChangeData::Rename,
                                    newFullName)
     );

   return true;
}
开发者ID:mark711,项目名称:mahogany,代码行数:52,代码来源:MFolder.cpp

示例2: GetName

String MFolderFromProfile::GetName() const
{
   return m_folderName.AfterLast(_T('/'));
}
开发者ID:mark711,项目名称:mahogany,代码行数:4,代码来源:MFolder.cpp

示例3: Move

bool MFolderFromProfile::Move(MFolder *newParent)
{
   CHECK( newParent, false, _T("no new parent in MFolder::Move()") );

   // This does not really 'move' the folder, but it creates a new one with the
   // correct parent and name, and copies all the profile information from the
   // old one to the new one. It then calls Delete on itself, so that the old
   // folder is removed from the tree. Last thing is to notify everyone that a
   // new folder has been created.

   // There are things that do not make sense at all
   CHECK( GetFolderType(GetType()) != MF_ILLEGAL, false,
            _T("How did you manage to try to move an MF_ILLEGAL folder ?") );
   CHECK( GetFolderType(GetType()) != MF_NEWS, false,
            _T("can't move News folders") );
   CHECK( GetFolderType(GetType()) != MF_INBOX, false,
            _T("can't move system Inbox") );
   CHECK( GetFolderType(GetType()) != MF_ROOT, false,
            _T("can't move the root pseudo-folder") );

   // And there are things we can't do yet.
   CHECK( GetSubfolderCount() == 0, false, _T("can't move a folder with sub-folders (yet)") );
   CHECK( GetFolderType(GetType()) != MF_IMAP, false, _T("can't move IMAP folders (yet)") );

   if ( GetFolderType(GetType()) == MF_IMAP )
   {
      // IMAP folders have one more check: we must make sure that they stay on
      // the same server, so that we can simply send it a RENAME command.
      CHECK( false, false, _T("Same server check not yet implemented") );
   }
   
   // Compute the name of the folder to create
   String path = newParent->GetFullName();
   String name = m_folderName.AfterLast('/');
   String newFullName = path;
   if ( !path.empty() )
      newFullName += _T('/');
   newFullName += name;

   // Create a new folder
   MFolder_obj newSubfolder(newParent->CreateSubfolder(name, MF_ILLEGAL));
   if ( !newSubfolder )
   {
      wxLogError(_("Could not create subfolder '%s' in '%s'."),
                   name.c_str(), path.c_str());
      return false;
   }

   wxString oldProfilePath, newProfilePath;
   oldProfilePath << Profile::GetProfilePath() << '/' << m_folderName;
   newProfilePath << Profile::GetProfilePath() << '/' << newFullName;
   if ( CopyEntries(mApplication->GetProfile()->GetConfig(), oldProfilePath, newProfilePath, false) == -1 )
   {
      wxLogError(_("Could not copy profile."));
      return false;
   }

   if ( GetFolderType(GetType()) == MF_IMAP )
   {
      // IMAP folders need one last specific thing: send a RENAME
      // command to the server, unless we are moving the root folder
      // for this server (in this case, nothing changes on the server
      // and no RENAME command should be issued).
      CHECK( false, false, _T("RENAME command to server not yet implemented") );
   }

   // We should update the cache, but I (XNO) did not find a way to do it correctly.
   //MFolderCache::Remove(this);
   //MFolderCache::Add(newSubfolder);
   
   // Iterate over all the filters to change the name of the folder where
   // it appears.
   wxArrayString allFilterNames = MFilter::GetAllFilters();
   for ( size_t i = 0; i < allFilterNames.GetCount(); ++i )
   {
      wxString filterName = allFilterNames[i];
      MFilter *filter = MFilter::CreateFromProfile(filterName);
      MFilterDesc filterDesc = filter->GetDesc();
      if ( filterDesc.IsSimple() )
      {
         MFDialogSettings *dialogSettings = filterDesc.GetSettings();
         wxString argument = dialogSettings->GetActionArgument();
         size_t nbReplacements = argument.Replace(m_folderName, newFullName);
         if ( nbReplacements > 0 )
         {
            dialogSettings->SetAction(dialogSettings->GetAction(), argument);
            filterDesc.Set(dialogSettings);
            filter->Set(filterDesc);
            wxLogStatus(_("Filter '%s' has been updated."), filterName.c_str());
         }
         else
         {
            dialogSettings->DecRef();
         }
      }
      else
      {
         // XNOTODO: Find out how to update this filter anyway
         wxLogError(_("Filter '%s' is not \"simple\" and has not been updated."), filterName.c_str());
      }
//.........这里部分代码省略.........
开发者ID:mark711,项目名称:mahogany,代码行数:101,代码来源:MFolder.cpp


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