diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:31:44 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:31:44 -0800 |
| commit | 9066cfe9886ac131c34d59ed0e2d287b0e3c0087 (patch) | |
| tree | d88beb88001f2482911e3d28e43833b50e4b4e97 /tools/localize/Configuration.cpp | |
| parent | d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (diff) | |
| download | frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.zip frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.tar.gz frameworks_base-9066cfe9886ac131c34d59ed0e2d287b0e3c0087.tar.bz2 | |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tools/localize/Configuration.cpp')
| -rw-r--r-- | tools/localize/Configuration.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/localize/Configuration.cpp b/tools/localize/Configuration.cpp new file mode 100644 index 0000000..56addbd --- /dev/null +++ b/tools/localize/Configuration.cpp @@ -0,0 +1,76 @@ +#include "Configuration.h" +#include <string.h> + +int +Configuration::Compare(const Configuration& that) const +{ + int n; + + n = locale.compare(that.locale); + if (n != 0) return n; + + n = vendor.compare(that.vendor); + if (n != 0) return n; + + n = orientation.compare(that.orientation); + if (n != 0) return n; + + n = density.compare(that.density); + if (n != 0) return n; + + n = touchscreen.compare(that.touchscreen); + if (n != 0) return n; + + n = keyboard.compare(that.keyboard); + if (n != 0) return n; + + n = navigation.compare(that.navigation); + if (n != 0) return n; + + n = screenSize.compare(that.screenSize); + if (n != 0) return n; + + return 0; +} + +string +Configuration::ToString() const +{ + string s; + if (locale.length() > 0) { + if (s.length() > 0) { + s += "-"; + } + s += locale; + } + return s; +} + +bool +split_locale(const string& in, string* language, string* region) +{ + const int len = in.length(); + if (len == 2) { + if (isalpha(in[0]) && isalpha(in[1])) { + *language = in; + region->clear(); + return true; + } else { + return false; + } + } + else if (len == 5) { + if (isalpha(in[0]) && isalpha(in[1]) && (in[2] == '_' || in[2] == '-') + && isalpha(in[3]) && isalpha(in[4])) { + language->assign(in.c_str(), 2); + region->assign(in.c_str()+3, 2); + return true; + } else { + return false; + } + } + else { + return false; + } +} + |
