changed duration_from_string() calls to TimeConversion::parseTimeDuration()
This commit is contained in:
parent
aba0318f3c
commit
1769fe5b48
9 changed files with 49 additions and 46 deletions
|
@ -7,4 +7,4 @@
|
|||
<!ATTLIST fadeInfo fadeOut NMTOKEN #REQUIRED >
|
||||
]>
|
||||
<fadeInfo id="0000000000009901" fadeIn="00:00:02.000000"
|
||||
fadeOut="00:00:01.500"/>
|
||||
fadeOut="00:00:01.0005"/>
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.28 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.29 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/AudioClip.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -130,8 +130,8 @@ using namespace boost::posix_time;
|
|||
* <!ATTLIST audioClip uri CDATA #IMPLIED >
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.28 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.29 $
|
||||
*/
|
||||
class AudioClip : public Configurable,
|
||||
public Playable
|
||||
|
@ -207,7 +207,7 @@ class AudioClip : public Configurable,
|
|||
* a valid ISO-8601 time
|
||||
*/
|
||||
void
|
||||
setPlaylength(const std::string & timeString)
|
||||
setPlaylength(Ptr<const std::string>::Ref timeString)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.40 $
|
||||
Version : $Revision: 1.41 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -128,7 +128,7 @@ using namespace boost::posix_time;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.40 $
|
||||
* @version $Revision: 1.41 $
|
||||
*/
|
||||
class Playlist : public Configurable,
|
||||
public Playable
|
||||
|
@ -218,7 +218,7 @@ class Playlist : public Configurable,
|
|||
* a valid ISO-8601 time
|
||||
*/
|
||||
void
|
||||
setPlaylength(const std::string & timeString)
|
||||
setPlaylength(Ptr<const std::string>::Ref timeString)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/TimeConversion.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -71,7 +71,7 @@ using namespace LiveSupport;
|
|||
* A helper object holding static time conversion functions.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
class TimeConversion
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ class TimeConversion
|
|||
* @return the duration as a time_duration
|
||||
*/
|
||||
static Ptr<time_duration>::Ref
|
||||
parseTimeDuration(Ptr<std::string>::Ref durationString)
|
||||
parseTimeDuration(Ptr<const std::string>::Ref durationString)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.30 $
|
||||
Version : $Revision: 1.31 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include <id3v1tag.h> // for TagLib
|
||||
#include <id3v2tag.h> // for TagLib
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/AudioClip.h"
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
@ -285,22 +286,15 @@ AudioClip :: setTitle(Ptr<const Glib::ustring>::Ref title)
|
|||
* Set the value of the playlength from a string (private).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
AudioClip :: setPlaylength(const std::string & timeString)
|
||||
AudioClip :: setPlaylength(Ptr<const std::string>::Ref timeString)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
try {
|
||||
playlength.reset(new time_duration(duration_from_string(timeString)));
|
||||
} catch (boost::bad_lexical_cast &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
playlength = TimeConversion::parseTimeDuration(timeString);
|
||||
} catch (std::exception &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
} catch ( ... ) {
|
||||
std::string eMsg = "bad time format in playlength";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,7 +374,10 @@ AudioClip :: configure(const xmlpp::Element & element)
|
|||
if (!playlength && prefix == extentElementPrefix
|
||||
&& name == extentElementName) {
|
||||
if (dataElement->has_child_text()) {
|
||||
setPlaylength(dataElement->get_child_text()->get_content());
|
||||
Ptr<std::string>::Ref playlengthString(new std::string(
|
||||
dataElement->get_child_text()
|
||||
->get_content() ));
|
||||
setPlaylength(playlengthString);
|
||||
} else { // or just leave blank? bad either way
|
||||
playlength.reset(new time_duration(0,0,0,0));
|
||||
}
|
||||
|
@ -496,7 +493,9 @@ AudioClip :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
throw (std::invalid_argument)
|
||||
{
|
||||
if (prefix == extentElementPrefix && name == extentElementName) {
|
||||
setPlaylength(*value); // may throw invalid_argument
|
||||
Ptr<const std::string>::Ref valueString(new const std::string(
|
||||
*value));
|
||||
setPlaylength(valueString); // may throw invalid_argument
|
||||
}
|
||||
|
||||
if (prefix == titleElementPrefix && name == titleElementName) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.6 $
|
||||
Version : $Revision: 1.7 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/FadeInfo.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/FadeInfo.h"
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
@ -99,16 +100,18 @@ FadeInfo :: configure(const xmlpp::Element & element)
|
|||
eMsg += idAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
fadeIn.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
Ptr<std::string>::Ref fadeInString(new std::string(
|
||||
attribute->get_value() ));
|
||||
fadeIn = TimeConversion::parseTimeDuration(fadeInString);
|
||||
|
||||
if (!(attribute = element.get_attribute(fadeOutAttrName))) {
|
||||
std::string eMsg = "missing attribute ";
|
||||
eMsg += idAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
fadeOut.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
Ptr<std::string>::Ref fadeOutString(new std::string(
|
||||
attribute->get_value() ));
|
||||
fadeOut = TimeConversion::parseTimeDuration(fadeOutString);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.39 $
|
||||
Version : $Revision: 1.40 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
|
||||
using namespace boost::posix_time;
|
||||
|
@ -279,22 +280,15 @@ Playlist :: setPlaylength(Ptr<time_duration>::Ref playlength)
|
|||
* Set the value of the playlength from a string (private).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist :: setPlaylength(const std::string & timeString)
|
||||
Playlist :: setPlaylength(Ptr<const std::string>::Ref timeString)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
try {
|
||||
playlength.reset(new time_duration(duration_from_string(timeString)));
|
||||
} catch (boost::bad_lexical_cast &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
playlength = TimeConversion::parseTimeDuration(timeString);
|
||||
} catch (std::exception &e) {
|
||||
std::string eMsg = "bad time format in playlength: ";
|
||||
eMsg += e.what();
|
||||
throw std::invalid_argument(eMsg);
|
||||
} catch ( ... ) {
|
||||
std::string eMsg = "bad time format in playlength";
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,7 +375,10 @@ Playlist :: configure(const xmlpp::Element & element)
|
|||
if (!playlength && prefix == extentElementPrefix
|
||||
&& name == extentElementName) {
|
||||
if (dataElement->has_child_text()) {
|
||||
setPlaylength(dataElement->get_child_text()->get_content());
|
||||
Ptr<const std::string>::Ref playlengthString(
|
||||
new std::string(dataElement->get_child_text()
|
||||
->get_content() ));
|
||||
setPlaylength(playlengthString);
|
||||
} else { // or just leave blank? bad either way
|
||||
playlength.reset(new time_duration(0,0,0,0));
|
||||
}
|
||||
|
@ -708,7 +705,9 @@ Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
|
|||
throw (std::invalid_argument)
|
||||
{
|
||||
if (prefix == extentElementPrefix && name == extentElementName) {
|
||||
setPlaylength(*value);
|
||||
Ptr<const std::string>::Ref valueString(new const std::string(
|
||||
*value));
|
||||
setPlaylength(valueString);
|
||||
}
|
||||
|
||||
if (prefix == titleElementPrefix && name == titleElementName) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.12 $
|
||||
Version : $Revision: 1.13 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistElement.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/Core/Playlist.h"
|
||||
#include "LiveSupport/Core/PlaylistElement.h"
|
||||
|
||||
|
@ -112,8 +113,9 @@ PlaylistElement :: configure(const xmlpp::Element & element)
|
|||
eMsg += relativeOffsetAttrName;
|
||||
throw std::invalid_argument(eMsg);
|
||||
}
|
||||
relativeOffset.reset(new time_duration(
|
||||
duration_from_string(attribute->get_value())));
|
||||
Ptr<std::string>::Ref relativeOffsetString(new std::string(
|
||||
attribute->get_value() ));
|
||||
relativeOffset = TimeConversion::parseTimeDuration(relativeOffsetString);
|
||||
|
||||
// set audio clip
|
||||
xmlpp::Node::NodeList childNodes
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/TimeConversion.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -218,7 +218,7 @@ TimeConversion :: timeDurationToHhMmSsString(
|
|||
* Parse a string to a time_duration.
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<time_duration>::Ref
|
||||
TimeConversion :: parseTimeDuration(Ptr<std::string>::Ref durationString)
|
||||
TimeConversion :: parseTimeDuration(Ptr<const std::string>::Ref durationString)
|
||||
throw ()
|
||||
{
|
||||
int micros = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue