OLD | NEW |
1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 1 #ifndef EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 2 #define EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
3 | 3 |
4 #include <stdint.h> | 4 #include <stdint.h> |
5 #include <string.h> | 5 #include <string.h> |
6 #include <string> | 6 #include <string> |
7 #include "SkTDArray.h" | 7 #include "SkTDArray.h" |
8 #include "SkTDict.h" | 8 #include "SkTDict.h" |
9 #include "SkRect.h" | 9 #include "SkRect.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 SkASSERT(key->fObjectType == kName_PdfObjectType); | 377 SkASSERT(key->fObjectType == kName_PdfObjectType); |
378 | 378 |
379 if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionar
y_PdfObjectType) { | 379 if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionar
y_PdfObjectType) { |
380 // TODO(edisonn): report err | 380 // TODO(edisonn): report err |
381 return false; | 381 return false; |
382 } | 382 } |
383 | 383 |
384 // we rewrite all delimiters and white spaces with '\0', so we expect th
e end of name to be '\0' | 384 // we rewrite all delimiters and white spaces with '\0', so we expect th
e end of name to be '\0' |
385 SkASSERT(key->fStr.fBuffer[key->fStr.fBytes] == '\0'); | 385 SkASSERT(key->fStr.fBuffer[key->fStr.fBytes] == '\0'); |
386 | 386 |
387 return set((char*)key->fStr.fBuffer, value); | 387 return set(key->fStr.fBuffer, key->fStr.fBytes, value); |
388 } | 388 } |
389 | 389 |
390 bool set(const char* key, SkPdfObject* value) { | 390 bool set(const char* key, SkPdfObject* value) { |
| 391 return set((const unsigned char*)key, strlen(key), value); |
| 392 } |
| 393 |
| 394 bool set(const unsigned char* key, size_t len, SkPdfObject* value) { |
391 SkASSERT(fObjectType == kDictionary_PdfObjectType); | 395 SkASSERT(fObjectType == kDictionary_PdfObjectType); |
392 | 396 |
393 if (fObjectType != kDictionary_PdfObjectType) { | 397 if (fObjectType != kDictionary_PdfObjectType) { |
394 // TODO(edisonn): report err | 398 // TODO(edisonn): report err |
395 return false; | 399 return false; |
396 } | 400 } |
397 | 401 |
398 return fMap->set(key, value); | 402 return fMap->set((const char*)key, len, value); |
399 } | 403 } |
400 | 404 |
401 SkPdfObject* get(SkPdfObject* key) { | 405 SkPdfObject* get(SkPdfObject* key) { |
402 SkASSERT(fObjectType == kDictionary_PdfObjectType); | 406 SkASSERT(fObjectType == kDictionary_PdfObjectType); |
403 SkASSERT(key->fObjectType == kName_PdfObjectType); | 407 SkASSERT(key->fObjectType == kName_PdfObjectType); |
404 | 408 |
405 if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionar
y_PdfObjectType) { | 409 if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionar
y_PdfObjectType) { |
406 // TODO(edisonn): report err | 410 // TODO(edisonn): report err |
407 return NULL; | 411 return NULL; |
408 } | 412 } |
409 | 413 |
410 SkASSERT(key->fStr.fBuffer[key->fStr.fBytes] == '\0'); | 414 SkASSERT(key->fStr.fBuffer[key->fStr.fBytes] == '\0'); |
411 | 415 |
412 return get((char*)key->fStr.fBuffer); | 416 return get(key->fStr.fBuffer, key->fStr.fBytes); |
413 } | 417 } |
414 | 418 |
415 SkPdfObject* get(const char* key) { | 419 SkPdfObject* get(const char* key) { |
| 420 return get((const unsigned char*)key, strlen(key)); |
| 421 } |
| 422 |
| 423 SkPdfObject* get(const unsigned char* key, size_t len) { |
416 SkASSERT(fObjectType == kDictionary_PdfObjectType); | 424 SkASSERT(fObjectType == kDictionary_PdfObjectType); |
417 SkASSERT(key); | 425 SkASSERT(key); |
418 if (fObjectType != kDictionary_PdfObjectType) { | 426 if (fObjectType != kDictionary_PdfObjectType) { |
419 // TODO(edisonn): report err | 427 // TODO(edisonn): report err |
420 return NULL; | 428 return NULL; |
421 } | 429 } |
422 SkPdfObject* ret = NULL; | 430 SkPdfObject* ret = NULL; |
423 fMap->find(key, &ret); | 431 fMap->find((const char*)key, len, &ret); |
424 return ret; | 432 return ret; |
425 } | 433 } |
426 | 434 |
427 const SkPdfObject* get(SkPdfObject* key) const { | 435 const SkPdfObject* get(SkPdfObject* key) const { |
428 SkASSERT(fObjectType == kDictionary_PdfObjectType); | 436 SkASSERT(fObjectType == kDictionary_PdfObjectType); |
429 SkASSERT(key->fObjectType == kName_PdfObjectType); | 437 SkASSERT(key->fObjectType == kName_PdfObjectType); |
430 | 438 |
431 if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionar
y_PdfObjectType) { | 439 if (key->fObjectType != kName_PdfObjectType || fObjectType != kDictionar
y_PdfObjectType) { |
432 // TODO(edisonn): report err | 440 // TODO(edisonn): report err |
433 return NULL; | 441 return NULL; |
434 } | 442 } |
435 | 443 |
436 SkASSERT(key->fStr.fBuffer[key->fStr.fBytes] == '\0'); | 444 SkASSERT(key->fStr.fBuffer[key->fStr.fBytes] == '\0'); |
437 | 445 |
438 return get((char*)key->fStr.fBuffer); | 446 return get(key->fStr.fBuffer, key->fStr.fBytes); |
439 } | 447 } |
440 | 448 |
| 449 const SkPdfObject* get(const char* key) const { |
| 450 return get((const unsigned char*)key, strlen(key)); |
| 451 } |
441 | 452 |
442 const SkPdfObject* get(const char* key) const { | 453 const SkPdfObject* get(const unsigned char* key, size_t len) const { |
443 SkASSERT(fObjectType == kDictionary_PdfObjectType); | 454 SkASSERT(fObjectType == kDictionary_PdfObjectType); |
444 SkASSERT(key); | 455 SkASSERT(key); |
445 if (fObjectType != kDictionary_PdfObjectType) { | 456 if (fObjectType != kDictionary_PdfObjectType) { |
446 // TODO(edisonn): report err | 457 // TODO(edisonn): report err |
447 return NULL; | 458 return NULL; |
448 } | 459 } |
449 SkPdfObject* ret = NULL; | 460 SkPdfObject* ret = NULL; |
450 fMap->find(key, &ret); | 461 fMap->find((const char*)key, len, &ret); |
451 return ret; | 462 return ret; |
452 } | 463 } |
453 | 464 |
454 const SkPdfObject* get(const char* key, const char* abr) const { | 465 const SkPdfObject* get(const char* key, const char* abr) const { |
455 const SkPdfObject* ret = get(key); | 466 const SkPdfObject* ret = get(key); |
456 // TODO(edisonn): / is a valid name, and it might be an abreviation, so
"" should not be like NULL | 467 // TODO(edisonn): / is a valid name, and it might be an abreviation, so
"" should not be like NULL |
457 // make this distiontion in generator, and remove "" from condition | 468 // make this distiontion in generator, and remove "" from condition |
458 if (ret != NULL || abr == NULL || *abr == '\0') { | 469 if (ret != NULL || abr == NULL || *abr == '\0') { |
459 return ret; | 470 return ret; |
460 } | 471 } |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 SkPdfName() : SkPdfObject() { | 882 SkPdfName() : SkPdfObject() { |
872 SkPdfObject::makeName((unsigned char*)"", this); | 883 SkPdfObject::makeName((unsigned char*)"", this); |
873 } | 884 } |
874 public: | 885 public: |
875 SkPdfName(char* name) : SkPdfObject() { | 886 SkPdfName(char* name) : SkPdfObject() { |
876 this->makeName((unsigned char*)name, this); | 887 this->makeName((unsigned char*)name, this); |
877 } | 888 } |
878 }; | 889 }; |
879 | 890 |
880 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ | 891 #endif // EXPERIMENTAL_PDFVIEWER_PDFPARSER_NATIVE_SKPDFOBJECT_H_ |
OLD | NEW |