Chromium Code Reviews| 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 | 8 |
| 9 #ifndef SkRTConf_DEFINED | 9 #ifndef SkRTConf_DEFINED |
| 10 #define SkRTConf_DEFINED | 10 #define SkRTConf_DEFINED |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 T value; | 104 T value; |
| 105 if (skRTConfRegistry().parse(fName.c_str(), &value)) { | 105 if (skRTConfRegistry().parse(fName.c_str(), &value)) { |
| 106 fValue = value; | 106 fValue = value; |
| 107 } | 107 } |
| 108 skRTConfRegistry().registerConf(this); | 108 skRTConfRegistry().registerConf(this); |
| 109 } | 109 } |
| 110 | 110 |
| 111 template<typename T> | 111 template<typename T> |
| 112 void SkRTConf<T>::print(SkWStream *o) const { | 112 void SkRTConf<T>::print(SkWStream *o) const { |
| 113 char outline[200]; // should be ok because we specify a max. width for every thing here. | 113 char outline[200]; // should be ok because we specify a max. width for every thing here. |
| 114 | 114 char *outptr; |
| 115 sprintf(outline, "%-30.30s", getName()); | 115 if (strlen(getName()) >= 30) { |
| 116 doPrint(&(outline[30])); | 116 o->writeText(getName()); |
| 117 sprintf(&(outline[60]), " %.128s", fDescription.c_str()); | 117 o->writeText(" "); |
| 118 outptr = &(outline[0]); | |
| 119 } | |
| 120 else { | |
|
hal.canary
2013/10/14 14:32:08
"} else {" should be all on one line.
reed1
2013/10/14 15:07:18
agreed
| |
| 121 sprintf(outline, "%-30.30s", getName()); | |
| 122 outptr = &(outline[30]); | |
| 123 } | |
| 124 | |
| 125 doPrint(outptr); | |
| 126 sprintf(outptr+30, " %.128s", fDescription.c_str()); | |
|
hal.canary
2013/10/14 14:32:08
Is there a style inconsistency between outptr+30 a
reed1
2013/10/14 15:07:18
very minor, but I think I agree with the reviewer,
| |
| 118 for (size_t i = strlen(outline); i --> 0 && ' ' == outline[i];) { | 127 for (size_t i = strlen(outline); i --> 0 && ' ' == outline[i];) { |
| 119 outline[i] = '\0'; | 128 outline[i] = '\0'; |
| 120 } | 129 } |
| 121 o->writeText(outline); | 130 o->writeText(outline); |
| 122 } | 131 } |
| 123 | 132 |
| 124 template<typename T> | 133 template<typename T> |
| 125 void SkRTConf<T>::doPrint(char *s) const { | 134 void SkRTConf<T>::doPrint(char *s) const { |
| 126 sprintf(s, "%-30.30s", "How do I print myself??"); | 135 sprintf(s, "%-30.30s", "How do I print myself??"); |
| 127 } | 136 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 // static_cast here is okay because there's only one kind of child class. | 176 // static_cast here is okay because there's only one kind of child class. |
| 168 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); | 177 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); |
| 169 return child_pointer && | 178 return child_pointer && |
| 170 fName == child_pointer->fName && | 179 fName == child_pointer->fName && |
| 171 fDescription == child_pointer->fDescription && | 180 fDescription == child_pointer->fDescription && |
| 172 fValue == child_pointer->fValue && | 181 fValue == child_pointer->fValue && |
| 173 fDefault == child_pointer->fDefault; | 182 fDefault == child_pointer->fDefault; |
| 174 } | 183 } |
| 175 | 184 |
| 176 #endif | 185 #endif |
| OLD | NEW |