Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Unified Diff: third_party/WebKit/Source/wtf/text/StringConcatenate.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/text/StringConcatenate.h
diff --git a/third_party/WebKit/Source/wtf/text/StringConcatenate.h b/third_party/WebKit/Source/wtf/text/StringConcatenate.h
index 70bb0bdef297a982508ffb24bb7687ac0fef1574..98bdd25bfe2eed0a5c661e85bd02faf604ef7bfb 100644
--- a/third_party/WebKit/Source/wtf/text/StringConcatenate.h
+++ b/third_party/WebKit/Source/wtf/text/StringConcatenate.h
@@ -41,317 +41,298 @@
namespace WTF {
-template<typename StringType>
+template <typename StringType>
class StringTypeAdapter {
- DISALLOW_NEW();
+ DISALLOW_NEW();
};
-template<>
+template <>
class StringTypeAdapter<char> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<char>(char buffer)
- : m_buffer(buffer)
- {
- }
+ DISALLOW_NEW();
- unsigned length() { return 1; }
+ public:
+ StringTypeAdapter<char>(char buffer) : m_buffer(buffer) {}
- bool is8Bit() { return true; }
+ unsigned length() { return 1; }
- void writeTo(LChar* destination)
- {
- *destination = m_buffer;
- }
+ bool is8Bit() { return true; }
- void writeTo(UChar* destination) { *destination = m_buffer; }
+ void writeTo(LChar* destination) { *destination = m_buffer; }
-private:
- unsigned char m_buffer;
+ void writeTo(UChar* destination) { *destination = m_buffer; }
+
+ private:
+ unsigned char m_buffer;
};
-template<>
+template <>
class StringTypeAdapter<LChar> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<LChar>(LChar buffer)
- : m_buffer(buffer)
- {
- }
+ DISALLOW_NEW();
+
+ public:
+ StringTypeAdapter<LChar>(LChar buffer) : m_buffer(buffer) {}
- unsigned length() { return 1; }
+ unsigned length() { return 1; }
- bool is8Bit() { return true; }
+ bool is8Bit() { return true; }
- void writeTo(LChar* destination)
- {
- *destination = m_buffer;
- }
+ void writeTo(LChar* destination) { *destination = m_buffer; }
- void writeTo(UChar* destination) { *destination = m_buffer; }
+ void writeTo(UChar* destination) { *destination = m_buffer; }
-private:
- LChar m_buffer;
+ private:
+ LChar m_buffer;
};
-template<>
+template <>
class StringTypeAdapter<UChar> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<UChar>(UChar buffer)
- : m_buffer(buffer)
- {
- }
+ DISALLOW_NEW();
- unsigned length() { return 1; }
+ public:
+ StringTypeAdapter<UChar>(UChar buffer) : m_buffer(buffer) {}
- bool is8Bit() { return m_buffer <= 0xff; }
+ unsigned length() { return 1; }
- void writeTo(LChar* destination)
- {
- ASSERT(is8Bit());
- *destination = static_cast<LChar>(m_buffer);
- }
+ bool is8Bit() { return m_buffer <= 0xff; }
- void writeTo(UChar* destination) { *destination = m_buffer; }
+ void writeTo(LChar* destination) {
+ ASSERT(is8Bit());
+ *destination = static_cast<LChar>(m_buffer);
+ }
-private:
- UChar m_buffer;
+ void writeTo(UChar* destination) { *destination = m_buffer; }
+
+ private:
+ UChar m_buffer;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<char*> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<char*>(char* buffer)
- : m_buffer(buffer)
- , m_length(strlen(buffer))
- {
- }
+ DISALLOW_NEW();
+
+ public:
+ StringTypeAdapter<char*>(char* buffer)
+ : m_buffer(buffer), m_length(strlen(buffer)) {}
- unsigned length() { return m_length; }
+ unsigned length() { return m_length; }
- bool is8Bit() { return true; }
+ bool is8Bit() { return true; }
- void writeTo(LChar* destination);
+ void writeTo(LChar* destination);
- void writeTo(UChar* destination);
+ void writeTo(UChar* destination);
-private:
- const char* m_buffer;
- unsigned m_length;
+ private:
+ const char* m_buffer;
+ unsigned m_length;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<LChar*> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<LChar*>(LChar* buffer);
+ DISALLOW_NEW();
- unsigned length() { return m_length; }
+ public:
+ StringTypeAdapter<LChar*>(LChar* buffer);
- bool is8Bit() { return true; }
+ unsigned length() { return m_length; }
- void writeTo(LChar* destination);
+ bool is8Bit() { return true; }
- void writeTo(UChar* destination);
+ void writeTo(LChar* destination);
-private:
- const LChar* m_buffer;
- unsigned m_length;
+ void writeTo(UChar* destination);
+
+ private:
+ const LChar* m_buffer;
+ unsigned m_length;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<const UChar*> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter(const UChar* buffer);
+ DISALLOW_NEW();
+
+ public:
+ StringTypeAdapter(const UChar* buffer);
- unsigned length() { return m_length; }
+ unsigned length() { return m_length; }
- bool is8Bit() { return false; }
+ bool is8Bit() { return false; }
- NO_RETURN_DUE_TO_CRASH void writeTo(LChar*)
- {
- RELEASE_ASSERT(false);
- }
+ NO_RETURN_DUE_TO_CRASH void writeTo(LChar*) { RELEASE_ASSERT(false); }
- void writeTo(UChar* destination);
+ void writeTo(UChar* destination);
-private:
- const UChar* m_buffer;
- unsigned m_length;
+ private:
+ const UChar* m_buffer;
+ unsigned m_length;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<const char*> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<const char*>(const char* buffer);
+ DISALLOW_NEW();
- unsigned length() { return m_length; }
+ public:
+ StringTypeAdapter<const char*>(const char* buffer);
- bool is8Bit() { return true; }
+ unsigned length() { return m_length; }
- void writeTo(LChar* destination);
+ bool is8Bit() { return true; }
- void writeTo(UChar* destination);
+ void writeTo(LChar* destination);
-private:
- const char* m_buffer;
- unsigned m_length;
+ void writeTo(UChar* destination);
+
+ private:
+ const char* m_buffer;
+ unsigned m_length;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<const LChar*> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<const LChar*>(const LChar* buffer);
+ DISALLOW_NEW();
+
+ public:
+ StringTypeAdapter<const LChar*>(const LChar* buffer);
- unsigned length() { return m_length; }
+ unsigned length() { return m_length; }
- bool is8Bit() { return true; }
+ bool is8Bit() { return true; }
- void writeTo(LChar* destination);
+ void writeTo(LChar* destination);
- void writeTo(UChar* destination);
+ void writeTo(UChar* destination);
-private:
- const LChar* m_buffer;
- unsigned m_length;
+ private:
+ const LChar* m_buffer;
+ unsigned m_length;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<Vector<char>> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<Vector<char>>(const Vector<char>& buffer)
- : m_buffer(buffer)
- {
- }
+ DISALLOW_NEW();
- size_t length() { return m_buffer.size(); }
+ public:
+ StringTypeAdapter<Vector<char>>(const Vector<char>& buffer)
+ : m_buffer(buffer) {}
- bool is8Bit() { return true; }
+ size_t length() { return m_buffer.size(); }
- void writeTo(LChar* destination);
+ bool is8Bit() { return true; }
- void writeTo(UChar* destination);
+ void writeTo(LChar* destination);
-private:
- const Vector<char>& m_buffer;
+ void writeTo(UChar* destination);
+
+ private:
+ const Vector<char>& m_buffer;
};
-template<>
+template <>
class StringTypeAdapter<Vector<LChar>> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<Vector<LChar>>(const Vector<LChar>& buffer)
- : m_buffer(buffer)
- {
- }
+ DISALLOW_NEW();
+
+ public:
+ StringTypeAdapter<Vector<LChar>>(const Vector<LChar>& buffer)
+ : m_buffer(buffer) {}
- size_t length() { return m_buffer.size(); }
+ size_t length() { return m_buffer.size(); }
- bool is8Bit() { return true; }
+ bool is8Bit() { return true; }
- void writeTo(LChar* destination);
+ void writeTo(LChar* destination);
- void writeTo(UChar* destination);
+ void writeTo(UChar* destination);
-private:
- const Vector<LChar>& m_buffer;
+ private:
+ const Vector<LChar>& m_buffer;
};
-template<>
+template <>
class WTF_EXPORT StringTypeAdapter<String> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<String>(const String& string)
- : m_buffer(string)
- {
- }
+ DISALLOW_NEW();
- unsigned length() { return m_buffer.length(); }
+ public:
+ StringTypeAdapter<String>(const String& string) : m_buffer(string) {}
- bool is8Bit() { return m_buffer.isNull() || m_buffer.is8Bit(); }
+ unsigned length() { return m_buffer.length(); }
- void writeTo(LChar* destination);
+ bool is8Bit() { return m_buffer.isNull() || m_buffer.is8Bit(); }
- void writeTo(UChar* destination);
+ void writeTo(LChar* destination);
-private:
- const String& m_buffer;
+ void writeTo(UChar* destination);
+
+ private:
+ const String& m_buffer;
};
-template<>
+template <>
class StringTypeAdapter<AtomicString> {
- DISALLOW_NEW();
-public:
- StringTypeAdapter<AtomicString>(const AtomicString& string)
- : m_adapter(string.string())
- {
- }
+ DISALLOW_NEW();
+
+ public:
+ StringTypeAdapter<AtomicString>(const AtomicString& string)
+ : m_adapter(string.string()) {}
- unsigned length() { return m_adapter.length(); }
+ unsigned length() { return m_adapter.length(); }
- bool is8Bit() { return m_adapter.is8Bit(); }
+ bool is8Bit() { return m_adapter.is8Bit(); }
- void writeTo(LChar* destination) { m_adapter.writeTo(destination); }
- void writeTo(UChar* destination) { m_adapter.writeTo(destination); }
+ void writeTo(LChar* destination) { m_adapter.writeTo(destination); }
+ void writeTo(UChar* destination) { m_adapter.writeTo(destination); }
-private:
- StringTypeAdapter<String> m_adapter;
+ private:
+ StringTypeAdapter<String> m_adapter;
};
-inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow)
-{
- unsigned oldTotal = total;
- total = oldTotal + addend;
- if (total < oldTotal)
- overflow = true;
+inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow) {
+ unsigned oldTotal = total;
+ total = oldTotal + addend;
+ if (total < oldTotal)
+ overflow = true;
}
-template<typename StringType1, typename StringType2>
-PassRefPtr<StringImpl> makeString(StringType1 string1, StringType2 string2)
-{
- StringTypeAdapter<StringType1> adapter1(string1);
- StringTypeAdapter<StringType2> adapter2(string2);
-
- bool overflow = false;
- unsigned length = adapter1.length();
- sumWithOverflow(length, adapter2.length(), overflow);
- if (overflow)
- return nullptr;
-
- if (adapter1.is8Bit() && adapter2.is8Bit()) {
- LChar* buffer;
- RefPtr<StringImpl> resultImpl = StringImpl::createUninitialized(length, buffer);
- if (!resultImpl)
- return nullptr;
-
- LChar* result = buffer;
- adapter1.writeTo(result);
- result += adapter1.length();
- adapter2.writeTo(result);
-
- return resultImpl.release();
- }
-
- UChar* buffer;
- RefPtr<StringImpl> resultImpl = StringImpl::createUninitialized(length, buffer);
+template <typename StringType1, typename StringType2>
+PassRefPtr<StringImpl> makeString(StringType1 string1, StringType2 string2) {
+ StringTypeAdapter<StringType1> adapter1(string1);
+ StringTypeAdapter<StringType2> adapter2(string2);
+
+ bool overflow = false;
+ unsigned length = adapter1.length();
+ sumWithOverflow(length, adapter2.length(), overflow);
+ if (overflow)
+ return nullptr;
+
+ if (adapter1.is8Bit() && adapter2.is8Bit()) {
+ LChar* buffer;
+ RefPtr<StringImpl> resultImpl =
+ StringImpl::createUninitialized(length, buffer);
if (!resultImpl)
- return nullptr;
+ return nullptr;
- UChar* result = buffer;
+ LChar* result = buffer;
adapter1.writeTo(result);
result += adapter1.length();
adapter2.writeTo(result);
return resultImpl.release();
+ }
+
+ UChar* buffer;
+ RefPtr<StringImpl> resultImpl =
+ StringImpl::createUninitialized(length, buffer);
+ if (!resultImpl)
+ return nullptr;
+
+ UChar* result = buffer;
+ adapter1.writeTo(result);
+ result += adapter1.length();
+ adapter2.writeTo(result);
+
+ return resultImpl.release();
}
-} // namespace WTF
+} // namespace WTF
#include "wtf/text/StringOperators.h"
#endif
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringBuilderTest.cpp ('k') | third_party/WebKit/Source/wtf/text/StringConcatenate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698