/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3935 by schoenebeck, Thu Jun 17 10:09:42 2021 UTC revision 3938 by schoenebeck, Thu Jun 17 11:41:45 2021 UTC
# Line 609  namespace { Line 609  namespace {
609          uint16_t iSampleGroup = 0; // 0 refers to default sample group          uint16_t iSampleGroup = 0; // 0 refers to default sample group
610          File* pFile = static_cast<File*>(pParent);          File* pFile = static_cast<File*>(pParent);
611          if (pFile->pGroups) {          if (pFile->pGroups) {
612              std::list<Group*>::iterator iter = pFile->pGroups->begin();              std::vector<Group*>::iterator iter = pFile->pGroups->begin();
613              std::list<Group*>::iterator end  = pFile->pGroups->end();              std::vector<Group*>::iterator end  = pFile->pGroups->end();
614              for (int i = 0; iter != end; i++, iter++) {              for (int i = 0; iter != end; i++, iter++) {
615                  if (*iter == pGroup) {                  if (*iter == pGroup) {
616                      iSampleGroup = i;                      iSampleGroup = i;
# Line 6286  namespace { Line 6286  namespace {
6286    
6287      File::~File() {      File::~File() {
6288          if (pGroups) {          if (pGroups) {
6289              std::list<Group*>::iterator iter = pGroups->begin();              std::vector<Group*>::iterator iter = pGroups->begin();
6290              std::list<Group*>::iterator end  = pGroups->end();              std::vector<Group*>::iterator end  = pGroups->end();
6291              while (iter != end) {              while (iter != end) {
6292                  delete *iter;                  delete *iter;
6293                  ++iter;                  ++iter;
# Line 6937  namespace { Line 6937  namespace {
6937          return bRequiresSave;          return bRequiresSave;
6938      }      }
6939    
6940        /**
6941         * Returns a pointer to the first <i>Group</i> object of the file,
6942         * <i>NULL</i> otherwise.
6943         *
6944         * @deprecated  This method is not reentrant-safe, use GetGroup() instead.
6945         */
6946      Group* File::GetFirstGroup() {      Group* File::GetFirstGroup() {
6947          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6948          // there must always be at least one group          // there must always be at least one group
# Line 6944  namespace { Line 6950  namespace {
6950          return *GroupsIterator;          return *GroupsIterator;
6951      }      }
6952    
6953        /**
6954         * Returns a pointer to the next <i>Group</i> object of the file,
6955         * <i>NULL</i> otherwise.
6956         *
6957         * @deprecated  This method is not reentrant-safe, use GetGroup() instead.
6958         */
6959      Group* File::GetNextGroup() {      Group* File::GetNextGroup() {
6960          if (!pGroups) return NULL;          if (!pGroups) return NULL;
6961          ++GroupsIterator;          ++GroupsIterator;
# Line 6958  namespace { Line 6970  namespace {
6970       */       */
6971      Group* File::GetGroup(size_t index) {      Group* File::GetGroup(size_t index) {
6972          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6973          GroupsIterator = pGroups->begin();          if (index >= pGroups->size()) return NULL;
6974          for (size_t i = 0; GroupsIterator != pGroups->end(); i++) {          return (*pGroups)[index];
             if (i == index) return *GroupsIterator;  
             ++GroupsIterator;  
         }  
         return NULL;  
6975      }      }
6976    
6977      /**      /**
# Line 6978  namespace { Line 6986  namespace {
6986       */       */
6987      Group* File::GetGroup(String name) {      Group* File::GetGroup(String name) {
6988          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
6989          GroupsIterator = pGroups->begin();          size_t i = 0;
6990          for (uint i = 0; GroupsIterator != pGroups->end(); ++GroupsIterator, ++i)          for (Group* pGroup = GetGroup(i); pGroup; pGroup = GetGroup(++i))
6991              if ((*GroupsIterator)->Name == name) return *GroupsIterator;              if (pGroup->Name == name) return pGroup;
6992          return NULL;          return NULL;
6993      }      }
6994    
# Line 7004  namespace { Line 7012  namespace {
7012       */       */
7013      void File::DeleteGroup(Group* pGroup) {      void File::DeleteGroup(Group* pGroup) {
7014          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
7015          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);          std::vector<Group*>::iterator iter =
7016                find(pGroups->begin(), pGroups->end(), pGroup);
7017          if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");          if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");
7018          if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");          if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");
7019          // delete all members of this group          // delete all members of this group
# Line 7030  namespace { Line 7039  namespace {
7039       */       */
7040      void File::DeleteGroupOnly(Group* pGroup) {      void File::DeleteGroupOnly(Group* pGroup) {
7041          if (!pGroups) LoadGroups();          if (!pGroups) LoadGroups();
7042          std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup);          std::vector<Group*>::iterator iter =
7043                find(pGroups->begin(), pGroups->end(), pGroup);
7044          if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");          if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group");
7045          if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");          if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!");
7046          // move all members of this group to another group          // move all members of this group to another group
# Line 7041  namespace { Line 7051  namespace {
7051      }      }
7052    
7053      void File::LoadGroups() {      void File::LoadGroups() {
7054          if (!pGroups) pGroups = new std::list<Group*>;          if (!pGroups) pGroups = new std::vector<Group*>;
7055          // try to read defined groups from file          // try to read defined groups from file
7056          RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI);          RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI);
7057          if (lst3gri) {          if (lst3gri) {
# Line 7240  namespace { Line 7250  namespace {
7250                  }                  }
7251              }              }
7252    
7253              std::list<Group*>::iterator iter = pGroups->begin();              std::vector<Group*>::iterator iter = pGroups->begin();
7254              std::list<Group*>::iterator end  = pGroups->end();              std::vector<Group*>::iterator end  = pGroups->end();
7255              for (; iter != end; ++iter) {              for (; iter != end; ++iter) {
7256                  (*iter)->UpdateChunks(pProgress);                  (*iter)->UpdateChunks(pProgress);
7257              }              }

Legend:
Removed from v.3935  
changed lines
  Added in v.3938

  ViewVC Help
Powered by ViewVC