Read a top-level integer field, clamped to [0, max_value]. Returns -1 if the key is missing. Throws on type mismatch.
| 280 | /// Read a top-level integer field, clamped to [0, max_value]. Returns -1 if |
| 281 | /// the key is missing. Throws on type mismatch. |
| 282 | int getIntField(const Poco::JSON::Object::Ptr & object, const char * key, int max_value) |
| 283 | { |
| 284 | if (!object->has(key)) |
| 285 | return -1; |
| 286 | Int64 value = object->getValue<Int64>(key); |
| 287 | if (value < 0) |
| 288 | return -1; |
| 289 | if (value > max_value) |
| 290 | return max_value; |
| 291 | return static_cast<int>(value); |
| 292 | } |
| 293 | |
| 294 | /// Parse a control message like {"type":"resize","cols":80,"rows":24}. |
| 295 | bool parseResizeMessage(const String & json, int & cols, int & rows) |
no test coverage detected