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 } else { |
| 120 sprintf(outline, "%-30.30s", getName()); |
| 121 outptr = &(outline[30]); |
| 122 } |
| 123 |
| 124 doPrint(outptr); |
| 125 sprintf(outptr+30, " %.128s", fDescription.c_str()); |
118 for (size_t i = strlen(outline); i --> 0 && ' ' == outline[i];) { | 126 for (size_t i = strlen(outline); i --> 0 && ' ' == outline[i];) { |
119 outline[i] = '\0'; | 127 outline[i] = '\0'; |
120 } | 128 } |
121 o->writeText(outline); | 129 o->writeText(outline); |
122 } | 130 } |
123 | 131 |
124 template<typename T> | 132 template<typename T> |
125 void SkRTConf<T>::doPrint(char *s) const { | 133 void SkRTConf<T>::doPrint(char *s) const { |
126 sprintf(s, "%-30.30s", "How do I print myself??"); | 134 sprintf(s, "%-30.30s", "How do I print myself??"); |
127 } | 135 } |
(...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. | 175 // 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); | 176 const SkRTConf<T> *child_pointer = static_cast<const SkRTConf<T> *>(conf); |
169 return child_pointer && | 177 return child_pointer && |
170 fName == child_pointer->fName && | 178 fName == child_pointer->fName && |
171 fDescription == child_pointer->fDescription && | 179 fDescription == child_pointer->fDescription && |
172 fValue == child_pointer->fValue && | 180 fValue == child_pointer->fValue && |
173 fDefault == child_pointer->fDefault; | 181 fDefault == child_pointer->fDefault; |
174 } | 182 } |
175 | 183 |
176 #endif | 184 #endif |
OLD | NEW |