diff options
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/boost_debug.cc | 69 | ||||
-rw-r--r-- | libs/pbd/convert.cc | 40 | ||||
-rw-r--r-- | libs/pbd/fpu.cc | 49 | ||||
-rw-r--r-- | libs/pbd/pbd.cc | 2 | ||||
-rw-r--r-- | libs/pbd/pbd/compose.h | 755 | ||||
-rw-r--r-- | libs/pbd/pbd/msvc_pbd.h | 84 | ||||
-rw-r--r-- | libs/pbd/pbd/ringbuffer.h | 130 | ||||
-rw-r--r-- | libs/pbd/pbd/timersub.h | 19 | ||||
-rw-r--r-- | libs/pbd/pbd/tokenizer.h | 48 | ||||
-rw-r--r-- | libs/pbd/xml++.cc | 5 |
10 files changed, 599 insertions, 602 deletions
diff --git a/libs/pbd/boost_debug.cc b/libs/pbd/boost_debug.cc index a0b09dcbc4..8b01239256 100644 --- a/libs/pbd/boost_debug.cc +++ b/libs/pbd/boost_debug.cc @@ -37,17 +37,16 @@ class Backtrace { public: - Backtrace (); - std::ostream& print (std::ostream& str) const; + Backtrace (); + std::ostream& print (std::ostream& str) const; private: - void* trace[200]; - size_t size; + void* trace[200]; + size_t size; }; std::ostream& operator<< (std::ostream& str, const Backtrace& bt) { return bt.print (str); } - Backtrace::Backtrace() { #ifdef HAVE_EXECINFO @@ -78,12 +77,11 @@ Backtrace::print (std::ostream& str) const struct BTPair { - Backtrace* ref; - Backtrace* rel; - - BTPair (Backtrace* bt) : ref (bt), rel (0) {} - ~BTPair () { } + Backtrace* ref; + Backtrace* rel; + BTPair (Backtrace* bt) : ref (bt), rel (0) {} + ~BTPair () { } }; std::ostream& operator<<(std::ostream& str, const BTPair& btp) { @@ -95,14 +93,14 @@ std::ostream& operator<<(std::ostream& str, const BTPair& btp) { } struct SPDebug { - Backtrace* constructor; - Backtrace* destructor; - - SPDebug (Backtrace* c) : constructor (c), destructor (0) {} - ~SPDebug () { - delete constructor; - delete destructor; - } + Backtrace* constructor; + Backtrace* destructor; + + SPDebug (Backtrace* c) : constructor (c), destructor (0) {} + ~SPDebug () { + delete constructor; + delete destructor; + } }; std::ostream& operator<< (std::ostream& str, const SPDebug& spd) @@ -121,27 +119,30 @@ typedef std::map<volatile void const*,const char*> IPointerMap; using namespace std; static PointerMap* _sptrs; -PointerMap& sptrs() { - if (_sptrs == 0) { - _sptrs = new PointerMap; - } - return *_sptrs; +PointerMap& sptrs() +{ + if (_sptrs == 0) { + _sptrs = new PointerMap; + } + return *_sptrs; } static IPointerMap* _interesting_pointers; -IPointerMap& interesting_pointers() { - if (_interesting_pointers == 0) { - _interesting_pointers = new IPointerMap; - } - return *_interesting_pointers; +IPointerMap& interesting_pointers() +{ + if (_interesting_pointers == 0) { + _interesting_pointers = new IPointerMap; + } + return *_interesting_pointers; } static Glib::Threads::Mutex* _the_lock; -static Glib::Threads::Mutex& the_lock() { - if (_the_lock == 0) { - _the_lock = new Glib::Threads::Mutex; - } - return *_the_lock; +static Glib::Threads::Mutex& the_lock() +{ + if (_the_lock == 0) { + _the_lock = new Glib::Threads::Mutex; + } + return *_the_lock; } @@ -169,7 +170,7 @@ void boost_debug_shared_ptr_mark_interesting (void* ptr, const char* type) { Glib::Threads::Mutex::Lock guard (the_lock()); - pair<void*,const char*> newpair (ptr, type); + pair<void*,const char*> newpair (ptr, type); interesting_pointers().insert (newpair); if (debug_out) { cerr << "Interesting object @ " << ptr << " of type " << type << endl; diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc index 3fdb8af71d..96918b9809 100644 --- a/libs/pbd/convert.cc +++ b/libs/pbd/convert.cc @@ -46,12 +46,12 @@ namespace PBD { string capitalize (const string& str) { - string ret = str; - if (!str.empty()) { - /* XXX not unicode safe */ - ret[0] = toupper (str[0]); - } - return ret; + string ret = str; + if (!str.empty()) { + /* XXX not unicode safe */ + ret[0] = toupper (str[0]); + } + return ret; } string @@ -175,8 +175,8 @@ internationalize (const char *package_name, const char **array) static int32_t int_from_hex (char hic, char loc) { - int hi; /* hi byte */ - int lo; /* low byte */ + int hi; /* hi byte */ + int lo; /* low byte */ hi = (int) hic; @@ -224,20 +224,20 @@ url_decode (string const & url) string length2string (const int32_t samples, const float sample_rate) { - int32_t secs = (int32_t) (samples / sample_rate); - int32_t hrs = secs / 3600; - secs -= (hrs * 3600); - int32_t mins = secs / 60; - secs -= (mins * 60); - - int32_t total_secs = (hrs * 3600) + (mins * 60) + secs; - int32_t samples_remaining = (int) floor (samples - (total_secs * sample_rate)); - float fractional_secs = (float) samples_remaining / sample_rate; + int32_t secs = (int32_t) (samples / sample_rate); + int32_t hrs = secs / 3600; + secs -= (hrs * 3600); + int32_t mins = secs / 60; + secs -= (mins * 60); + + int32_t total_secs = (hrs * 3600) + (mins * 60) + secs; + int32_t samples_remaining = (int) floor (samples - (total_secs * sample_rate)); + float fractional_secs = (float) samples_remaining / sample_rate; - char duration_str[32]; - sprintf (duration_str, "%02" PRIi32 ":%02" PRIi32 ":%05.2f", hrs, mins, (float) secs + fractional_secs); + char duration_str[32]; + sprintf (duration_str, "%02" PRIi32 ":%02" PRIi32 ":%05.2f", hrs, mins, (float) secs + fractional_secs); - return duration_str; + return duration_str; } #endif diff --git a/libs/pbd/fpu.cc b/libs/pbd/fpu.cc index 78bcd3d812..c6c11b6875 100644 --- a/libs/pbd/fpu.cc +++ b/libs/pbd/fpu.cc @@ -48,25 +48,25 @@ FPU* FPU::_instance (0); static void __cpuid(int regs[4], int cpuid_leaf) { - asm volatile ( + asm volatile ( #if defined(__i386__) - "pushl %%ebx;\n\t" + "pushl %%ebx;\n\t" #endif - "cpuid;\n\t" - "movl %%eax, (%1);\n\t" - "movl %%ebx, 4(%1);\n\t" - "movl %%ecx, 8(%1);\n\t" - "movl %%edx, 12(%1);\n\t" + "cpuid;\n\t" + "movl %%eax, (%1);\n\t" + "movl %%ebx, 4(%1);\n\t" + "movl %%ecx, 8(%1);\n\t" + "movl %%edx, 12(%1);\n\t" #if defined(__i386__) - "popl %%ebx;\n\t" + "popl %%ebx;\n\t" #endif - :"=a" (cpuid_leaf) /* %eax clobbered by CPUID */ - :"S" (regs), "a" (cpuid_leaf) - : + :"=a" (cpuid_leaf) /* %eax clobbered by CPUID */ + :"S" (regs), "a" (cpuid_leaf) + : #if !defined(__i386__) - "%ebx", + "%ebx", #endif - "%ecx", "%edx", "memory"); + "%ecx", "%edx", "memory"); } #endif /* !PLATFORM_WINDOWS */ @@ -158,15 +158,16 @@ FPU::FPU () return; #else - /* Get the CPU vendor just for kicks */ - - // __cpuid with an InfoType argument of 0 returns the number of - // valid Ids in CPUInfo[0] and the CPU identification string in - // the other three array elements. The CPU identification string is - // not in linear order. The code below arranges the information - // in a human readable form. The human readable order is CPUInfo[1] | - // CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped - // before using memcpy to copy these three array elements to cpu_string. + /* Get the CPU vendor just for kicks + * + * __cpuid with an InfoType argument of 0 returns the number of + * valid Ids in CPUInfo[0] and the CPU identification string in + * the other three array elements. The CPU identification string is + * not in linear order. The code below arranges the information + * in a human readable form. The human readable order is CPUInfo[1] | + * CPUInfo[3] | CPUInfo[2]. CPUInfo[2] and CPUInfo[3] are swapped + * before using memcpy to copy these three array elements to cpu_string. + */ int cpu_info[4]; char cpu_string[48]; @@ -175,9 +176,9 @@ FPU::FPU () __cpuid (cpu_info, 0); int num_ids = cpu_info[0]; - std::swap(cpu_info[2], cpu_info[3]); + std::swap(cpu_info[2], cpu_info[3]); memcpy(cpu_string, &cpu_info[1], 3 * sizeof(cpu_info[1])); - cpu_vendor.assign(cpu_string, 3 * sizeof(cpu_info[1])); + cpu_vendor.assign(cpu_string, 3 * sizeof(cpu_info[1])); info << string_compose (_("CPU vendor: %1"), cpu_vendor) << endmsg; diff --git a/libs/pbd/pbd.cc b/libs/pbd/pbd.cc index a7a818ee5f..a43204404b 100644 --- a/libs/pbd/pbd.cc +++ b/libs/pbd/pbd.cc @@ -97,7 +97,7 @@ PBD::init () // will be created or opened in BINARY mode! _fmode = O_BINARY; - WSADATA wsaData; + WSADATA wsaData; /* Initialize windows socket DLL for PBD::CrossThreadChannel */ diff --git a/libs/pbd/pbd/compose.h b/libs/pbd/pbd/compose.h index 231afa583e..c7a225ca32 100644 --- a/libs/pbd/pbd/compose.h +++ b/libs/pbd/pbd/compose.h @@ -36,400 +36,397 @@ #include <sstream> #include <string> #include <list> -#include <map> // for multimap +#include <map> // for multimap #include "pbd/libpbd_visibility.h" namespace StringPrivate { - // the actual composition class - using string::compose is cleaner, so we - // hide it here - class LIBPBD_API Composition - { - public: - // initialize and prepare format string on the form "text %1 text %2 etc." - explicit Composition(std::string fmt); - - // supply an replacement argument starting from %1 - template <typename T> - Composition &arg(const T &obj); - - // specialization to catch strings (C++ and C) - Composition &arg(const std::string &str); - Composition &arg(char const * const cstr); - - // compose and return string - std::string str() const; - - private: - std::ostringstream os; - int arg_no; - - // we store the output as a list - when the output string is requested, the - // list is concatenated to a string; this way we can keep iterators into - // the list instead of into a string where they're possibly invalidated on - // inserting a specification string - typedef std::list<std::string> output_list; - output_list output; - - // the initial parse of the format string fills in the specification map - // with positions for each of the various %?s - typedef std::multimap<int, output_list::iterator> specification_map; - specification_map specs; - }; - - // helper for converting spec string numbers - inline int char_to_int(char c) - { - switch (c) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - default: return -1000; - } - } - - inline bool is_number(int n) - { - switch (n) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return true; - - default: - return false; - } - } - - - // implementation of class Composition - template <typename T> - inline Composition &Composition::arg(const T &obj) - { - os << obj; - - std::string rep = os.str(); - - if (!rep.empty()) { // manipulators don't produce output - for (specification_map::const_iterator i = specs.lower_bound(arg_no), - end = specs.upper_bound(arg_no); i != end; ++i) { - output_list::iterator pos = i->second; - ++pos; - - output.insert(pos, rep); - } - - os.str(std::string()); - //os.clear(); - ++arg_no; - } - - return *this; - } - - inline Composition &Composition::arg(const std::string &str) - { - /* specialization to ensure that empty strings show up - * in the output - */ - for (specification_map::const_iterator i = specs.lower_bound(arg_no), - end = specs.upper_bound(arg_no); i != end; ++i) { - output_list::iterator pos = i->second; - ++pos; - - output.insert(pos, str); - } - - ++arg_no; - - return *this; - } - - inline Composition &Composition::arg(char const * const cstr) - { - /* specialization to ensure that empty C strings show up - * in the output - */ - for (specification_map::const_iterator i = specs.lower_bound(arg_no), - end = specs.upper_bound(arg_no); i != end; ++i) { - output_list::iterator pos = i->second; - ++pos; - - output.insert(pos, std::string (cstr)); - } - - ++arg_no; - - return *this; - } - - inline Composition::Composition(std::string fmt) - : arg_no(1) - { - std::string::size_type b = 0, i = 0; - - // fill in output with the strings between the %1 %2 %3 etc. and - // fill in specs with the positions - while (i < fmt.length()) { - if (fmt[i] == '%' && i + 1 < fmt.length()) { - if (fmt[i + 1] == '%') { // catch %% - fmt.replace(i, 2, "%"); - ++i; +// the actual composition class - using string::compose is cleaner, so we +// hide it here +class LIBPBD_API Composition +{ +public: + // initialize and prepare format string on the form "text %1 text %2 etc." + explicit Composition(std::string fmt); + + // supply an replacement argument starting from %1 + template <typename T> + Composition &arg(const T &obj); + + // specialization to catch strings (C++ and C) + Composition &arg(const std::string &str); + Composition &arg(char const * const cstr); + + // compose and return string + std::string str() const; + +private: + std::ostringstream os; + int arg_no; + + // we store the output as a list - when the output string is requested, the + // list is concatenated to a string; this way we can keep iterators into + // the list instead of into a string where they're possibly invalidated on + // inserting a specification string + typedef std::list<std::string> output_list; + output_list output; + + // the initial parse of the format string fills in the specification map + // with positions for each of the various %?s + typedef std::multimap<int, output_list::iterator> specification_map; + specification_map specs; +}; + +// helper for converting spec string numbers +inline int char_to_int(char c) +{ + switch (c) { + case '0': return 0; + case '1': return 1; + case '2': return 2; + case '3': return 3; + case '4': return 4; + case '5': return 5; + case '6': return 6; + case '7': return 7; + case '8': return 8; + case '9': return 9; + default: return -1000; + } +} + +inline bool is_number(int n) +{ + switch (n) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return true; + + default: + return false; } - else if (is_number(fmt[i + 1])) { // aha! a spec! - // save string - output.push_back(fmt.substr(b, i - b)); +} + +// implementation of class Composition +template <typename T> + inline Composition &Composition::arg(const T &obj) + { + os << obj; + + std::string rep = os.str(); + + if (!rep.empty()) { // manipulators don't produce output + for (specification_map::const_iterator i = specs.lower_bound(arg_no), + end = specs.upper_bound(arg_no); i != end; ++i) { + output_list::iterator pos = i->second; + ++pos; + + output.insert(pos, rep); + } + + os.str(std::string()); + //os.clear(); + ++arg_no; + } + + return *this; + } + +inline Composition &Composition::arg(const std::string &str) +{ + /* specialization to ensure that empty strings show up + * in the output + */ + for (specification_map::const_iterator i = specs.lower_bound(arg_no), + end = specs.upper_bound(arg_no); i != end; ++i) { + output_list::iterator pos = i->second; + ++pos; + + output.insert(pos, str); + } + + ++arg_no; + + return *this; +} - int n = 1; // number of digits - int spec_no = 0; +inline Composition &Composition::arg(char const * const cstr) +{ + /* specialization to ensure that empty C strings show up + * in the output + */ + for (specification_map::const_iterator i = specs.lower_bound(arg_no), + end = specs.upper_bound(arg_no); i != end; ++i) { + output_list::iterator pos = i->second; + ++pos; + + output.insert(pos, std::string (cstr)); + } - do { - spec_no += char_to_int(fmt[i + n]); - spec_no *= 10; - ++n; - } while (i + n < fmt.length() && is_number(fmt[i + n])); + ++arg_no; - spec_no /= 10; - output_list::iterator pos = output.end(); - --pos; // safe since we have just inserted a string> + return *this; +} - specs.insert(specification_map::value_type(spec_no, pos)); +inline Composition::Composition(std::string fmt) + : arg_no(1) +{ + std::string::size_type b = 0, i = 0; + + // fill in output with the strings between the %1 %2 %3 etc. and + // fill in specs with the positions + while (i < fmt.length()) { + if (fmt[i] == '%' && i + 1 < fmt.length()) { + if (fmt[i + 1] == '%') { // catch %% + fmt.replace(i, 2, "%"); + ++i; + } + else if (is_number(fmt[i + 1])) { // aha! a spec! + // save string + output.push_back(fmt.substr(b, i - b)); + + int n = 1; // number of digits + int spec_no = 0; + + do { + spec_no += char_to_int(fmt[i + n]); + spec_no *= 10; + ++n; + } while (i + n < fmt.length() && is_number(fmt[i + n])); + + spec_no /= 10; + output_list::iterator pos = output.end(); + --pos; // safe since we have just inserted a string> + + specs.insert(specification_map::value_type(spec_no, pos)); + + // jump over spec string + i += n; + b = i; + } + else + ++i; + } + else + ++i; + } - // jump over spec string - i += n; - b = i; + if (i - b > 0) { // add the rest of the string + output.push_back(fmt.substr(b, i - b)); } - else - ++i; - } - else - ++i; - } - - if (i - b > 0) // add the rest of the string - output.push_back(fmt.substr(b, i - b)); - } - - inline std::string Composition::str() const - { - // assemble string - std::string str; - - for (output_list::const_iterator i = output.begin(), end = output.end(); - i != end; ++i) - str += *i; - - return str; - } +} + +inline std::string Composition::str() const +{ + // assemble string + std::string str; + + for (output_list::const_iterator i = output.begin(), end = output.end(); + i != end; ++i) + str += *i; + + return str; +} } // now for the real thing(s) -//namespace PBD -//{ - // a series of functions which accept a format string on the form "text %1 - // more %2 less %3" and a number of templated parameters and spits out the - // composited string - template <typename T1> - inline std::string string_compose(const std::string &fmt, const T1 &o1) - { - StringPrivate::Composition c(fmt); - c.arg(o1); - return c.str(); - } - - template <typename T1, typename T2> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2); - return c.str(); - } - - template <typename T1, typename T2, typename T3> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12, typename T13> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12, - const T13 &o13) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12).arg(o13); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12, typename T13, typename T14> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12, - const T13 &o13, const T14 &o14) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12).arg(o13).arg(o14); - return c.str(); - } - - template <typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12, typename T13, typename T14, - typename T15> - inline std::string string_compose(const std::string &fmt, - const T1 &o1, const T2 &o2, const T3 &o3, - const T4 &o4, const T5 &o5, const T6 &o6, - const T7 &o7, const T8 &o8, const T9 &o9, - const T10 &o10, const T11 &o11, const T12 &o12, - const T13 &o13, const T14 &o14, const T15 &o15) - { - StringPrivate::Composition c(fmt); - c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) - .arg(o10).arg(o11).arg(o12).arg(o13).arg(o14).arg(o15); - return c.str(); - } -//} +// a series of functions which accept a format string on the form "text %1 +// more %2 less %3" and a number of templated parameters and spits out the +// composited string +template <typename T1> +inline std::string string_compose(const std::string &fmt, const T1 &o1) +{ + StringPrivate::Composition c(fmt); + c.arg(o1); + return c.str(); +} + +template <typename T1, typename T2> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2); + return c.str(); +} + +template <typename T1, typename T2, typename T3> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9, typename T10> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9, + const T10 &o10) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) + .arg(o10); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9, + const T10 &o10, const T11 &o11) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) + .arg(o10).arg(o11); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11, typename T12> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9, + const T10 &o10, const T11 &o11, const T12 &o12) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) + .arg(o10).arg(o11).arg(o12); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11, typename T12, typename T13> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9, + const T10 &o10, const T11 &o11, const T12 &o12, + const T13 &o13) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) + .arg(o10).arg(o11).arg(o12).arg(o13); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11, typename T12, typename T13, typename T14> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9, + const T10 &o10, const T11 &o11, const T12 &o12, + const T13 &o13, const T14 &o14) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) + .arg(o10).arg(o11).arg(o12).arg(o13).arg(o14); + return c.str(); +} + +template <typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11, typename T12, typename T13, typename T14, + typename T15> +inline std::string string_compose(const std::string &fmt, + const T1 &o1, const T2 &o2, const T3 &o3, + const T4 &o4, const T5 &o5, const T6 &o6, + const T7 &o7, const T8 &o8, const T9 &o9, + const T10 &o10, const T11 &o11, const T12 &o12, + const T13 &o13, const T14 &o14, const T15 &o15) +{ + StringPrivate::Composition c(fmt); + c.arg(o1).arg(o2).arg(o3).arg(o4).arg(o5).arg(o6).arg(o7).arg(o8).arg(o9) + .arg(o10).arg(o11).arg(o12).arg(o13).arg(o14).arg(o15); + return c.str(); +} #endif // STRING_COMPOSE_H diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h index 7c981582c5..a471dd11ba 100644 --- a/libs/pbd/pbd/msvc_pbd.h +++ b/libs/pbd/pbd/msvc_pbd.h @@ -80,11 +80,11 @@ #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ #ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ +} /* extern "C" */ +#endif /* __cplusplus */ #ifdef PLATFORM_WINDOWS @@ -121,22 +121,22 @@ extern "C" { #endif #ifndef OPEN_MAX -#define OPEN_MAX 32 +#define OPEN_MAX (32) #endif #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ -PBDEXTN_API int PBDEXTN_APICALLTYPE cyginit (unsigned int result); -LIBPBD_API int PBD_APICALLTYPE dlclose (void *handle) __THROW; -LIBPBD_API void* PBD_APICALLTYPE dlopen (const char *file_name, int mode) __THROW; -LIBPBD_API void* PBD_APICALLTYPE dlsym (void *handle, const char *symbol_name) __THROW; -LIBPBD_API char* PBD_APICALLTYPE dlerror () __THROW; +PBDEXTN_API int PBDEXTN_APICALLTYPE cyginit (unsigned int result); +LIBPBD_API int PBD_APICALLTYPE dlclose (void *handle) __THROW; +LIBPBD_API void* PBD_APICALLTYPE dlopen (const char *file_name, int mode) __THROW; +LIBPBD_API void* PBD_APICALLTYPE dlsym (void *handle, const char *symbol_name) __THROW; +LIBPBD_API char* PBD_APICALLTYPE dlerror () __THROW; #ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ +} /* extern "C" */ +#endif /* __cplusplus */ #ifndef __CYGWIN__ /* For whatever reason, Ardour's 'libevoral' refuses to build as a DLL if we include both 'rpc.h' */ @@ -157,17 +157,17 @@ typedef int (FAR PBDEXTN_APICALLTYPE *CYGINIT_API)(unsigned int); #define _SSIZE_T_ typedef long _ssize_t; -#ifndef _NO_OLDNAMES +#ifndef _NO_OLDNAMES typedef _ssize_t ssize_t; #endif #endif /* ! _SSIZE_T_ */ struct dirent { - long d_ino; // Always zero - unsigned short d_reclen; // Always zero - unsigned short d_namlen; // Length of name in d_name - char d_name[FILENAME_MAX]; // File name + long d_ino; // Always zero + unsigned short d_reclen; // Always zero + unsigned shor d_namlen; // Length of name in d_name + char d_name[FILENAME_MAX]; // File name }; // This is an internal data structure. Do not use it @@ -175,65 +175,65 @@ struct dirent typedef struct { // Disk transfer area for this dir - struct _finddata_t dd_dta; + struct _finddata_t dd_dta; // 'dirent' struct to return from dir (NOTE: this // is not thread safe). - struct dirent dd_dir; + struct dirent dd_dir; // '_findnext()' handle - long dd_handle; + long dd_handle; // Current status of search: // 0 = not started yet (next entry to read is first entry) // -1 = off the end // Otherwise - positive (0 based) index of next entry - int dd_stat; + int dd_stat; // Full path for dir with search pattern (struct will be extended) - char dd_name[1]; + char dd_name[1]; } DIR; typedef unsigned int nfds_t; #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ +#endif /* __cplusplus */ -LIBPBD_API int __cdecl gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz); -LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset); -LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset); +LIBPBD_API int __cdecl gettimeofday(struct timeval *__restrict tv, __timezone_ptr_t tz); +LIBPBD_API ssize_t PBD_APICALLTYPE pread(int handle, void *buf, size_t nbytes, off_t offset); +LIBPBD_API ssize_t PBD_APICALLTYPE pwrite(int handle, const void *buf, size_t nbytes, off_t offset); #if defined(_MSC_VER) && (_MSC_VER < 1800) -LIBPBD_API double PBD_APICALLTYPE expm1(double x); -LIBPBD_API double PBD_APICALLTYPE log1p(double x); -LIBPBD_API double PBD_APICALLTYPE round(double x); -LIBPBD_API float PBD_APICALLTYPE roundf(float x); +LIBPBD_API double PBD_APICALLTYPE expm1(double x); +LIBPBD_API double PBD_APICALLTYPE log1p(double x); +LIBPBD_API double PBD_APICALLTYPE round(double x); +LIBPBD_API float PBD_APICALLTYPE roundf(float x); #endif #if defined(_MSC_VER) && (_MSC_VER < 1900) -LIBPBD_API double PBD_APICALLTYPE log2 (double x); -LIBPBD_API double PBD_APICALLTYPE trunc(double x); +LIBPBD_API double PBD_APICALLTYPE log2 (double x); +LIBPBD_API double PBD_APICALLTYPE trunc(double x); #endif namespace PBD { -LIBPBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored"); -LIBPBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]); -LIBPBD_API int PBD_APICALLTYPE mkstemp (char *template_name); -LIBPBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath); -LIBPBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath); +LIBPBD_API bool PBD_APICALLTYPE TestForMinimumSpecOS(char *revision="currently ignored"); +LIBPBD_API char* PBD_APICALLTYPE realpath (const char *original_path, char resolved_path[_MAX_PATH+1]); +LIBPBD_API int PBD_APICALLTYPE mkstemp (char *template_name); +LIBPBD_API int PBD_APICALLTYPE ntfs_link (const char *existing_filepath, const char *link_filepath); +LIBPBD_API int PBD_APICALLTYPE ntfs_unlink (const char *link_filepath); // These are used to replicate 'dirent.h' functionality -LIBPBD_API DIR* PBD_APICALLTYPE opendir (const char *szPath); -LIBPBD_API struct dirent* PBD_APICALLTYPE readdir (DIR *pDir); -LIBPBD_API int PBD_APICALLTYPE closedir (DIR *pDir); +LIBPBD_API DIR* PBD_APICALLTYPE opendir (const char *szPath); +LIBPBD_API struct dirent* PBD_APICALLTYPE readdir (DIR *pDir); +LIBPBD_API int PBD_APICALLTYPE closedir (DIR *pDir); } // namespace PBD #ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ +} /* extern "C" */ +#endif /* __cplusplus */ #endif // !__CYGWIN__ #endif // PLATFORM_WINDOWS diff --git a/libs/pbd/pbd/ringbuffer.h b/libs/pbd/pbd/ringbuffer.h index 9b5b09651e..bed9e829fb 100644 --- a/libs/pbd/pbd/ringbuffer.h +++ b/libs/pbd/pbd/ringbuffer.h @@ -30,16 +30,18 @@ namespace PBD { template<class T> class /*LIBPBD_API*/ RingBuffer { - public: +public: RingBuffer (guint sz) { -// size = ffs(sz); /* find first [bit] set is a single inlined assembly instruction. But it looks like the API rounds up so... */ - guint power_of_two; - for (power_of_two = 1; 1U<<power_of_two < sz; power_of_two++) {} - size = 1<<power_of_two; - size_mask = size; - size_mask -= 1; - buf = new T[size]; - reset (); +#if 0 + size = ffs(sz); /* find first [bit] set is a single inlined assembly instruction. But it looks like the API rounds up so... */ +#endif + guint power_of_two; + for (power_of_two = 1; 1U<<power_of_two < sz; power_of_two++) {} + size = 1<<power_of_two; + size_mask = size; + size_mask -= 1; + buf = new T[size]; + reset (); } virtual ~RingBuffer() { @@ -62,8 +64,8 @@ class /*LIBPBD_API*/ RingBuffer guint write (T const * src, guint cnt); struct rw_vector { - T *buf[2]; - guint len[2]; + T *buf[2]; + guint len[2]; }; void get_read_vector (rw_vector *); @@ -114,7 +116,7 @@ class /*LIBPBD_API*/ RingBuffer guint get_read_idx () const { return g_atomic_int_get (&read_idx); } guint bufsize () const { return size; } - protected: +protected: T *buf; guint size; mutable gint write_idx; @@ -125,80 +127,80 @@ class /*LIBPBD_API*/ RingBuffer template<class T> /*LIBPBD_API*/ guint RingBuffer<T>::read (T *dest, guint cnt) { - guint free_cnt; - guint cnt2; - guint to_read; - guint n1, n2; - guint priv_read_idx; + guint free_cnt; + guint cnt2; + guint to_read; + guint n1, n2; + guint priv_read_idx; - priv_read_idx=g_atomic_int_get(&read_idx); + priv_read_idx=g_atomic_int_get(&read_idx); - if ((free_cnt = read_space ()) == 0) { - return 0; - } + if ((free_cnt = read_space ()) == 0) { + return 0; + } - to_read = cnt > free_cnt ? free_cnt : cnt; + to_read = cnt > free_cnt ? free_cnt : cnt; - cnt2 = priv_read_idx + to_read; + cnt2 = priv_read_idx + to_read; - if (cnt2 > size) { - n1 = size - priv_read_idx; - n2 = cnt2 & size_mask; - } else { - n1 = to_read; - n2 = 0; - } + if (cnt2 > size) { + n1 = size - priv_read_idx; + n2 = cnt2 & size_mask; + } else { + n1 = to_read; + n2 = 0; + } - memcpy (dest, &buf[priv_read_idx], n1 * sizeof (T)); - priv_read_idx = (priv_read_idx + n1) & size_mask; + memcpy (dest, &buf[priv_read_idx], n1 * sizeof (T)); + priv_read_idx = (priv_read_idx + n1) & size_mask; - if (n2) { - memcpy (dest+n1, buf, n2 * sizeof (T)); - priv_read_idx = n2; - } + if (n2) { + memcpy (dest+n1, buf, n2 * sizeof (T)); + priv_read_idx = n2; + } - g_atomic_int_set(&read_idx, priv_read_idx); - return to_read; + g_atomic_int_set(&read_idx, priv_read_idx); + return to_read; } template<class T> /*LIBPBD_API*/ guint RingBuffer<T>::write (T const *src, guint cnt) { - guint free_cnt; - guint cnt2; - guint to_write; - guint n1, n2; - guint priv_write_idx; + guint free_cnt; + guint cnt2; + guint to_write; + guint n1, n2; + guint priv_write_idx; - priv_write_idx=g_atomic_int_get(&write_idx); + priv_write_idx=g_atomic_int_get(&write_idx); - if ((free_cnt = write_space ()) == 0) { - return 0; - } + if ((free_cnt = write_space ()) == 0) { + return 0; + } - to_write = cnt > free_cnt ? free_cnt : cnt; + to_write = cnt > free_cnt ? free_cnt : cnt; - cnt2 = priv_write_idx + to_write; + cnt2 = priv_write_idx + to_write; - if (cnt2 > size) { - n1 = size - priv_write_idx; - n2 = cnt2 & size_mask; - } else { - n1 = to_write; - n2 = 0; - } + if (cnt2 > size) { + n1 = size - priv_write_idx; + n2 = cnt2 & size_mask; + } else { + n1 = to_write; + n2 = 0; + } - memcpy (&buf[priv_write_idx], src, n1 * sizeof (T)); - priv_write_idx = (priv_write_idx + n1) & size_mask; + memcpy (&buf[priv_write_idx], src, n1 * sizeof (T)); + priv_write_idx = (priv_write_idx + n1) & size_mask; - if (n2) { - memcpy (buf, src+n1, n2 * sizeof (T)); - priv_write_idx = n2; - } + if (n2) { + memcpy (buf, src+n1, n2 * sizeof (T)); + priv_write_idx = n2; + } - g_atomic_int_set(&write_idx, priv_write_idx); - return to_write; + g_atomic_int_set(&write_idx, priv_write_idx); + return to_write; } template<class T> /*LIBPBD_API*/ void diff --git a/libs/pbd/pbd/timersub.h b/libs/pbd/pbd/timersub.h index 6cb152414c..785cbdde9d 100644 --- a/libs/pbd/pbd/timersub.h +++ b/libs/pbd/pbd/timersub.h @@ -1,5 +1,5 @@ /* Copyright (C) 1991-1994,1996-2003,2005,2006,2009 - Free Software Foundation, Inc. + Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -19,14 +19,13 @@ #include <sys/time.h> #ifndef timersub -# define timersub(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ } while (0) #endif - diff --git a/libs/pbd/pbd/tokenizer.h b/libs/pbd/pbd/tokenizer.h index ef9f3c951e..78e6be0490 100644 --- a/libs/pbd/pbd/tokenizer.h +++ b/libs/pbd/pbd/tokenizer.h @@ -43,49 +43,47 @@ tokenize(const StringType& str, Iter it, bool strip_whitespace=false) { - typename StringType::size_type start_pos = 0; - typename StringType::size_type end_pos = 0; - unsigned int token_count = 0; - - do { - start_pos = str.find_first_not_of(delims, start_pos); - end_pos = str.find_first_of(delims, start_pos); - if (start_pos != end_pos) { - if (end_pos == str.npos) { - end_pos = str.length(); - } - if (strip_whitespace) { + typename StringType::size_type start_pos = 0; + typename StringType::size_type end_pos = 0; + unsigned int token_count = 0; + + do { + start_pos = str.find_first_not_of(delims, start_pos); + end_pos = str.find_first_of(delims, start_pos); + if (start_pos != end_pos) { + if (end_pos == str.npos) { + end_pos = str.length(); + } + if (strip_whitespace) { StringType stripped = str.substr(start_pos, end_pos - start_pos); strip_whitespace_edges (stripped); if (stripped.length()) { *it++ = stripped; } } else { - *it++ = str.substr(start_pos, end_pos - start_pos); + *it++ = str.substr(start_pos, end_pos - start_pos); } - ++token_count; - start_pos = str.find_first_not_of(delims, end_pos + 1); - } - } while (start_pos != str.npos); + ++token_count; + start_pos = str.find_first_not_of(delims, end_pos + 1); + } + } while (start_pos != str.npos); - if (start_pos != str.npos) { - if (strip_whitespace) { + if (start_pos != str.npos) { + if (strip_whitespace) { StringType stripped = str.substr(start_pos, str.length() - start_pos); strip_whitespace_edges (stripped); if (stripped.length()) { *it++ = stripped; } } else { - *it++ = str.substr(start_pos, str.length() - start_pos); + *it++ = str.substr(start_pos, str.length() - start_pos); } - ++token_count; - } + ++token_count; + } - return token_count; + return token_count; } } // namespace PBD #endif // PBD_TOKENIZER - - diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index c18d36f065..6548852917 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -258,7 +258,7 @@ XMLNode::clear_lists () _selected_children.clear (); - for (curchild = _children.begin(); curchild != _children.end(); ++curchild) { + for (curchild = _children.begin(); curchild != _children.end(); ++curchild) { delete *curchild; } @@ -665,8 +665,7 @@ XMLNode::remove_nodes_and_delete(const string& propname, const string& val) } void -XMLNode::remove_node_and_delete(const string& n, const string& propname, - const string& val) +XMLNode::remove_node_and_delete(const string& n, const string& propname, const string& val) { for (XMLNodeIterator i = _children.begin(); i != _children.end(); ++i) { if ((*i)->name() == n) { |