X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/1df5f87f1309a8daa30dabdee855f48ae40d14ab..6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174:/wtf/text/StringOperators.h?ds=inline diff --git a/wtf/text/StringOperators.h b/wtf/text/StringOperators.h deleted file mode 100644 index e8c2181..0000000 --- a/wtf/text/StringOperators.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. - * Copyright (C) Research In Motion Limited 2011. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#ifndef StringOperators_h -#define StringOperators_h - -namespace WTF { - -template -class StringAppend { -public: - StringAppend(StringType1 string1, StringType2 string2) - : m_string1(string1) - , m_string2(string2) - { - } - - operator String() const - { - RefPtr resultImpl = tryMakeString(m_string1, m_string2); - if (!resultImpl) - CRASH(); - return resultImpl.release(); - } - - operator AtomicString() const - { - return operator String(); - } - - void writeTo(UChar* destination) - { - StringTypeAdapter adapter1(m_string1); - StringTypeAdapter adapter2(m_string2); - adapter1.writeTo(destination); - adapter2.writeTo(destination + adapter1.length()); - } - - unsigned length() - { - StringTypeAdapter adapter1(m_string1); - StringTypeAdapter adapter2(m_string2); - return adapter1.length() + adapter2.length(); - } - -private: - StringType1 m_string1; - StringType2 m_string2; -}; - -template -class StringTypeAdapter > { -public: - StringTypeAdapter >(StringAppend& buffer) - : m_buffer(buffer) - { - } - - unsigned length() { return m_buffer.length(); } - void writeTo(UChar* destination) { m_buffer.writeTo(destination); } - -private: - StringAppend& m_buffer; -}; - -inline StringAppend operator+(const char* string1, const String& string2) -{ - return StringAppend(string1, string2); -} - -inline StringAppend operator+(const char* string1, const AtomicString& string2) -{ - return StringAppend(string1, string2); -} - -template -StringAppend operator+(const String& string1, T string2) -{ - return StringAppend(string1, string2); -} - -template -StringAppend > operator+(U string1, const StringAppend& string2) -{ - return StringAppend >(string1, string2); -} - -} // namespace WTF - -#endif // StringOperators_h