Towards fixing AU preset invalidation
[ardour.git] / libs / pbd / enumwriter.cc
index 243cd1c6ab1ca1f67521d45d8cff1a2c9c88f631..7b3aba9053bafc4b956b7b4194cec809b4e97915 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
     Copyright (C) 2006 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
 using namespace std;
 using namespace PBD;
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 EnumWriter* EnumWriter::_instance = 0;
 map<string,string> EnumWriter::hack_table;
 
-static int 
-nocase_cmp(const string & s1, const string& s2) 
+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())) { 
+
+       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; 
+                       return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
                }
 
                ++it1;
@@ -65,11 +65,11 @@ nocase_cmp(const string & s1, const string& s2)
 }
 
 EnumWriter&
-EnumWriter::instance() 
+EnumWriter::instance()
 {
        if (_instance == 0) {
                _instance = new EnumWriter;
-       } 
+       }
 
        return *_instance;
 }
@@ -97,7 +97,7 @@ EnumWriter::register_distinct (string type, vector<int> v, vector<string> s)
 
        newpair.first = type;
        newpair.second = EnumRegistration (v, s, false);
-       
+
        result = registry.insert (newpair);
 
        if (!result.second) {
@@ -113,7 +113,7 @@ EnumWriter::register_bits (string type, vector<int> v, vector<string> s)
 
        newpair.first = type;
        newpair.second = EnumRegistration (v, s, true);
-       
+
        result = registry.insert (newpair);
 
        if (!result.second) {
@@ -153,7 +153,7 @@ EnumWriter::read (string type, string value)
        } else {
                return read_distinct (x->second, value);
        }
-}      
+}
 
 string
 EnumWriter::write_bits (EnumRegistration& er, int value)
@@ -166,7 +166,7 @@ EnumWriter::write_bits (EnumRegistration& er, int value)
                if (value & (*i)) {
                        if (!result.empty()) {
                                result += ',';
-                       } 
+                       }
                        result += (*s);
                }
        }
@@ -204,22 +204,22 @@ EnumWriter::validate (EnumRegistration& er, int val) const
 
         vector<int>::iterator i;
         string enum_name = _("unknown enumeration");
-        
+
         for (Registry::const_iterator x = registry.begin(); x != registry.end(); ++x) {
                 if (&er == &(*x).second) {
                         enum_name = (*x).first;
                 }
         }
-        
+
 
         for (i = er.values.begin(); i != er.values.end(); ++i) {
                 if (*i == val) {
                         return val;
                 }
         }
-        
+
         warning << string_compose (_("Illegal value loaded for %1 (%2) - %3 used instead"),
-                                   enum_name, val, er.names.front()) 
+                                   enum_name, val, er.names.front())
                 << endmsg;
         return er.values.front();
 }
@@ -263,7 +263,7 @@ EnumWriter::read_bits (EnumRegistration& er, string str)
         }
 
        do {
-               
+
                comma = str.find_first_of (',');
                string segment = str.substr (0, comma);