| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkRTConf.h" | 8 #include "SkRTConf.h" |
| 9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 *commentptr = '\0'; | 34 *commentptr = '\0'; |
| 35 } | 35 } |
| 36 | 36 |
| 37 char sep[] = " \t\r\n"; | 37 char sep[] = " \t\r\n"; |
| 38 | 38 |
| 39 char *keyptr = strtok(line, sep); | 39 char *keyptr = strtok(line, sep); |
| 40 if (!keyptr) { | 40 if (!keyptr) { |
| 41 continue; | 41 continue; |
| 42 } | 42 } |
| 43 | 43 |
| 44 char *valptr = strtok(NULL, sep); | 44 char *valptr = strtok(nullptr, sep); |
| 45 if (!valptr) { | 45 if (!valptr) { |
| 46 continue; | 46 continue; |
| 47 } | 47 } |
| 48 | 48 |
| 49 SkString *key = new SkString(keyptr); | 49 SkString *key = new SkString(keyptr); |
| 50 SkString *val = new SkString(valptr); | 50 SkString *val = new SkString(valptr); |
| 51 | 51 |
| 52 fConfigFileKeys.append(1, &key); | 52 fConfigFileKeys.append(1, &key); |
| 53 fConfigFileValues.append(1, &val); | 53 fConfigFileValues.append(1, &val); |
| 54 } | 54 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 static inline void str_replace(char *s, char search, char replace) { | 234 static inline void str_replace(char *s, char search, char replace) { |
| 235 for (char *ptr = s ; *ptr ; ptr++) { | 235 for (char *ptr = s ; *ptr ; ptr++) { |
| 236 if (*ptr == search) { | 236 if (*ptr == search) { |
| 237 *ptr = replace; | 237 *ptr = replace; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 template<typename T> bool SkRTConfRegistry::parse(const char *name, T* value) { | 242 template<typename T> bool SkRTConfRegistry::parse(const char *name, T* value) { |
| 243 const char *str = NULL; | 243 const char *str = nullptr; |
| 244 | 244 |
| 245 for (int i = fConfigFileKeys.count() - 1 ; i >= 0; i--) { | 245 for (int i = fConfigFileKeys.count() - 1 ; i >= 0; i--) { |
| 246 if (fConfigFileKeys[i]->equals(name)) { | 246 if (fConfigFileKeys[i]->equals(name)) { |
| 247 str = fConfigFileValues[i]->c_str(); | 247 str = fConfigFileValues[i]->c_str(); |
| 248 break; | 248 break; |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 SkString environment_variable("skia."); | 252 SkString environment_variable("skia."); |
| 253 environment_variable.append(name); | 253 environment_variable.append(name); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 T value, | 294 T value, |
| 295 bool warnIfNotFound) { | 295 bool warnIfNotFound) { |
| 296 SkTDArray<SkRTConfBase *> *confArray; | 296 SkTDArray<SkRTConfBase *> *confArray; |
| 297 if (!fConfs.find(name, &confArray)) { | 297 if (!fConfs.find(name, &confArray)) { |
| 298 if (warnIfNotFound) { | 298 if (warnIfNotFound) { |
| 299 SkDebugf("WARNING: Attempting to set configuration value \"%s\"," | 299 SkDebugf("WARNING: Attempting to set configuration value \"%s\"," |
| 300 " but I've never heard of that.\n", name); | 300 " but I've never heard of that.\n", name); |
| 301 } | 301 } |
| 302 return; | 302 return; |
| 303 } | 303 } |
| 304 SkASSERT(confArray != NULL); | 304 SkASSERT(confArray != nullptr); |
| 305 for (SkRTConfBase **confBase = confArray->begin(); confBase != confArray->en
d(); confBase++) { | 305 for (SkRTConfBase **confBase = confArray->begin(); confBase != confArray->en
d(); confBase++) { |
| 306 // static_cast here is okay because there's only one kind of child class
. | 306 // static_cast here is okay because there's only one kind of child class
. |
| 307 SkRTConf<T> *concrete = static_cast<SkRTConf<T> *>(*confBase); | 307 SkRTConf<T> *concrete = static_cast<SkRTConf<T> *>(*confBase); |
| 308 | 308 |
| 309 if (concrete) { | 309 if (concrete) { |
| 310 concrete->set(value); | 310 concrete->set(value); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 template void SkRTConfRegistry::set(const char *name, bool value, bool); | 315 template void SkRTConfRegistry::set(const char *name, bool value, bool); |
| 316 template void SkRTConfRegistry::set(const char *name, int value, bool); | 316 template void SkRTConfRegistry::set(const char *name, int value, bool); |
| 317 template void SkRTConfRegistry::set(const char *name, unsigned int value, bool); | 317 template void SkRTConfRegistry::set(const char *name, unsigned int value, bool); |
| 318 template void SkRTConfRegistry::set(const char *name, float value, bool); | 318 template void SkRTConfRegistry::set(const char *name, float value, bool); |
| 319 template void SkRTConfRegistry::set(const char *name, double value, bool); | 319 template void SkRTConfRegistry::set(const char *name, double value, bool); |
| 320 template void SkRTConfRegistry::set(const char *name, char * value, bool); | 320 template void SkRTConfRegistry::set(const char *name, char * value, bool); |
| 321 | 321 |
| 322 SkRTConfRegistry &skRTConfRegistry() { | 322 SkRTConfRegistry &skRTConfRegistry() { |
| 323 static SkRTConfRegistry r; | 323 static SkRTConfRegistry r; |
| 324 return r; | 324 return r; |
| 325 } | 325 } |
| OLD | NEW |