/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * 
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Original Code is Komodo code.
 * 
 * The Initial Developer of the Original Code is ActiveState Software Inc.
 * Portions created by ActiveState Software Inc are Copyright (C) 2000-2007
 * ActiveState Software Inc. All Rights Reserved.
 * 
 * Contributor(s):
 *   ActiveState Software Inc
 * 
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"
#include "koIPrefs.idl"

/* A preference containing ordered subelements, addressable
   by an integer index.
   i.e. an array preference. */

[scriptable, uuid(956aabe1-79cb-4672-9e38-d6d646aca74b)]
interface koIOrderedPreference : koIPreferenceContainer {
  // Append a preference to the end of the collection.
  void appendPref(in koIPreferenceContainer pref);
  void appendString(in wstring pref);
  void appendLong(in long pref);
  void appendDouble(in double pref);
  void appendBoolean(in boolean pref);

  // Insert a preference at a particular index in the collection,
  // pushing elements to "the right" as necessary.
  void insertPref(in long index, in koIPreferenceContainer pref);
  void insertString(in long index, in wstring pref);
  void insertLong(in long index, in long pref);
  void insertDouble(in long index, in double pref);
  void insertBoolean(in long index, in boolean pref);
  
  // Retrieve a particular preference from the preference set.
  // It is an error to "get" a preference which does not exist or is of the
  // wrong type. Use "has*Pref" to ensure the pref exists.
  string getPrefType(in long index);
  koIPreferenceContainer getPref(in long index);
  wstring getString(in long index);
  long getLong(in long index);
  double getDouble(in long index);
  boolean getBoolean(in long index);

  // Utility methods for finding strings in an ordered preference, returns the
  // index at which the string was found, or -1 when not found.
  long findString(in wstring pref);
  long findStringFuzzy(in wstring pref);
  long findStringIgnoringCase(in wstring pref);
  // Utility methods for finding and deleting strings in an ordered preference,
  // returns true when the string found, or false when not found.
  boolean findAndDeleteString(in wstring pref);
  boolean findAndDeleteStringIgnoringCase(in wstring pref);

  // The number of preferences contained in the ordered collection.
  readonly attribute long length;

  // Remove a preference from the collection.
  void deletePref(in long index);
  // Reset to an empty preference collection.
  void reset();


  /***********************************************************************
   * @deprecated since Komodo 8.5
   * Use the shorter versions (appendString, insertString, etc...)
   */
  void appendStringPref(in wstring pref);
  void appendLongPref(in long pref);
  void appendDoublePref(in double pref);
  void appendBooleanPref(in boolean pref);

  void insertStringPref(in long index, in wstring pref);
  void insertLongPref(in long index, in long pref);
  void insertDoublePref(in long index, in double pref);
  void insertBooleanPref(in long index, in boolean pref);

  wstring getStringPref(in long index);
  long getLongPref(in long index);
  double getDoublePref(in long index);
  boolean getBooleanPref(in long index);

  boolean findAndDeleteStringPref(in wstring pref);
  boolean findAndDeleteStringPrefIgnoringCase(in wstring pref);
  long findStringPref(in wstring pref);
  long findStringPrefIgnoringCase(in wstring pref);
  /**********************************************************************/
};
