xpcom/ds/nsAtomService.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/ds/nsAtomService.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsAtomService.h"
    1.10 +#include "nsIAtom.h"
    1.11 +
    1.12 +NS_IMPL_ISUPPORTS(nsAtomService, nsIAtomService)
    1.13 +
    1.14 +nsAtomService::nsAtomService()
    1.15 +{
    1.16 +}
    1.17 +
    1.18 +nsresult
    1.19 +nsAtomService::GetAtom(const nsAString& aString, nsIAtom ** aResult)
    1.20 +{
    1.21 +  *aResult = NS_NewAtom(aString).take();
    1.22 +
    1.23 +  if (!*aResult)
    1.24 +    return NS_ERROR_OUT_OF_MEMORY;
    1.25 +  
    1.26 +  return NS_OK;
    1.27 +}
    1.28 +
    1.29 +nsresult
    1.30 +nsAtomService::GetPermanentAtom(const nsAString& aString, nsIAtom ** aResult)
    1.31 +{
    1.32 +  *aResult = NS_NewPermanentAtom(aString);
    1.33 +
    1.34 +  if (!*aResult)
    1.35 +    return NS_ERROR_OUT_OF_MEMORY;
    1.36 +  
    1.37 +  return NS_OK;
    1.38 +}
    1.39 +
    1.40 +NS_IMETHODIMP
    1.41 +nsAtomService::GetAtomUTF8(const char *aValue, nsIAtom* *aResult)
    1.42 +{
    1.43 +    *aResult = NS_NewAtom(aValue).take();
    1.44 +
    1.45 +    if (!*aResult)
    1.46 +        return NS_ERROR_OUT_OF_MEMORY;
    1.47 +
    1.48 +    return NS_OK;
    1.49 +}
    1.50 +
    1.51 +NS_IMETHODIMP
    1.52 +nsAtomService::GetPermanentAtomUTF8(const char *aValue, nsIAtom* *aResult)
    1.53 +{
    1.54 +    *aResult = NS_NewPermanentAtom(NS_ConvertUTF8toUTF16(aValue));
    1.55 +
    1.56 +    if (!*aResult)
    1.57 +        return NS_ERROR_OUT_OF_MEMORY;
    1.58 +
    1.59 +    return NS_OK;
    1.60 +}

mercurial