diff options
author | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-10 01:04:37 +0000 |
---|---|---|
committer | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-04-10 01:04:37 +0000 |
commit | 4e1d3acc16edb0b502cff157978235f5af627a5a (patch) | |
tree | 1df757df2590777d5eb4a07bb616a4fa8e07c8ba /include | |
parent | d5e05d428647c164080e38dabee94db52c8c4544 (diff) |
code style
git-svn-id: http://skia.googlecode.com/svn/trunk@1095 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkString.h | 110 | ||||
-rw-r--r-- | include/core/SkUtils.h | 7 |
2 files changed, 57 insertions, 60 deletions
diff --git a/include/core/SkString.h b/include/core/SkString.h index eb25e15f8d..38604dd375 100644 --- a/include/core/SkString.h +++ b/include/core/SkString.h @@ -78,25 +78,21 @@ public: const char* c_str() const { return fRec->data(); } char operator[](size_t n) const { return this->c_str()[n]; } - bool equals(const SkString&) const; - bool equals(const char text[]) const; - bool equals(const char text[], size_t len) const; + bool equals(const SkString&) const; + bool equals(const char text[]) const; + bool equals(const char text[], size_t len) const; - bool startsWith(const char prefix[]) const - { + bool startsWith(const char prefix[]) const { return SkStrStartsWith(fRec->data(), prefix); } - bool endsWith(const char suffix[]) const - { + bool endsWith(const char suffix[]) const { return SkStrEndsWith(fRec->data(), suffix); } - friend int operator==(const SkString& a, const SkString& b) - { + friend int operator==(const SkString& a, const SkString& b) { return a.equals(b); } - friend int operator!=(const SkString& a, const SkString& b) - { + friend int operator!=(const SkString& a, const SkString& b) { return !a.equals(b); } @@ -107,51 +103,52 @@ public: char* writable_str(); char& operator[](size_t n) { return this->writable_str()[n]; } - void reset(); - void resize(size_t len) { this->set(NULL, len); } - void set(const SkString& src) { *this = src; } - void set(const char text[]); - void set(const char text[], size_t len); - void setUTF16(const uint16_t[]); - void setUTF16(const uint16_t[], size_t len); - - void insert(size_t offset, const SkString& src) { this->insert(offset, src.c_str(), src.size()); } - void insert(size_t offset, const char text[]); - void insert(size_t offset, const char text[], size_t len); - void insertUnichar(size_t offset, SkUnichar); - void insertS32(size_t offset, int32_t value); - void insertS64(size_t offset, int64_t value, int minDigits = 0); - void insertHex(size_t offset, uint32_t value, int minDigits = 0); - void insertScalar(size_t offset, SkScalar); - - void append(const SkString& str) { this->insert((size_t)-1, str); } - void append(const char text[]) { this->insert((size_t)-1, text); } - void append(const char text[], size_t len) { this->insert((size_t)-1, text, len); } - void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); } - void appendS32(int32_t value) { this->insertS32((size_t)-1, value); } - void appendS64(int64_t value, int minDigits = 0) { this->insertS64((size_t)-1, value, minDigits); } - void appendHex(uint32_t value, int minDigits = 0) { this->insertHex((size_t)-1, value, minDigits); } - void appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); } - - void prepend(const SkString& str) { this->insert(0, str); } - void prepend(const char text[]) { this->insert(0, text); } - void prepend(const char text[], size_t len) { this->insert(0, text, len); } - void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); } - void prependS32(int32_t value) { this->insertS32(0, value); } - void prependS64(int32_t value, int minDigits = 0) { this->insertS64(0, value, minDigits); } - void prependHex(uint32_t value, int minDigits = 0) { this->insertHex(0, value, minDigits); } - void prependScalar(SkScalar value) { this->insertScalar((size_t)-1, value); } - - void printf(const char format[], ...); - void appendf(const char format[], ...); - void prependf(const char format[], ...); - - void remove(size_t offset, size_t length); - - /** Swap contents between this and other. This function is guaranteed - to never fail or throw. - */ - void swap(SkString& other); + void reset(); + void resize(size_t len) { this->set(NULL, len); } + void set(const SkString& src) { *this = src; } + void set(const char text[]); + void set(const char text[], size_t len); + void setUTF16(const uint16_t[]); + void setUTF16(const uint16_t[], size_t len); + + void insert(size_t offset, const SkString& src) { this->insert(offset, src.c_str(), src.size()); } + void insert(size_t offset, const char text[]); + void insert(size_t offset, const char text[], size_t len); + void insertUnichar(size_t offset, SkUnichar); + void insertS32(size_t offset, int32_t value); + void insertS64(size_t offset, int64_t value, int minDigits = 0); + void insertHex(size_t offset, uint32_t value, int minDigits = 0); + void insertScalar(size_t offset, SkScalar); + + void append(const SkString& str) { this->insert((size_t)-1, str); } + void append(const char text[]) { this->insert((size_t)-1, text); } + void append(const char text[], size_t len) { this->insert((size_t)-1, text, len); } + void appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); } + void appendS32(int32_t value) { this->insertS32((size_t)-1, value); } + void appendS64(int64_t value, int minDigits = 0) { this->insertS64((size_t)-1, value, minDigits); } + void appendHex(uint32_t value, int minDigits = 0) { this->insertHex((size_t)-1, value, minDigits); } + void appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); } + + void prepend(const SkString& str) { this->insert(0, str); } + void prepend(const char text[]) { this->insert(0, text); } + void prepend(const char text[], size_t len) { this->insert(0, text, len); } + void prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); } + void prependS32(int32_t value) { this->insertS32(0, value); } + void prependS64(int32_t value, int minDigits = 0) { this->insertS64(0, value, minDigits); } + void prependHex(uint32_t value, int minDigits = 0) { this->insertHex(0, value, minDigits); } + void prependScalar(SkScalar value) { this->insertScalar((size_t)-1, value); } + + void printf(const char format[], ...); + void appendf(const char format[], ...); + void prependf(const char format[], ...); + + void remove(size_t offset, size_t length); + + /** + * Swap contents between this and other. This function is guaranteed + * to never fail or throw. + */ + void swap(SkString& other); private: struct Rec { @@ -185,6 +182,7 @@ public: /** This returns the number of ucs2 characters */ int count() const { return fCount; } + /** This returns a null terminated ucs2 string */ const uint16_t* getUCS2() const { return fUCS2; } diff --git a/include/core/SkUtils.h b/include/core/SkUtils.h index 7cb2066037..a346d48692 100644 --- a/include/core/SkUtils.h +++ b/include/core/SkUtils.h @@ -19,7 +19,7 @@ #include "SkTypes.h" -/////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// /** Similar to memset(), but it assigns a 16bit value into the buffer. @param buffer The memory to have value copied into it @@ -54,7 +54,7 @@ extern SkMemset16Proc sk_memset16; extern SkMemset32Proc sk_memset32; #endif -/////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// #define kMaxBytesInUTF8Sequence 4 @@ -64,8 +64,7 @@ extern SkMemset32Proc sk_memset32; #define SkUTF8_LeadByteToCount(c) ((((0xE5 << 24) >> ((unsigned)c >> 4 << 1)) & 3) + 1) #endif -inline int SkUTF8_CountUTF8Bytes(const char utf8[]) -{ +inline int SkUTF8_CountUTF8Bytes(const char utf8[]) { SkASSERT(utf8); return SkUTF8_LeadByteToCount(*(const uint8_t*)utf8); } |