From: <man...@us...> - 2013-05-21 21:18:41
|
Revision: 2164 http://sourceforge.net/p/modplug/code/2164 Author: manxorist Date: 2013-05-21 21:18:34 +0000 (Tue, 21 May 2013) Log Message: ----------- [Ref] Use std::string for GetTitle() and SetTitle() in CSoundFile. Modified Paths: -------------- trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/mod2midi.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -37,7 +37,7 @@ //------------------------------------------------------------------------- { const CString &path = (!fullPath || pModDoc->GetPathName().IsEmpty()) ? pModDoc->GetTitle() : pModDoc->GetPathName(); - return pModDoc->GetrSoundFile().GetTitle() + CString(" (") + path + CString(")"); + return CString(pModDoc->GetrSoundFile().GetTitle().c_str()) + CString(" (") + path + CString(")"); } Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -325,7 +325,7 @@ CString title; m_EditTitle.GetWindowText(title); - if(m_sndFile.SetTitle(title, title.GetLength())) + if(m_sndFile.SetTitle(title.GetString())) { m_EditTitle.SetModify(FALSE); m_modDoc.SetModified(); Modified: trunk/OpenMPT/mptrack/mod2midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/mod2midi.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/mptrack/mod2midi.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -394,13 +394,13 @@ f.Write(&mthd, sizeof(mthd)); // Add Song Name on track 0 - const CHAR *modTitle = m_pSndFile->GetTitle(); + const std::string modTitle = m_pSndFile->GetTitle(); if (modTitle[0]) { tmp[0] = 0; tmp[1] = 0xff; tmp[2] = 0x01; Tracks[0].Write(tmp, 3); - Tracks[0].WriteLen(strlen(modTitle)); - Tracks[0].Write(modTitle, strlen(modTitle)); + Tracks[0].WriteLen(modTitle.length()); + Tracks[0].Write(modTitle.c_str(), modTitle.length()); } // Add Song comments on track 0 Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-21 21:18:34 UTC (rev 2164) @@ -1663,12 +1663,12 @@ } -bool CSoundFile::SetTitle(const char *titleCandidate, size_t strSize) -//------------------------------------------------------------------- +bool CSoundFile::SetTitle(const std::string & newTitle) +//----------------------------------------------------- { - if(strcmp(m_szNames[0], titleCandidate)) + if(m_szNames[0] != newTitle) { - StringFixer::CopyN(m_szNames[0], titleCandidate, strSize); + StringFixer::CopyN(m_szNames[0], &newTitle[0], newTitle.length()); return true; } return false; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-21 20:20:37 UTC (rev 2163) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-21 21:18:34 UTC (rev 2164) @@ -192,9 +192,6 @@ class CSoundFile //============== { -public: - //Return true if title was changed. - bool SetTitle(const char*, size_t strSize); public: //Misc void ChangeModTypeTo(const MODTYPE& newType); @@ -464,7 +461,8 @@ void DontLoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0); //rewbs.playSongFromCursor void SetCurrentPos(UINT nPos); void SetCurrentOrder(ORDERINDEX nOrder); - LPCSTR GetTitle() const { return m_szNames[0]; } + std::string GetTitle() const { return m_szNames[0]; } + bool SetTitle(const std::string &newTitle); // Return true if title was changed. LPCTSTR GetSampleName(UINT nSample) const; const char *GetInstrumentName(INSTRUMENTINDEX nInstr) const; UINT GetMusicSpeed() const { return m_nMusicSpeed; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |