txStringUtils.h 948 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef txStringUtils_h__
  6. #define txStringUtils_h__
  7. #include "nsAString.h"
  8. #include "nsIAtom.h"
  9. #include "nsUnicharUtils.h"
  10. #include "nsContentUtils.h" // For ASCIIToLower().
  11. typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
  12. /**
  13. * Check equality between a string and an atom containing ASCII.
  14. */
  15. inline bool
  16. TX_StringEqualsAtom(const nsASingleFragmentString& aString, nsIAtom* aAtom)
  17. {
  18. return aAtom->Equals(aString);
  19. }
  20. inline already_AddRefed<nsIAtom>
  21. TX_ToLowerCaseAtom(nsIAtom* aAtom)
  22. {
  23. nsAutoString str;
  24. aAtom->ToString(str);
  25. nsContentUtils::ASCIIToLower(str);
  26. return NS_Atomize(str);
  27. }
  28. #endif // txStringUtils_h__