char* StringData::ReallocateStr(char* Addr_, Subscript Bytes_) { if (Addr_ && Addr_ != &_DummyData) return ResizeString(Addr_, (Bytes_ + 1), STD_NEW); return (new char[Bytes_ + 1]); }
//sets the description of the event, fails if it cannot set the name, //and returns false bool CHotKey::SetDescription(const char* pszDescription) { if(pszDescription) { if(ResizeString(strlen(pszDescription) + 1, &m_pszDescription)) { strcpy(m_pszDescription, pszDescription); return true; } return false; } return true; }
//sets the name of the event, fails if it cannot set the name, //and returns false bool CHotKey::SetEventName(const char* pszEventName) { if(pszEventName) { if(ResizeString(strlen(pszEventName) + 1, &m_pszEventName)) { strcpy(m_pszEventName, pszEventName); return true; } return false; } return true; }
bool CHotKey::Load(istream& InFile, const char* pszName) #endif { ResetEvents(); uint32 nCurrChar; if(ResizeString(strlen(pszName) + 1, &m_pszEventName) == false) { return false; } strcpy(m_pszEventName, pszName); //read in the description uint32 nDescriptionLen; InFile >> nDescriptionLen; //skip past the newline InFile.get(); if(ResizeString(nDescriptionLen + 1, &m_pszDescription) == false) { return false; } //read in the specified number of characters for(nCurrChar = 0; nCurrChar < nDescriptionLen; nCurrChar++) { m_pszDescription[nCurrChar] = InFile.get(); } m_pszDescription[nDescriptionLen] = '\0'; //read in if it is user changable uint32 nChangable; InFile >> nChangable; SetUserChangable((nChangable) ? true : false); //lists that we need to load CUIEventList* pLists[] = {&m_StartEventList, &m_EndEventList}; for(uint32 nCurrList = 0; nCurrList < sizeof(pLists) / sizeof(pLists[0]); nCurrList++) { //get the number of keys uint32 nNumEvents; InFile >> nNumEvents; //read in all the keys for(uint32 nCurrEvent = 0; nCurrEvent < nNumEvents; nCurrEvent++) { uint32 nType; uint32 nCode; //read in the type and code InFile >> nType >> nCode; //create the event CUIEvent* pEvent = CreateEvent(nType, nCode); //add it to the list if it is valid if(pEvent) { pLists[nCurrList]->Add(pEvent); } } } return true; }