Home | History | Annotate | Download | only in style
      1 /**
      2  * Copyright (C) 2011 Nokia Inc.  All rights reserved.
      3  *
      4  * This library is free software; you can redistribute it and/or
      5  * modify it under the terms of the GNU Library General Public
      6  * License as published by the Free Software Foundation; either
      7  * version 2 of the License, or (at your option) any later version.
      8  *
      9  * This library is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12  * Library General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU Library General Public License
     15  * along with this library; see the file COPYING.LIB.  If not, write to
     16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     17  * Boston, MA 02110-1301, USA.
     18  *
     19  */
     20 
     21 #include "config.h"
     22 #include "QuotesData.h"
     23 
     24 namespace WebCore {
     25 
     26 QuotesData* QuotesData::create(int stringCount)
     27 {
     28     char* tmp = new char[sizeof(QuotesData)+sizeof(String)*stringCount];
     29     if (!tmp)
     30         return 0;
     31     new (tmp) QuotesData(stringCount);
     32     for (int i = 0; i < stringCount; ++i)
     33         new (tmp +sizeof(QuotesData) + sizeof(String)*i) String();
     34     return reinterpret_cast<QuotesData*>(tmp);
     35 }
     36 
     37 bool QuotesData::operator==(const QuotesData& other) const
     38 {
     39     if (this == &other)
     40         return true;
     41     if (!&other || !this)
     42         return false;
     43     if (length != other.length)
     44         return false;
     45     const String* myData = data();
     46     const String* otherData = other.data();
     47     for (int i = length-1; i >= 0; --i)
     48         if (myData[i] != otherData[i])
     49             return false;
     50     return true;
     51 }
     52 
     53 QuotesData::~QuotesData()
     54 {
     55     String* p = data();
     56     for (int i = 0; i < length; ++i)
     57         p[i].~String();
     58 }
     59 
     60 } // namespace WebCore
     61