---------------------------------------------------------------------------
| 256 | |
| 257 | //--------------------------------------------------------------------------- |
| 258 | int TimeCode::FromString(const string_view& V, bool Ignore1001FromDropFrame) |
| 259 | { |
| 260 | const char* Value = V.data(); |
| 261 | size_t Length = V.size(); |
| 262 | |
| 263 | // Handled undefined |
| 264 | if (Length >= 8 && !memcmp(Value, "--:--:--", 8)) |
| 265 | { |
| 266 | bool Caught = false; |
| 267 | if (Length == 8) |
| 268 | Caught = true; |
| 269 | else if (Value[8] == ':' || Value[8] == ';') |
| 270 | { |
| 271 | Caught = true; |
| 272 | for (size_t i = 9; i < Length; i++) |
| 273 | if (Value[i] != '-') |
| 274 | Caught = false; |
| 275 | } |
| 276 | if (Caught) |
| 277 | { |
| 278 | SetUndefined(); |
| 279 | if (Length > 8 && Value[8] == ';' && Ignore1001FromDropFrame) |
| 280 | SetDropFrame(); |
| 281 | SetValid(); |
| 282 | return 0; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // Handle negative values |
| 287 | if (*Value == '-') |
| 288 | { |
| 289 | SetNegative(); |
| 290 | Value++; |
| 291 | Length--; |
| 292 | } |
| 293 | |
| 294 | //hh:mm:ss;ff or hh:mm:ss.zzzzzzzzzSfffffffff formats |
| 295 | if (Length > 7 |
| 296 | && Value[0] >= '0' && Value[0] <= '9' |
| 297 | && Value[1] >= '0' && Value[1] <= '9' |
| 298 | && Value[2] == ':' |
| 299 | && Value[3] >= '0' && Value[3] <= '9' |
| 300 | && Value[4] >= '0' && Value[4] <= '9' |
| 301 | && Value[5] == ':' |
| 302 | && Value[6] >= '0' && Value[6] <= '9' |
| 303 | && Value[7] >= '0' && Value[7] <= '9') |
| 304 | { |
| 305 | if (Length > 8) |
| 306 | { |
| 307 | //hh:mm:ss.zzzzzzzzzSfffffffff format |
| 308 | unsigned char c = (unsigned char)Value[8]; |
| 309 | if (c == '.' || c == ',') |
| 310 | { |
| 311 | if (Length == 9) |
| 312 | { |
| 313 | *this = TimeCode(); |
| 314 | return 1; |
| 315 | } |
no test coverage detected