const string &kw = st.args[1].get<const string &>();
const string &args = st.args[2].get<const string &>();
- for(string::const_iterator i=args.begin(); i!=args.end(); ++i)
- for(unsigned j=0; valid_signatures[j]!=*i; ++j)
+ for(char c: args)
+ for(unsigned j=0; valid_signatures[j]!=c; ++j)
if(!valid_signatures[j])
throw bad_definition("__kwd");
int id = get_item(dict, StatementKey(st.keyword, st.get_signature()));
write_int(id);
- for(Statement::Arguments::const_iterator j = st.args.begin(); j!=st.args.end(); ++j)
- switch(j->get_signature())
+ for(const Value &a: st.args)
+ switch(a.get_signature())
{
- case IntType::signature: write_int (j->get<IntType::Store>()); break;
- case StringType::signature: write_string(j->get<StringType::Store>()); break;
- case BoolType::signature: write_int (j->get<BoolType::Store>()); break;
- case FloatType::signature: write_float (j->get<FloatType::Store>()); break;
- case SymbolType::signature: write_symbol(j->get<SymbolType::Store>()); break;
+ case IntType::signature: write_int (a.get<IntType::Store>()); break;
+ case StringType::signature: write_string(a.get<StringType::Store>()); break;
+ case BoolType::signature: write_int (a.get<BoolType::Store>()); break;
+ case FloatType::signature: write_float (a.get<FloatType::Store>()); break;
+ case SymbolType::signature: write_symbol(a.get<SymbolType::Store>()); break;
}
write_int(st.sub.size());
- for(list<Statement>::const_iterator j = st.sub.begin(); j!=st.sub.end(); ++j)
- write(*j);
+ for(const Statement &s: st.sub)
+ write(s);
}
void BinaryWriter::collect_keywords(const Statement &st)
dict[key] = next_kwd_id++;
}
- for(vector<Value>::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
+ for(const Value &a: st.args)
{
- char sig = i->get_signature();
+ char sig = a.get_signature();
string str;
if(sig==SymbolType::signature)
- str = i->get<Symbol>().name;
+ str = a.get<Symbol>().name;
else if(sig==StringType::signature)
{
- str = i->get<string>();
+ str = a.get<string>();
if(str.size()>32)
continue;
}
strings[str] = next_str_id++;
}
- for(list<Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
- collect_keywords(*i);
+ for(const Statement &s: st.sub)
+ collect_keywords(s);
}
void BinaryWriter::write_int(IntType::Store n)
CollectionSource::NameList BuiltinSource::get_names(const CollectionItemTypeBase &type) const
{
NameList names;
- for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
- if(type.match_name(i->first))
- names.push_back(i->first);
+ for(const auto &kvp: objects)
+ if(type.match_name(kvp.first))
+ names.push_back(kvp.first);
return names;
}
void BuiltinSource::load(Collection &coll, const CollectionItemTypeBase &type, const string &name) const
{
- ObjectMap::const_iterator i = objects.find(name);
+ auto i = objects.find(name);
if(i!=objects.end())
{
IO::Memory in(i->second.data, i->second.size);
IO::Seekable *BuiltinSource::open(const string &name) const
{
- ObjectMap::const_iterator i = objects.find(name);
+ auto i = objects.find(name);
if(i!=objects.end())
return new IO::Memory(i->second.data, i->second.size);
Object(const char *, unsigned);
};
- typedef std::map<std::string, Object> ObjectMap;
-
- ObjectMap objects;
+ std::map<std::string, Object> objects;
public:
void add_object(const std::string &, const char *, unsigned);
#include <set>
+#include <msp/core/algorithm.h>
#include "collection.h"
using namespace std;
Collection::~Collection()
{
- for(TypeList::iterator i = types.begin(); i!=types.end(); ++i)
- delete *i;
+ for(CollectionItemTypeBase *t: types)
+ delete t;
}
void Collection::add_var(const string &name, const CollectionItemTypeBase *type, const Variant &var)
type->create_item(*this, name);
loaded = items.count(name);
}
- for(SourceList::iterator j=sources.begin(); (!loaded && j!=sources.end()); ++j)
+ for(auto j=sources.begin(); (!loaded && j!=sources.end()); ++j)
{
(*j)->load(*this, *type, name);
loaded = items.count(name);
void Collection::gather_items(vector<const Variant *> *vars, list<string> *names, const CollectionItemTypeBase &type, bool include_sources) const
{
- for(ItemMap::const_iterator i=items.begin(); i!=items.end(); ++i)
- if(type.check_item_type(i->second))
+ for(const auto &kvp: items)
+ if(type.check_item_type(kvp.second))
{
if(vars)
- vars->push_back(&i->second);
+ vars->push_back(&kvp.second);
if(names)
- names->push_back(i->first);
+ names->push_back(kvp.first);
}
if(include_sources && names)
ItemMap::const_iterator i = items.find(name);
if(i==items.end())
{
- for(SourceList::const_iterator j=sources.begin(); j!=sources.end(); ++j)
- if((*j)->is_loadable(type, name))
- return 2;
+ auto j = find_if(sources, [&name, &type](const CollectionSource *s){ return s->is_loadable(type, name); });
+ if(j!=sources.end())
+ return 2;
if(fallback)
if(CollectionItemTypeBase *fb_type = fallback->get_type(type))
return fallback->get_status(name, *fb_type);
CollectionItemTypeBase *Collection::get_type(const CollectionItemTypeBase &type) const
{
- for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j)
- if((*j)->is_same_type(type))
- return *j;
+ for(CollectionItemTypeBase *t: types)
+ if(t->is_same_type(type))
+ return t;
return 0;
}
CollectionItemTypeBase *Collection::get_type_for_item(const Variant &var) const
{
- for(TypeList::const_iterator i=types.begin(); i!=types.end(); ++i)
- if((*i)->check_item_type(var))
- return *i;
+ for(CollectionItemTypeBase *t: types)
+ if(t->check_item_type(var))
+ return t;
return 0;
}
IO::Seekable *Collection::open_raw(const string &name) const
{
- for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
- if(IO::Seekable *io = (*i)->open(name))
+ for(const CollectionSource *s: sources)
+ if(IO::Seekable *io = s->open(name))
return io;
return 0;
void Collection::gather_names_from_sources(list<string> &names, const CollectionItemTypeBase &type) const
{
set<string> new_names;
- for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
- {
- std::list<std::string> available_names = (*i)->get_names(type);
- for(std::list<std::string>::iterator j=available_names.begin(); j!=available_names.end(); ++j)
- if(!items.count(*j))
- new_names.insert(*j);
- }
+ for(const CollectionSource *s: sources)
+ for(const string &n: s->get_names(type))
+ if(!items.count(n))
+ new_names.insert(n);
names.insert(names.end(), new_names.begin(), new_names.end());
}
void Collection::load_items_from_sources(const CollectionItemTypeBase &type)
{
- for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i)
- {
- std::list<std::string> available_names = (*i)->get_names(type);
- for(std::list<std::string>::iterator j=available_names.begin(); j!=available_names.end(); ++j)
- if(!items.count(*j))
+ for(const CollectionSource *s: sources)
+ for(const string &n: s->get_names(type))
+ if(!items.count(n))
{
bool loaded = false;
if(type.can_create())
{
- type.create_item(*this, *j);
- loaded = items.count(*j);
+ type.create_item(*this, n);
+ loaded = items.count(n);
}
if(!loaded)
- (*i)->load(*this, type, *j);
+ s->load(*this, type, n);
}
- }
}
void Collection::set_fallback(Collection *f)
Collection::Loader::Loader(Collection &c):
coll(c)
{
- for(TypeList::const_iterator i = coll.types.begin(); i!=coll.types.end(); ++i)
- (*i)->add_to_loader(*this);
+ for(const CollectionItemTypeBase *t: coll.types)
+ t->add_to_loader(*this);
}
CollectionItemTypeBase::~CollectionItemTypeBase()
{
- for(vector<ExtractorBase *>::iterator i=extractors.begin(); i!=extractors.end(); ++i)
- delete *i;
+ for(ExtractorBase *e: extractors)
+ delete e;
}
void CollectionItemTypeBase::set_keyword(const string &k)
bool CollectionItemTypeBase::match_name(const string &name) const
{
- for(vector<string>::const_iterator i=suffixes.begin(); i!=suffixes.end(); ++i)
- if(name.size()>i->size() && !name.compare(name.size()-i->size(), string::npos, *i))
+ for(const string &s: suffixes)
+ if(name.size()>s.size() && !name.compare(name.size()-s.size(), string::npos, s))
return true;
return false;
}
private:
typedef std::map<std::string, Variant> ItemMap;
- typedef std::vector<CollectionItemTypeBase *> TypeList;
- typedef std::vector<const CollectionSource *> SourceList;
- TypeList types;
+ std::vector<CollectionItemTypeBase *> types;
ItemMap items;
- SourceList sources;
+ std::vector<const CollectionSource *> sources;
Collection *fallback;
public:
std::list<T *> extract_list(const std::vector<const Variant *> &vars) const
{
std::list<T *> result;
- for(std::vector<const Variant *>::const_iterator i=vars.begin(); i!=vars.end(); ++i)
- result.push_back(&extract<T>(**i));
+ for(const Variant *v: vars)
+ result.push_back(&extract<T>(*v));
return result;
}
{
typedef RefPtr<typename std::remove_cv<T>::type> RPNCT;
- for(ItemMap::const_iterator i=items.begin(); i!=items.end(); ++i)
- if(i->second.check_type<RPNCT>())
- if(i->second.value<RPNCT>().get()==d)
- return i->first;
+ for(const auto &kvp: items)
+ if(kvp.second.check_type<RPNCT>())
+ if(kvp.second.value<RPNCT>().get()==d)
+ return kvp.first;
// XXX Need better exception class
throw std::runtime_error("Item not found in collection");
template<typename T>
bool can_extract() const
{
- for(std::vector<ExtractorBase *>::const_iterator i=extractors.begin(); i!=extractors.end(); ++i)
- if(dynamic_cast<Extractor<T> *>(*i))
+ for(ExtractorBase *e: extractors)
+ if(dynamic_cast<Extractor<T> *>(e))
return true;
return false;
}
template<typename T>
T *extract(const Variant &var) const
{
- for(std::vector<ExtractorBase *>::const_iterator i=extractors.begin(); i!=extractors.end(); ++i)
- if(Extractor<T> *ex = dynamic_cast<Extractor<T> *>(*i))
+ for(ExtractorBase *e: extractors)
+ if(Extractor<T> *ex = dynamic_cast<Extractor<T> *>(e))
return &ex->extract(var);
return 0;
}
~CollectionItemType()
{
delete creat;
- for(typename std::vector<NotifyeeBase *>::const_iterator i=notif.begin(); i!=notif.end(); ++i)
- delete *i;
+ for(NotifyeeBase *n: notif)
+ delete n;
}
/** Sets a datafile keyword for this item type. The Collection's loader
virtual void notify_item(Collection &coll, const std::string &name, const Variant &var) const
{
RefPtr<T> obj = var.value<RefPtr<T> >();
- for(typename std::vector<NotifyeeBase *>::const_iterator i=notif.begin(); i!=notif.end(); ++i)
- (*i)->notify(coll, name, *obj);
+ for(NotifyeeBase *n: notif)
+ n->notify(coll, name, *obj);
}
};
template<typename T>
typename CollectionItemTypeChooser<T>::Type &Collection::modify_type()
{
- for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j)
- if(CollectionItemType<T> *t = dynamic_cast<CollectionItemType<T> *>(*j))
- return *t;
+ for(CollectionItemTypeBase *t: types)
+ if(CollectionItemType<T> *tt = dynamic_cast<CollectionItemType<T> *>(t))
+ return *tt;
throw std::logic_error("type not found in collection");
}
template<typename T>
CollectionItemTypeBase *Collection::get_type(const std::string &name) const
{
- for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j)
- if(dynamic_cast<CollectionItemType<T> *>(*j))
- return *j;
+ for(CollectionItemTypeBase *t: types)
+ if(dynamic_cast<CollectionItemType<T> *>(t))
+ return t;
CollectionItemTypeBase *type = 0;
- for(TypeList::const_iterator j=types.begin(); j!=types.end(); ++j)
- if((*j)->can_extract<T>())
+ for(CollectionItemTypeBase *t: types)
+ if(t->can_extract<T>())
{
- if(!name.empty() && (*j)->match_name(name))
- return *j;
- type = *j;
+ if(!name.empty() && t->match_name(name))
+ return t;
+ type = t;
}
return type;
}
void DirectorySource::add_directory(const FS::Path &d, bool replace)
{
- list<string> files = FS::list_files(d);
- for(list<string>::const_iterator i=files.begin(); i!=files.end(); ++i)
- {
- if(!objects.count(*i) || replace)
- objects[*i] = d / *i;
- }
+ for(const string &f: FS::list_files(d))
+ if(!objects.count(f) || replace)
+ objects[f] = d/f;
}
bool DirectorySource::is_loadable(const CollectionItemTypeBase &, const string &name) const
CollectionSource::NameList DirectorySource::get_names(const CollectionItemTypeBase &type) const
{
NameList names;
- for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
- if(type.match_name(i->first))
- names.push_back(i->first);
+ for(const auto &kvp: objects)
+ if(type.match_name(kvp.first))
+ names.push_back(kvp.first);
return names;
}
StringCodec::Utf8::Encoder enc;
bool escape = false;
- for(string::const_iterator i=str.begin(); i!=str.end(); )
+ for(auto i=str.begin(); i!=str.end(); )
{
StringCodec::unichar c = dec.decode_char(str, i);
else if(act_sig.size()==2 && act_sig[1]=='*')
{
int match = 3;
- for(string::const_iterator i=st_sig.begin(); (i!=st_sig.end() && match); ++i)
+ for(auto i=st_sig.begin(); (i!=st_sig.end() && match); ++i)
match = min(match, signature_match(*i, act_sig[0]));
return match;
if(!actions)
throw logic_error("no actions");
- for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
- load_statement(*i);
+ for(const Statement &s: st.sub)
+ load_statement(s);
finish();
}
if(!aux_loaders.empty() && !has_action(key))
{
- for(vector<Loader *>::const_iterator i=aux_loaders.begin(); i!=aux_loaders.end(); ++i)
- if((*i)->has_action(key))
- return (*i)->load_statement(st);
+ for(Loader *l: aux_loaders)
+ if(l->has_action(key))
+ return l->load_statement(st);
}
LoaderAction *act = find_action(key);
if(!actions)
return false;
- ActionMap::const_iterator i = actions->lower_bound(StatementKey(key.keyword, string()));
+ auto i = actions->lower_bound(StatementKey(key.keyword, string()));
for(; (i!=actions->end() && i->first.keyword==key.keyword); ++i)
if(signature_match(key.signature, i->first.signature))
return true;
if(!actions)
return 0;
- ActionMap::const_iterator begin = actions->lower_bound(StatementKey(key.keyword, string()));
- ActionMap::const_iterator end = actions->upper_bound(StatementKey(key.keyword, "~"));
+ auto begin = actions->lower_bound(StatementKey(key.keyword, string()));
+ auto end = actions->upper_bound(StatementKey(key.keyword, "~"));
if(begin==end)
throw unknown_keyword(key.keyword);
LoaderAction *act = 0;
int match = 0;
- for(ActionMap::const_iterator i=begin; i!=end; ++i)
+ for(auto i=begin; i!=end; ++i)
{
int m = signature_match(key.signature, i->first.signature);
if(m>match)
Loader::ActionMap::~ActionMap()
{
- for(iterator i=begin(); i!=end(); ++i)
- delete i->second;
+ for(const auto &kvp: *this)
+ delete kvp.second;
}
} // namespace DataFile
{
std::vector<A0> values;
values.reserve(st.args.size());
- for(Statement::Arguments::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
- values.push_back(i->get<A0>());
+ for(const Value &a: st.args)
+ values.push_back(a.get<A0>());
(dynamic_cast<L &>(l).*func)(values);
}
+#include <msp/core/algorithm.h>
#include <msp/io/slice.h>
#include <msp/strings/format.h>
#include <msp/strings/regex.h>
void PackSource::add_pack(IO::Seekable *io, const string &fn, const string &filter)
{
- Pack *pack = 0;
- for(list<Pack>::iterator i=packs.begin(); (!pack && i!=packs.end()); ++i)
- if(i->get_filename()==fn || (io && i->get_io()==io))
- pack = &*i;
- if(!pack)
+ auto i = find_if(packs, [io, &fn](const Pack &p){ return p.get_filename()==fn || (io && p.get_io()==io); });
+ if(i==packs.end())
{
packs.push_back(Pack(io, fn));
- pack = &packs.back();
+ i = prev(packs.end());
if(io)
{
DataFile::Parser parser(*io, fn);
- Pack::Loader loader(*pack);
+ Pack::Loader loader(*i);
loader.load(parser);
}
else
- DataFile::load(*pack, fn);
+ DataFile::load(*i, fn);
}
FileMap pack_files;
- pack->collect_files(pack_files, filter);
- for(FileMap::const_iterator i=pack_files.begin(); i!=pack_files.end(); ++i)
+ i->collect_files(pack_files, filter);
+ for(const auto &kvp: pack_files)
{
- files[i->first] = i->second;
- i->second->collect_objects(objects);
+ files[kvp.first] = kvp.second;
+ kvp.second->collect_objects(objects);
}
}
list<PackSource::FileInfo> PackSource::list_files() const
{
list<FileInfo> result;
- for(FileMap::const_iterator i=files.begin(); i!=files.end(); ++i)
- result.push_back(i->second->get_info());
+ for(const auto &kvp: files)
+ result.push_back(kvp.second->get_info());
return result;
}
bool PackSource::is_loadable(const CollectionItemTypeBase &type, const string &name) const
{
- ObjectMap::const_iterator i = objects.find(name);
+ auto i = objects.find(name);
if(i==objects.end())
return false;
CollectionSource::NameList PackSource::get_names(const CollectionItemTypeBase &type) const
{
NameList names;
- for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
+ for(const auto &kvp: objects)
{
- if(!i->second->get_keyword().empty())
+ if(!kvp.second->get_keyword().empty())
{
- if(i->second->get_keyword()!=type.get_keyword())
+ if(kvp.second->get_keyword()!=type.get_keyword())
continue;
}
- else if(!type.match_name(i->first))
+ else if(!type.match_name(kvp.first))
continue;
- names.push_back(i->first);
+ names.push_back(kvp.first);
}
return names;
void PackSource::load(Collection &coll, const CollectionItemTypeBase &type, const string &name) const
{
- ObjectMap::const_iterator i = objects.find(name);
+ auto i = objects.find(name);
if(i==objects.end())
return;
IO::Seekable *PackSource::open(const string &fn) const
{
- FileMap::const_iterator i = files.find(fn);
+ auto i = files.find(fn);
if(i!=files.end())
return i->second->open().release();
io(other.io),
base_offset(other.base_offset)
{
- for(list<File>::const_iterator i=other.files.begin(); i!=other.files.end(); ++i)
- files.push_back(File(*i, *this));
+ for(const File &f: other.files)
+ files.push_back(File(f, *this));
}
void PackSource::Pack::collect_files(FileMap &fm, const string &filter) const
{
if(filter.empty())
{
- for(list<File>::const_iterator i=files.begin(); i!=files.end(); ++i)
- fm[i->get_filename()] = &*i;
+ for(const File &f: files)
+ fm[f.get_filename()] = &f;
}
else
{
Regex re(filter);
- for(list<File>::const_iterator i=files.begin(); i!=files.end(); ++i)
- if(re.match(i->get_filename()))
- fm[i->get_filename()] = &*i;
+ for(const File &f: files)
+ if(re.match(f.get_filename()))
+ fm[f.get_filename()] = &f;
}
}
void PackSource::Pack::translate_files(FileMap &fm, const Pack &source) const
{
- for(list<File>::const_iterator i=files.begin(), j=source.files.begin(); (i!=files.end() && j!=source.files.end()); ++i, ++j)
+ for(auto i=files.begin(), j=source.files.begin(); (i!=files.end() && j!=source.files.end()); ++i, ++j)
{
- FileMap::iterator k = fm.find(i->get_filename());
+ auto k = fm.find(i->get_filename());
if(k!=fm.end() && k->second==&*j)
k->second = &*i;
}
length(other.length),
collection(other.collection)
{
- for(list<Object>::const_iterator i=other.objects.begin(); i!=other.objects.end(); ++i)
- objects.push_back(Object(*i, *this));
+ for(const Object &o: other.objects)
+ objects.push_back(Object(o, *this));
}
RefPtr<IO::Seekable> PackSource::File::open() const
void PackSource::File::collect_objects(ObjectMap &objs) const
{
- for(list<Object>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
- objs[i->get_name()] = &*i;
+ for(const Object &o: objects)
+ objs[o.get_name()] = &o;
}
void PackSource::File::translate_objects(ObjectMap &objs, const File &source) const
{
- for(list<Object>::const_iterator i=objects.begin(), j=source.objects.begin(); (i!=objects.end() && j!=source.objects.end()); ++i, ++j)
+ for(auto i=objects.begin(), j=source.objects.begin(); (i!=objects.end() && j!=source.objects.end()); ++i, ++j)
{
- ObjectMap::iterator k = objs.find(i->get_name());
+ auto k = objs.find(i->get_name());
if(k!=objs.end() && k->second==&*j)
k->second = &*i;
}
string Statement::get_signature() const
{
string result;
- for(Arguments::const_iterator i=args.begin(); i!=args.end(); ++i)
- result += i->get_signature();
+ for(const Value &a: args)
+ result += a.get_signature();
return result;
}
key(k, s),
args_size(0)
{
- for(string::const_iterator i=key.signature.begin(); i!=key.signature.end(); ++i)
+ for(char c: key.signature)
{
arg_offsets.push_back(args_size);
- switch(*i)
+ switch(c)
{
case IntType::signature:
args_size += sizeof(IntType::Store);
bin.reserve(data.size()*3/4);
unsigned accum = 0;
unsigned a_bits = 0;
- for(string::const_iterator i=data.begin(); i!=data.end(); ++i)
+ for(char c: data)
{
unsigned d;
- if(*i>='A' && *i<='Z')
- d = *i-'A';
- else if(*i>='a' && *i<='z')
- d = 26+(*i-'a');
- else if(*i>='0' && *i<='9')
- d = 52+(*i-'0');
- else if(*i=='+')
+ if(c>='A' && c<='Z')
+ d = c-'A';
+ else if(c>='a' && c<='z')
+ d = 26+(c-'a');
+ else if(c>='0' && c<='9')
+ d = 52+(c-'0');
+ else if(c=='+')
d = 62;
- else if(*i=='/')
+ else if(c=='/')
d = 63;
- else if(*i=='=')
+ else if(c=='=')
continue;
else
throw invalid_argument("TextParser::base64_decode");
string indent(level, '\t');
out.write(format("%s%s", indent, st.keyword));
- for(vector<Value>::const_iterator i = st.args.begin(); i!=st.args.end(); ++i)
+ for(const Value &v: st.args)
{
out.put(' ');
- if(i->get_signature()==StringType::signature)
- out.write(format("\"%s\"", c_escape(i->get<StringType::Store>(), false)));
- else if(i->get_signature()==BoolType::signature)
- out.write(i->get<BoolType::Store>() ? "true" : "false");
- else if(i->get_signature()==IntType::signature)
- out.write(lexical_cast<string>(i->get<IntType::Store>()));
- else if(i->get_signature()==FloatType::signature)
- out.write(lexical_cast<string>(i->get<FloatType::Store>(), float_format));
- else if(i->get_signature()==SymbolType::signature)
+ if(v.get_signature()==StringType::signature)
+ out.write(format("\"%s\"", c_escape(v.get<StringType::Store>(), false)));
+ else if(v.get_signature()==BoolType::signature)
+ out.write(v.get<BoolType::Store>() ? "true" : "false");
+ else if(v.get_signature()==IntType::signature)
+ out.write(lexical_cast<string>(v.get<IntType::Store>()));
+ else if(v.get_signature()==FloatType::signature)
+ out.write(lexical_cast<string>(v.get<FloatType::Store>(), float_format));
+ else if(v.get_signature()==SymbolType::signature)
{
- string name = i->get<SymbolType::Store>().name;
+ string name = v.get<SymbolType::Store>().name;
if(isdigit(name[0]))
out.write("\\"+name);
else
if(!st.sub.empty())
{
out.write(format("\n%s{\n", indent));
- for(list<Statement>::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i)
- write_(*i, level+1);
+ for(const Statement &s: st.sub)
+ write_(s, level+1);
out.write(format("%s}", indent));
}
out.write(";\n");
void ForEach::finish()
{
- list<string> files = FS::list_files(base);
- for(list<string>::iterator i = files.begin(); i!=files.end(); ++i)
+ for(const string &f: FS::list_files(base))
{
bool match = false;
for(list<string>::const_iterator j = patterns.begin(); (j!=patterns.end() && !match); ++j)
- match = Regex(*j).match(*i);
+ match = Regex(*j).match(f);
for(list<string>::const_iterator j = excludes.begin(); (j!=excludes.end() && match); ++j)
- match = !Regex(*j).match(*i);
+ match = !Regex(*j).match(f);
if(match)
- compiler.process_file(base / *i, write_st);
+ compiler.process_file(base/f, write_st);
}
}