00001 #ifdef _MSC_VER
00002 #pragma warning(disable : 4786)
00003 #endif
00004
00005
00006 #include <ctype.h>
00007 #include "utility.h"
00008 #include "internal.h"
00009
00010
00011 namespace audiere {
00012
00013 ParameterList::ParameterList(const char* parameters) {
00014 std::string key;
00015 std::string value;
00016
00017 std::string* current_string = &key;
00018
00019
00020 const char* p = parameters;
00021 while (*p) {
00022
00023 if (*p == '=') {
00024
00025 current_string = &value;
00026
00027 } else if (*p == ',') {
00028
00029 if (key.length() && value.length()) {
00030 m_values[key] = value;
00031 }
00032 key = "";
00033 value = "";
00034 current_string = &key;
00035
00036 } else {
00037 *current_string += *p;
00038 }
00039
00040 ++p;
00041 }
00042
00043
00044 if (key.length() && value.length()) {
00045 m_values[key] = value;
00046 }
00047 }
00048
00049 std::string
00050 ParameterList::getValue(std::string key, std::string defaultValue) const {
00051 std::map<std::string, std::string>::const_iterator i = m_values.find(key);
00052 return (i == m_values.end() ? defaultValue : i->second);
00053 }
00054
00055
00056 int strcmp_case(const char* a, const char* b) {
00057 while (*a && *b) {
00058
00059 char c = tolower(*a++);
00060 char d = tolower(*b++);
00061
00062 if (c != d) {
00063 return c - d;
00064 }
00065 }
00066
00067 char c = tolower(*a);
00068 char d = tolower(*b);
00069 return (c - d);
00070 }
00071
00072
00073 ADR_EXPORT(int, AdrGetSampleSize)(SampleFormat format) {
00074 switch (format) {
00075 case SF_U8: return 1;
00076 case SF_S16: return 2;
00077 default: return 0;
00078 }
00079 }
00080
00081 }