Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1464)

Side by Side Diff: src/utils/SkRTConf.cpp

Issue 54503007: New SkRTConf macro SK_CONF_TRY_SET: no complaint on missing configuration (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: whitespace change for ifdefs Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 // need to explicitly instantiate the parsing function for every config type we might have... 266 // need to explicitly instantiate the parsing function for every config type we might have...
267 267
268 template bool SkRTConfRegistry::parse(const char *name, bool *value); 268 template bool SkRTConfRegistry::parse(const char *name, bool *value);
269 template bool SkRTConfRegistry::parse(const char *name, int *value); 269 template bool SkRTConfRegistry::parse(const char *name, int *value);
270 template bool SkRTConfRegistry::parse(const char *name, unsigned int *value); 270 template bool SkRTConfRegistry::parse(const char *name, unsigned int *value);
271 template bool SkRTConfRegistry::parse(const char *name, float *value); 271 template bool SkRTConfRegistry::parse(const char *name, float *value);
272 template bool SkRTConfRegistry::parse(const char *name, double *value); 272 template bool SkRTConfRegistry::parse(const char *name, double *value);
273 template bool SkRTConfRegistry::parse(const char *name, const char **value); 273 template bool SkRTConfRegistry::parse(const char *name, const char **value);
274 274
275 template <typename T> void SkRTConfRegistry::set(const char *name, T value) { 275 template <typename T> void SkRTConfRegistry::set(const char *name,
276 276 T value,
277 bool warnIfNotFound) {
277 SkTDArray<SkRTConfBase *> *confArray; 278 SkTDArray<SkRTConfBase *> *confArray;
278 if (!fConfs.find(name, &confArray)) { 279 if (!fConfs.find(name, &confArray)) {
279 SkDebugf("WARNING: Attempting to set configuration value \"%s\", but I'v e never heard of that.\n", name); 280 if (warnIfNotFound) {
281 SkDebugf("WARNING: Attempting to set configuration value \"%s\","
282 " but I've never heard of that.\n", name);
283 }
280 return; 284 return;
281 } 285 }
282 286 SkASSERT(confArray != NULL);
283 for (SkRTConfBase **confBase = confArray->begin(); confBase != confArray->en d(); confBase++) { 287 for (SkRTConfBase **confBase = confArray->begin(); confBase != confArray->en d(); confBase++) {
284 // static_cast here is okay because there's only one kind of child class . 288 // static_cast here is okay because there's only one kind of child class .
285 SkRTConf<T> *concrete = static_cast<SkRTConf<T> *>(*confBase); 289 SkRTConf<T> *concrete = static_cast<SkRTConf<T> *>(*confBase);
286 290
287 if (concrete) { 291 if (concrete) {
288 concrete->set(value); 292 concrete->set(value);
289 } 293 }
290 } 294 }
291 } 295 }
292 296
293 template void SkRTConfRegistry::set(const char *name, bool value); 297 template void SkRTConfRegistry::set(const char *name, bool value, bool);
294 template void SkRTConfRegistry::set(const char *name, int value); 298 template void SkRTConfRegistry::set(const char *name, int value, bool);
295 template void SkRTConfRegistry::set(const char *name, unsigned int value); 299 template void SkRTConfRegistry::set(const char *name, unsigned int value, bool);
296 template void SkRTConfRegistry::set(const char *name, float value); 300 template void SkRTConfRegistry::set(const char *name, float value, bool);
297 template void SkRTConfRegistry::set(const char *name, double value); 301 template void SkRTConfRegistry::set(const char *name, double value, bool);
298 template void SkRTConfRegistry::set(const char *name, char * value); 302 template void SkRTConfRegistry::set(const char *name, char * value, bool);
299 303
300 SkRTConfRegistry &skRTConfRegistry() { 304 SkRTConfRegistry &skRTConfRegistry() {
301 static SkRTConfRegistry r; 305 static SkRTConfRegistry r;
302 return r; 306 return r;
303 } 307 }
304 308
305 309
306 #ifdef SK_SUPPORT_UNITTEST 310 #ifdef SK_SUPPORT_UNITTEST
307 311
308 #ifdef SK_BUILD_FOR_WIN32 312 #ifdef SK_BUILD_FOR_WIN32
(...skipping 12 matching lines...) Expand all
321 sk_setenv("skia_nonexistent_item", "132"); 325 sk_setenv("skia_nonexistent_item", "132");
322 int result = 0; 326 int result = 0;
323 registryWithoutContents.parse("nonexistent.item", &result); 327 registryWithoutContents.parse("nonexistent.item", &result);
324 SkASSERT(result == 132); 328 SkASSERT(result == 132);
325 } 329 }
326 330
327 SkRTConfRegistry::SkRTConfRegistry(bool) 331 SkRTConfRegistry::SkRTConfRegistry(bool)
328 : fConfs(100) { 332 : fConfs(100) {
329 } 333 }
330 #endif 334 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698