1 #include <msp/strings/format.h>
2 #include <msp/strings/regex.h>
13 Zone::Zone(Layout &l):
25 void Zone::set_name(const string &n)
27 Regex r_name("(.+) ([^ ]+) ([1-9][0-9]*)");
28 RegMatch m = r_name.match(n);
30 throw invalid_argument("Zone::set_name");
32 set_name(m[1].str, m[2].str, lexical_cast<unsigned>(m[3].str));
35 void Zone::set_name(const string &g, const string &q, unsigned n)
41 string full_name = group;
42 if(!qualifier.empty())
45 full_name += qualifier;
48 full_name += format(" %d", number);
49 TrackChain::set_name(full_name);
52 void Zone::save(list<DataFile::Statement> &st) const
54 st.push_back((DataFile::Statement("group"), group));
55 if(!qualifier.empty())
56 st.push_back((DataFile::Statement("qualifier"), qualifier));
58 st.push_back((DataFile::Statement("number"), number));
60 set<unsigned> block_ids;
61 for(TrackSet::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
62 block_ids.insert((*i)->get_block().get_id());
64 for(set<unsigned>::const_iterator i=block_ids.begin(); i!=block_ids.end(); ++i)
65 st.push_back((DataFile::Statement("block"), *i));
69 Zone::Loader::Loader(Zone &z):
70 DataFile::ObjectLoader<Zone>(z)
72 add("block", &Loader::block);
73 add("group", &Zone::group);
74 add("number", &Zone::number);
75 add("qualifier", &Zone::qualifier);
78 void Zone::Loader::block(unsigned b)
80 Block &blk = obj.layout.get_block(b);
81 const set<Track *> &btracks = blk.get_tracks();
82 obj.tracks.insert(btracks.begin(), btracks.end());