summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-01-02 17:36:38 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-01-02 17:36:38 +0000
commit8fabcf4f760e68e10573efc0ef1da9d6d8453885 (patch)
treee7362b6dbb266b639c5e4855bd9eadf522d58911
parentb529cbc5dc0b92f01ff01d5f40786ff025fbb63b (diff)
finish use of EnumWriter for saving flags etc. throughout the session file
git-svn-id: svn://localhost/ardour2/trunk@1259 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/ardour.bindings3
-rw-r--r--libs/ardour/ardour/diskstream.h6
-rw-r--r--libs/ardour/ardour/location.h4
-rw-r--r--libs/ardour/ardour/redirect.h2
-rw-r--r--libs/ardour/ardour/route.h2
-rw-r--r--libs/ardour/ardour/route_group.h2
-rw-r--r--libs/ardour/ardour/utils.h1
-rw-r--r--libs/ardour/audio_diskstream.cc10
-rw-r--r--libs/ardour/audio_track.cc57
-rw-r--r--libs/ardour/audiofilesource.cc9
-rw-r--r--libs/ardour/audioregion.cc2
-rw-r--r--libs/ardour/enums.cc8
-rw-r--r--libs/ardour/location.cc12
-rw-r--r--libs/ardour/panner.cc8
-rw-r--r--libs/ardour/redirect.cc30
-rw-r--r--libs/ardour/region.cc2
-rw-r--r--libs/ardour/route.cc8
-rw-r--r--libs/ardour/route_group.cc23
-rw-r--r--libs/ardour/utils.cc12
-rw-r--r--libs/pbd/enumwriter.cc71
-rw-r--r--libs/pbd/pbd/enumwriter.h3
21 files changed, 160 insertions, 115 deletions
diff --git a/gtk2_ardour/ardour.bindings b/gtk2_ardour/ardour.bindings
index 86f50e139f..bf5df40e9e 100644
--- a/gtk2_ardour/ardour.bindings
+++ b/gtk2_ardour/ardour.bindings
@@ -121,6 +121,7 @@
; (gtk_accel_path "<Actions>/Editor/EditSelectRegionOptions" "")
(gtk_accel_path "<Actions>/Editor/crop" "c")
; (gtk_accel_path "<Actions>/redirectmenu/newsend" "")
+; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurfaceSubMenu" "")
; (gtk_accel_path "<Actions>/Editor/MeterFalloff" "")
; (gtk_accel_path "<Actions>/RegionList/rlRemove" "")
(gtk_accel_path "<Actions>/Transport/GotoStart" "Home")
@@ -276,6 +277,7 @@
; (gtk_accel_path "<Actions>/Editor/Subframes80" "")
; (gtk_accel_path "<Actions>/options/FileHeaderFormatCAF" "")
(gtk_accel_path "<Actions>/Common/ToggleLocations" "<Alt>l")
+; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurface" "")
(gtk_accel_path "<Actions>/Editor/editor-delete" "Delete")
; (gtk_accel_path "<Actions>/JACK/JACKLatency256" "")
(gtk_accel_path "<Actions>/Editor/select-all-between-cursors" "u")
@@ -298,6 +300,7 @@
; (gtk_accel_path "<Actions>/Snap/snap-to-region-sync" "")
(gtk_accel_path "<Actions>/Editor/edit-cursor-to-previous-region-sync" "apostrophe")
; (gtk_accel_path "<Actions>/redirectmenu/clear" "")
+; (gtk_accel_path "<Actions>/Editor/ToggleGeneric MIDISurfaceFeedback" "")
; (gtk_accel_path "<Actions>/Editor/PullupPlus4Minus1" "")
; (gtk_accel_path "<Actions>/JACK/JACKLatency512" "")
(gtk_accel_path "<Actions>/Editor/edit-cursor-to-next-region-end" "<Control>bracketright")
diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h
index 3f30cd9f0e..c56c411a82 100644
--- a/libs/ardour/ardour/diskstream.h
+++ b/libs/ardour/ardour/diskstream.h
@@ -76,8 +76,8 @@ class IO;
virtual float playback_buffer_load() const = 0;
virtual float capture_buffer_load() const = 0;
- void set_flag (Flag f) { _flags |= f; }
- void unset_flag (Flag f) { _flags &= ~f; }
+ void set_flag (Flag f) { _flags = Flag (_flags | f); }
+ void unset_flag (Flag f) { _flags = Flag (_flags & ~f); }
AlignStyle alignment_style() const { return _alignment_style; }
void set_align_style (AlignStyle);
@@ -303,7 +303,7 @@ class IO;
sigc::connection plmod_connection;
sigc::connection plgone_connection;
- unsigned char _flags;
+ Flag _flags;
};
}; /* namespace ARDOUR */
diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h
index 94f70bb4e8..b0a7d11ef2 100644
--- a/libs/ardour/ardour/location.h
+++ b/libs/ardour/ardour/location.h
@@ -68,7 +68,7 @@ class Location : public PBD::StatefulDestructible
Location () {
_start = 0;
_end = 0;
- _flags = 0;
+ _flags = Flags (0);
}
Location (const Location& other);
@@ -124,7 +124,7 @@ class Location : public PBD::StatefulDestructible
string _name;
nframes_t _start;
nframes_t _end;
- uint32_t _flags;
+ Flags _flags;
void set_mark (bool yn);
bool set_flag_internal (bool yn, Flags flag);
diff --git a/libs/ardour/ardour/redirect.h b/libs/ardour/ardour/redirect.h
index 847b9b8c13..83b389d72a 100644
--- a/libs/ardour/ardour/redirect.h
+++ b/libs/ardour/ardour/redirect.h
@@ -111,8 +111,6 @@ class Redirect : public IO
virtual void transport_stopped (nframes_t frame) {};
protected:
- void set_placement (const string&, void *src);
-
/* children may use this stuff as they see fit */
map<uint32_t,AutomationList*> parameter_automation;
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 12ef57858b..2067c31b9c 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -250,7 +250,7 @@ class Route : public IO
void curve_reallocate ();
protected:
- unsigned char _flags;
+ Flag _flags;
/* tight cache-line access here is more important than sheer speed of
access.
diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h
index e9fad1aa2b..d87d3fa3a4 100644
--- a/libs/ardour/ardour/route_group.h
+++ b/libs/ardour/ardour/route_group.h
@@ -115,7 +115,7 @@ class RouteGroup : public Stateful, public sigc::trackable {
Session& _session;
list<Route *> routes;
string _name;
- uint32_t _flags;
+ Flag _flags;
void remove_when_going_away (Route*);
};
diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h
index 0167036667..2babfd6bd7 100644
--- a/libs/ardour/ardour/utils.h
+++ b/libs/ardour/ardour/utils.h
@@ -37,7 +37,6 @@ void elapsed_time_to_str (char *buf, uint32_t seconds);
Glib::ustring legalize_for_path (Glib::ustring str);
std::ostream& operator<< (std::ostream& o, const ARDOUR::BBT_Time& bbt);
XMLNode* find_named_node (const XMLNode& node, std::string name);
-std::string placement_as_string (ARDOUR::Placement);
static inline float f_max(float x, float a) {
x -= a;
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index 4ff810df1d..66b34956fe 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -35,6 +35,7 @@
#include <glibmm/thread.h>
#include <pbd/xml++.h>
#include <pbd/memento_command.h>
+#include <pbd/enumwriter.h>
#include <ardour/ardour.h>
#include <ardour/audioengine.h>
@@ -1760,8 +1761,7 @@ AudioDiskstream::get_state ()
char buf[64] = "";
LocaleGuard lg (X_("POSIX"));
- snprintf (buf, sizeof(buf), "0x%x", _flags);
- node->add_property ("flags", buf);
+ node->add_property ("flags", enum_2_string (_flags));
snprintf (buf, sizeof(buf), "%zd", channels.size());
node->add_property ("channels", buf);
@@ -1848,7 +1848,7 @@ AudioDiskstream::set_state (const XMLNode& node)
}
if ((prop = node.property ("flags")) != 0) {
- _flags = strtol (prop->value().c_str(), 0, 0);
+ _flags = Flag (string_2_enum (prop->value(), _flags));
}
if ((prop = node.property ("channels")) != 0) {
@@ -2258,10 +2258,10 @@ AudioDiskstream::set_destructive (bool yn)
if (!can_become_destructive (bounce_ignored)) {
return -1;
}
- _flags |= Destructive;
+ _flags = Flag (_flags | Destructive);
use_destructive_playlist ();
} else {
- _flags &= ~Destructive;
+ _flags = Flag (_flags & ~Destructive);
reset_write_sources (true, true);
}
}
diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc
index 33bb478a1c..e7b1368fa4 100644
--- a/libs/ardour/audio_track.cc
+++ b/libs/ardour/audio_track.cc
@@ -17,11 +17,14 @@
$Id$
*/
-#include <pbd/error.h>
+
#include <sigc++/retype.h>
#include <sigc++/retype_return.h>
#include <sigc++/bind.h>
+#include <pbd/error.h>
+#include <pbd/enumwriter.h>
+
#include <ardour/audio_track.h>
#include <ardour/audio_diskstream.h>
#include <ardour/session.h>
@@ -236,14 +239,7 @@ AudioTrack::_set_state (const XMLNode& node, bool call_base)
}
if ((prop = node.property (X_("mode"))) != 0) {
- if (prop->value() == X_("normal")) {
- _mode = Normal;
- } else if (prop->value() == X_("destructive")) {
- _mode = Destructive;
- } else {
- warning << string_compose ("unknown audio track mode \"%1\" seen and ignored", prop->value()) << endmsg;
- _mode = Normal;
- }
+ _mode = TrackMode (string_2_enum (prop->value(), _mode));
} else {
_mode = Normal;
}
@@ -312,8 +308,7 @@ AudioTrack::state(bool full_state)
freeze_node = new XMLNode (X_("freeze-info"));
freeze_node->add_property ("playlist", _freeze_record.playlist->name());
- snprintf (buf, sizeof (buf), "%d", (int) _freeze_record.state);
- freeze_node->add_property ("state", buf);
+ freeze_node->add_property ("state", enum_2_string (_freeze_record.state));
for (vector<FreezeRecordInsertInfo*>::iterator i = _freeze_record.insert_info.begin(); i != _freeze_record.insert_info.end(); ++i) {
inode = new XMLNode (X_("insert"));
@@ -330,15 +325,8 @@ AudioTrack::state(bool full_state)
/* Alignment: act as a proxy for the diskstream */
XMLNode* align_node = new XMLNode (X_("alignment"));
- switch (_diskstream->alignment_style()) {
- case ExistingMaterial:
- snprintf (buf, sizeof (buf), X_("existing"));
- break;
- case CaptureTime:
- snprintf (buf, sizeof (buf), X_("capture"));
- break;
- }
- align_node->add_property (X_("style"), buf);
+ AlignStyle as = _diskstream->alignment_style ();
+ align_node->add_property (X_("style"), enum_2_string (as));
root.add_child_nocopy (*align_node);
XMLNode* remote_control_node = new XMLNode (X_("remote_control"));
@@ -346,14 +334,7 @@ AudioTrack::state(bool full_state)
remote_control_node->add_property (X_("id"), buf);
root.add_child_nocopy (*remote_control_node);
- switch (_mode) {
- case Normal:
- root.add_property (X_("mode"), X_("normal"));
- break;
- case Destructive:
- root.add_property (X_("mode"), X_("destructive"));
- break;
- }
+ root.add_property (X_("mode"), enum_2_string (_mode));
/* we don't return diskstream state because we don't
own the diskstream exclusively. control of the diskstream
@@ -407,7 +388,7 @@ AudioTrack::set_state_part_two ()
}
if ((prop = fnode->property (X_("state"))) != 0) {
- _freeze_record.state = (FreezeState) atoi (prop->value().c_str());
+ _freeze_record.state = FreezeState (string_2_enum (prop->value(), _freeze_record.state));
}
XMLNodeConstIterator citer;
@@ -434,11 +415,21 @@ AudioTrack::set_state_part_two ()
if ((fnode = find_named_node (*pending_state, X_("alignment"))) != 0) {
if ((prop = fnode->property (X_("style"))) != 0) {
- if (prop->value() == "existing") {
- _diskstream->set_persistent_align_style (ExistingMaterial);
- } else if (prop->value() == "capture") {
- _diskstream->set_persistent_align_style (CaptureTime);
+
+ /* fix for older sessions from before EnumWriter */
+
+ string pstr;
+
+ if (prop->value() == "capture") {
+ pstr = "CaptureTime";
+ } else if (prop->value() == "existing") {
+ pstr = "ExistingMaterial";
+ } else {
+ pstr = prop->value();
}
+
+ AlignStyle as = AlignStyle (string_2_enum (pstr, as));
+ _diskstream->set_persistent_align_style (as);
}
}
return;
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index 92db950cc0..53809c3c2f 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -29,6 +29,7 @@
#include <pbd/pathscanner.h>
#include <pbd/stl_delete.h>
#include <pbd/strsplit.h>
+#include <pbd/enumwriter.h>
#include <sndfile.h>
@@ -194,9 +195,7 @@ XMLNode&
AudioFileSource::get_state ()
{
XMLNode& root (AudioSource::get_state());
- char buf[16];
- snprintf (buf, sizeof (buf), "0x%x", (int)_flags);
- root.add_property ("flags", buf);
+ root.add_property ("flags", enum_2_string (_flags));
return root;
}
@@ -211,9 +210,7 @@ AudioFileSource::set_state (const XMLNode& node)
if ((prop = node.property (X_("flags"))) != 0) {
- int ival;
- sscanf (prop->value().c_str(), "0x%x", &ival);
- _flags = Flag (ival);
+ _flags = Flag (string_2_enum (prop->value(), _flags));
} else {
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 7d3c1fc549..1fc7703cfa 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -602,8 +602,6 @@ AudioRegion::state (bool full)
char buf2[64];
LocaleGuard lg (X_("POSIX"));
- // snprintf (buf, sizeof (buf), "0x%x", (int) _flags);
- // node.add_property ("flags", buf);
node.add_property ("flags", enum_2_string (_flags));
snprintf (buf, sizeof(buf), "%.12g", _scale_amplitude);
diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc
index 32f195e2ac..0460df43d8 100644
--- a/libs/ardour/enums.cc
+++ b/libs/ardour/enums.cc
@@ -8,6 +8,7 @@
#include <ardour/audioregion.h>
#include <ardour/route_group.h>
#include <ardour/panner.h>
+#include <ardour/track.h>
using namespace std;
using namespace PBD;
@@ -20,7 +21,6 @@ setup_enum_writer ()
vector<int> i;
vector<string> s;
-
OverlapType _OverlapType;
AlignStyle _AlignStyle;
MeterPoint _MeterPoint;
@@ -59,6 +59,7 @@ setup_enum_writer ()
Location::Flags _Location_Flags;
RouteGroup::Flag _RouteGroup_Flag;
Region::Flag _Region_Flag;
+ Track::FreezeState _Track_FreezeState;
#define REGISTER(e) enum_writer->register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_BITS(e) enum_writer->register_bits (typeid(e).name(), i, s); i.clear(); s.clear()
@@ -317,5 +318,10 @@ setup_enum_writer ()
REGISTER_CLASS_ENUM (Region, Hidden);
REGISTER_CLASS_ENUM (Region, DoNotSaveState);
REGISTER_BITS (_Region_Flag);
+
+ REGISTER_CLASS_ENUM (Track, NoFreeze);
+ REGISTER_CLASS_ENUM (Track, Frozen);
+ REGISTER_CLASS_ENUM (Track, UnFrozen);
+ REGISTER (_Track_FreezeState);
}
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index e09a59d42f..5a75c2bc16 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -28,6 +28,7 @@
#include <pbd/stl_delete.h>
#include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
#include <ardour/location.h>
#include <ardour/session.h>
@@ -217,12 +218,12 @@ Location::set_flag_internal (bool yn, Flags flag)
{
if (yn) {
if (!(_flags & flag)) {
- _flags |= flag;
+ _flags = Flags (_flags | flag);
return true;
}
} else {
if (_flags & flag) {
- _flags &= ~flag;
+ _flags = Flags (_flags & ~flag);
return true;
}
}
@@ -273,8 +274,7 @@ Location::get_state (void)
node->add_property ("start", buf);
snprintf (buf, sizeof (buf), "%u", end());
node->add_property ("end", buf);
- snprintf (buf, sizeof (buf), "%" PRIu32, (uint32_t) _flags);
- node->add_property ("flags", buf);
+ node->add_property ("flags", enum_2_string (_flags));
return *node;
}
@@ -327,14 +327,12 @@ Location::set_state (const XMLNode& node)
_end = atoi (prop->value().c_str());
- _flags = 0;
-
if ((prop = node.property ("flags")) == 0) {
error << _("XML node for Location has no flags information") << endmsg;
return -1;
}
- _flags = Flags (atoi (prop->value().c_str()));
+ _flags = Flags (string_2_enum (prop->value(), _flags));
for (cd_iter = cd_list.begin(); cd_iter != cd_list.end(); ++cd_iter) {
diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc
index faf2f14fb3..97646d99cd 100644
--- a/libs/ardour/panner.cc
+++ b/libs/ardour/panner.cc
@@ -33,6 +33,7 @@
#include <pbd/error.h>
#include <pbd/failed_constructor.h>
#include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
#include <ardour/session.h>
#include <ardour/panner.h>
@@ -1055,8 +1056,7 @@ Panner::state (bool full)
char buf[32];
root->add_property (X_("linked"), (_linked ? "yes" : "no"));
- snprintf (buf, sizeof (buf), "%d", _link_direction);
- root->add_property (X_("link_direction"), buf);
+ root->add_property (X_("link_direction"), enum_2_string (_link_direction));
root->add_property (X_("bypassed"), (bypassed() ? "yes" : "no"));
/* add each output */
@@ -1100,8 +1100,8 @@ Panner::set_state (const XMLNode& node)
}
if ((prop = node.property (X_("link_direction"))) != 0) {
- sscanf (prop->value().c_str(), "%d", &i);
- set_link_direction ((LinkDirection) (i));
+ LinkDirection ld; /* here to provide type information */
+ set_link_direction (LinkDirection (string_2_enum (prop->value(), ld)));
}
nlist = node.children();
diff --git a/libs/ardour/redirect.cc b/libs/ardour/redirect.cc
index ba81252511..a5f6031f30 100644
--- a/libs/ardour/redirect.cc
+++ b/libs/ardour/redirect.cc
@@ -28,6 +28,7 @@
#include <sigc++/bind.h>
#include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
#include <ardour/redirect.h>
#include <ardour/session.h>
@@ -97,18 +98,6 @@ Redirect::set_placement (Placement p, void *src)
}
}
-void
-Redirect::set_placement (const string& str, void *src)
-{
- if (str == _("pre")) {
- set_placement (PreFader, this);
- } else if (str == _("post")) {
- set_placement (PostFader, this);
- } else {
- error << string_compose(_("Redirect: unknown placement string \"%1\" (ignored)"), str) << endmsg;
- }
-}
-
/* NODE STRUCTURE
<Automation [optionally with visible="...." ]>
@@ -195,7 +184,7 @@ Redirect::state (bool full_state)
stringstream sstr;
node->add_property("active", active() ? "yes" : "no");
- node->add_property("placement", placement_as_string (placement()));
+ node->add_property("placement", enum_2_string (_placement));
node->add_child_nocopy (IO::state (full_state));
if (_extra_xml){
@@ -295,7 +284,20 @@ Redirect::set_state (const XMLNode& node)
return -1;
}
- set_placement (prop->value(), this);
+ /* hack to handle older sessions before we only used EnumWriter */
+
+ string pstr;
+
+ if (prop->value() == "pre") {
+ pstr = "PreFader";
+ } else if (prop->value() == "post") {
+ pstr = "PostFader";
+ } else {
+ pstr = prop->value();
+ }
+
+ Placement p = Placement (string_2_enum (pstr, p));
+ set_placement (p, this);
return 0;
}
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 9d81cc5907..3e10df9dba 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -768,7 +768,7 @@ Region::state (bool full_state)
snprintf (buf, sizeof (buf), "%d", (int) _layer);
node->add_property ("layer", buf);
- snprintf (buf, sizeof (buf), "%u", _sync_position);
+ snprintf (buf, sizeof (buf), "%" PRIu32, _sync_position);
node->add_property ("sync-position", buf);
return *node;
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 38cd7ad37d..f32757c169 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -24,6 +24,7 @@
#include <sigc++/bind.h>
#include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
#include <ardour/timestamps.h>
#include <ardour/buffer.h>
@@ -1372,8 +1373,7 @@ Route::state(bool full_state)
char buf[32];
if (_flags) {
- snprintf (buf, sizeof (buf), "0x%x", _flags);
- node->add_property("flags", buf);
+ node->add_property("flags", enum_2_string (_flags));
}
node->add_property("default-type", _default_type.to_string());
@@ -1533,9 +1533,7 @@ Route::_set_state (const XMLNode& node, bool call_base)
}
if ((prop = node.property (X_("flags"))) != 0) {
- int x;
- sscanf (prop->value().c_str(), "0x%x", &x);
- _flags = Flag (x);
+ _flags = Flag (string_2_enum (prop->value(), _flags));
} else {
_flags = Flag (0);
}
diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc
index 5730623742..c2aa59ed8b 100644
--- a/libs/ardour/route_group.cc
+++ b/libs/ardour/route_group.cc
@@ -26,6 +26,7 @@
#include <sigc++/bind.h>
#include <pbd/error.h>
+#include <pbd/enumwriter.h>
#include <ardour/route_group.h>
#include <ardour/audio_track.h>
@@ -125,11 +126,9 @@ RouteGroup::get_max_factor(gain_t factor)
XMLNode&
RouteGroup::get_state (void)
{
- char buf[32];
XMLNode *node = new XMLNode ("RouteGroup");
node->add_property ("name", _name);
- snprintf (buf, sizeof (buf), "%" PRIu32, (uint32_t) _flags);
- node->add_property ("flags", buf);
+ node->add_property ("flags", enum_2_string (_flags));
return *node;
}
@@ -143,7 +142,7 @@ RouteGroup::set_state (const XMLNode& node)
}
if ((prop = node.property ("flags")) != 0) {
- _flags = atoi (prop->value().c_str());
+ _flags = Flag (string_2_enum (prop->value(), _flags));
}
return 0;
@@ -157,9 +156,9 @@ RouteGroup::set_active (bool yn, void *src)
return;
}
if (yn) {
- _flags |= Active;
+ _flags = Flag (_flags | Active);
} else {
- _flags &= ~Active;
+ _flags = Flag (_flags & ~Active);
}
_session.set_dirty ();
FlagsChanged (src); /* EMIT SIGNAL */
@@ -173,9 +172,9 @@ RouteGroup::set_relative (bool yn, void *src)
return;
}
if (yn) {
- _flags |= Relative;
+ _flags = Flag (_flags | Relative);
} else {
- _flags &= ~Relative;
+ _flags = Flag (_flags & ~Relative);
}
_session.set_dirty ();
FlagsChanged (src); /* EMIT SIGNAL */
@@ -189,14 +188,14 @@ RouteGroup::set_hidden (bool yn, void *src)
return;
}
if (yn) {
- _flags |= Hidden;
+ _flags = Flag (_flags | Hidden);
if (Config->get_hiding_groups_deactivates_groups()) {
- _flags &= ~Active;
+ _flags = Flag (_flags & ~Active);
}
} else {
- _flags &= ~Hidden;
+ _flags = Flag (_flags & ~Hidden);
if (Config->get_hiding_groups_deactivates_groups()) {
- _flags |= Active;
+ _flags = Flag (_flags | Active);
}
}
_session.set_dirty ();
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index fbea468682..ec5cb4e757 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -208,18 +208,6 @@ touch_file (ustring path)
return 1;
}
-string
-placement_as_string (Placement p)
-{
- switch (p) {
- case PreFader:
- return _("pre");
- default: /* to get g++ to realize we have all the cases covered */
- case PostFader:
- return _("post");
- }
-}
-
ustring
region_name_from_path (ustring path, bool strip_channels)
{
diff --git a/libs/pbd/enumwriter.cc b/libs/pbd/enumwriter.cc
index d6c882e00a..7674410ec9 100644
--- a/libs/pbd/enumwriter.cc
+++ b/libs/pbd/enumwriter.cc
@@ -18,6 +18,9 @@
$Id$
*/
+#include <ctype.h>
+
+#include <string.h>
#include <stdlib.h>
#include <pbd/enumwriter.h>
@@ -30,6 +33,35 @@ using namespace PBD;
#include "i18n.h"
EnumWriter* EnumWriter::_instance = 0;
+map<string,string> EnumWriter::hack_table;
+
+static int
+nocase_cmp(const string & s1, const string& s2)
+{
+ string::const_iterator it1 = s1.begin();
+ string::const_iterator it2 = s2.begin();
+
+ while ((it1 != s1.end()) && (it2 != s2.end())) {
+ if(::toupper(*it1) != ::toupper(*it2)) {//letters differ?
+ // return -1 to indicate 'smaller than', 1 otherwise
+ return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
+ }
+
+ ++it1;
+ ++it2;
+ }
+
+ string::size_type size1 = s1.size();
+ string::size_type size2 = s2.size();
+
+ //return -1,0 or 1 according to strings' lengths
+
+ if (size1 == size2) {
+ return 0;
+ }
+
+ return (size1 < size2) ? -1 : 1;
+}
EnumWriter::EnumWriter ()
{
@@ -157,13 +189,19 @@ EnumWriter::read_bits (EnumRegistration& er, string str)
return strtol (str.c_str(), (char **) 0, 16);
}
+ /* catch old style dec numerics */
+
+ if (strspn (str.c_str(), "0123456789") == str.length()) {
+ return strtol (str.c_str(), (char **) 0, 10);
+ }
+
do {
comma = str.find_first_of (',');
string segment = str.substr (0, comma);
for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) {
- if (segment == (*s)) {
+ if (segment == *s || nocase_cmp (segment, *s) == 0) {
result |= (*i);
found = true;
}
@@ -196,13 +234,40 @@ EnumWriter::read_distinct (EnumRegistration& er, string str)
return strtol (str.c_str(), (char **) 0, 16);
}
+ /* catch old style dec numerics */
+
+ if (strspn (str.c_str(), "0123456789") == str.length()) {
+ return strtol (str.c_str(), (char **) 0, 10);
+ }
+
for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) {
- if (str == (*s)) {
+ if (str == (*s) || nocase_cmp (str, *s) == 0) {
return (*i);
}
}
+ /* failed to find it as-is. check to see if there a hack for the name we're looking up */
+
+ map<string,string>::iterator x;
+
+ if ((x = hack_table.find (str)) != hack_table.end()) {
+
+ cerr << "found hack for " << str << " = " << x->second << endl;
+
+ str = x->second;
+
+ for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) {
+ if (str == (*s) || nocase_cmp (str, *s) == 0) {
+ return (*i);
+ }
+ }
+ }
+
throw unknown_enumeration();
}
-
+void
+EnumWriter::add_to_hack_table (string str, string hacked)
+{
+ hack_table[str] = hacked;
+}
diff --git a/libs/pbd/pbd/enumwriter.h b/libs/pbd/pbd/enumwriter.h
index 356a0a1acc..f53388f3cc 100644
--- a/libs/pbd/pbd/enumwriter.h
+++ b/libs/pbd/pbd/enumwriter.h
@@ -44,6 +44,8 @@ class EnumWriter {
std::string write (std::string type, int value);
int read (std::string type, std::string value);
+ void add_to_hack_table (std::string str, std::string hacked_str);
+
private:
struct EnumRegistration {
std::vector<int> values;
@@ -65,6 +67,7 @@ class EnumWriter {
int read_distinct (EnumRegistration&, std::string value);
static EnumWriter* _instance;
+ static std::map<std::string,std::string> hack_table;
};
}