Back to index

lightning-sunbird  0.9+nobinonly
nsAbBooleanExpression.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Sun Microsystems, Inc.
00019  * Portions created by the Initial Developer are Copyright (C) 2001
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Created by: Paul Sandoz   <paul.sandoz@sun.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "nsAbBooleanExpression.h"
00040 #include "nsReadableUtils.h"
00041 
00042 NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbBooleanConditionString, nsIAbBooleanConditionString)
00043 
00044 nsAbBooleanConditionString::nsAbBooleanConditionString() :
00045     mCondition (nsIAbBooleanConditionTypes::Exists)
00046 {
00047 }
00048 
00049 nsAbBooleanConditionString::~nsAbBooleanConditionString()
00050 {
00051 }
00052 
00053 /* attribute nsAbBooleanConditionType condition; */
00054 NS_IMETHODIMP nsAbBooleanConditionString::GetCondition(nsAbBooleanConditionType *aCondition)
00055 {
00056     if (!aCondition)
00057         return NS_ERROR_NULL_POINTER;
00058 
00059     *aCondition = mCondition;
00060 
00061     return NS_OK;
00062 }
00063 NS_IMETHODIMP nsAbBooleanConditionString::SetCondition(nsAbBooleanConditionType aCondition)
00064 {
00065     mCondition = aCondition;
00066 
00067     return NS_OK;
00068 }
00069 
00070 /* attribute string name; */
00071 NS_IMETHODIMP nsAbBooleanConditionString::GetName(char** aName)
00072 {
00073     if (!aName)
00074         return NS_ERROR_NULL_POINTER;
00075 
00076     *aName = mName.IsEmpty() ? 0 : ToNewCString(mName);
00077 
00078     return NS_OK;
00079 
00080 }
00081 NS_IMETHODIMP nsAbBooleanConditionString::SetName(const char* aName)
00082 {
00083     if (!aName)
00084         return NS_ERROR_NULL_POINTER;
00085 
00086     mName = aName;
00087 
00088     return NS_OK;
00089 }
00090 
00091 /* attribute wstring value; */
00092 NS_IMETHODIMP nsAbBooleanConditionString::GetValue(PRUnichar** aValue)
00093 {
00094     if (!aValue)
00095         return NS_ERROR_NULL_POINTER;
00096 
00097     *aValue = ToNewUnicode(mValue);
00098 
00099     return NS_OK;
00100 }
00101 NS_IMETHODIMP nsAbBooleanConditionString::SetValue(const PRUnichar * aValue)
00102 {
00103     if (!aValue)
00104         return NS_ERROR_NULL_POINTER;
00105 
00106     mValue = aValue;
00107 
00108     return NS_OK;
00109 }
00110 
00111 NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbBooleanExpression, nsIAbBooleanExpression)
00112 
00113 nsAbBooleanExpression::nsAbBooleanExpression() :
00114     mOperation (nsIAbBooleanOperationTypes::AND)
00115 {
00116 }
00117 
00118 nsAbBooleanExpression::~nsAbBooleanExpression()
00119 {
00120 }
00121 
00122 /* attribute nsAbBooleanOperationType operation; */
00123 NS_IMETHODIMP nsAbBooleanExpression::GetOperation(nsAbBooleanOperationType *aOperation)
00124 {
00125     if (!aOperation)
00126         return NS_ERROR_NULL_POINTER;
00127 
00128     *aOperation = mOperation;
00129 
00130     return NS_OK;
00131 }
00132 NS_IMETHODIMP nsAbBooleanExpression::SetOperation(nsAbBooleanOperationType aOperation)
00133 {
00134     mOperation = aOperation;
00135 
00136     return NS_OK;
00137 }
00138 
00139 /* attribute nsISupportsArray expressions; */
00140 NS_IMETHODIMP nsAbBooleanExpression::GetExpressions(nsISupportsArray** aExpressions)
00141 {
00142     if (!aExpressions)
00143         return NS_ERROR_NULL_POINTER;
00144 
00145     if (!mExpressions)
00146         NS_NewISupportsArray(getter_AddRefs(mExpressions));
00147 
00148     NS_IF_ADDREF(*aExpressions = mExpressions);
00149     return NS_OK;
00150 }
00151 
00152 NS_IMETHODIMP nsAbBooleanExpression::SetExpressions(nsISupportsArray* aExpressions)
00153 {
00154     if (!aExpressions)
00155         return NS_ERROR_NULL_POINTER;
00156 
00157     mExpressions = aExpressions;
00158 
00159     return NS_OK;
00160 }
00161 
00162 /* void asetExpressions (in unsigned long aExpressionsSize, [array, size_is (aExpressionsSize)] in nsISupports aExpressionsArray); */
00163 NS_IMETHODIMP nsAbBooleanExpression::AsetExpressions(PRUint32 aExpressionsSize, nsISupports **aExpressionsArray)
00164 {
00165     return NS_ERROR_NOT_IMPLEMENTED;
00166 }
00167 
00168 /* void agetExpressions (out unsigned long aExpressionsSize, [array, size_is (aExpressionsSize), retval] out nsISupports aExpressionsArray); */
00169 NS_IMETHODIMP nsAbBooleanExpression::AgetExpressions(PRUint32 *aExpressionsSize, nsISupports ***aExpressionsArray)
00170 {
00171     return NS_ERROR_NOT_IMPLEMENTED;
00172 }
00173