michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsAtomService.h" michael@0: #include "nsIAtom.h" michael@0: michael@0: NS_IMPL_ISUPPORTS(nsAtomService, nsIAtomService) michael@0: michael@0: nsAtomService::nsAtomService() michael@0: { michael@0: } michael@0: michael@0: nsresult michael@0: nsAtomService::GetAtom(const nsAString& aString, nsIAtom ** aResult) michael@0: { michael@0: *aResult = NS_NewAtom(aString).take(); michael@0: michael@0: if (!*aResult) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: nsAtomService::GetPermanentAtom(const nsAString& aString, nsIAtom ** aResult) michael@0: { michael@0: *aResult = NS_NewPermanentAtom(aString); michael@0: michael@0: if (!*aResult) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAtomService::GetAtomUTF8(const char *aValue, nsIAtom* *aResult) michael@0: { michael@0: *aResult = NS_NewAtom(aValue).take(); michael@0: michael@0: if (!*aResult) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAtomService::GetPermanentAtomUTF8(const char *aValue, nsIAtom* *aResult) michael@0: { michael@0: *aResult = NS_NewPermanentAtom(NS_ConvertUTF8toUTF16(aValue)); michael@0: michael@0: if (!*aResult) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: michael@0: return NS_OK; michael@0: }