2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : sipparameterheaderbase.h
17 * Interface : SDK API, SIP Codec API
25 #ifndef CSIPPARAMETERHEADERBASE_H
26 #define CSIPPARAMETERHEADERBASE_H
29 #include "sipheaderbase.h"
31 // FORWARD DECLARATIONS
32 class CSIPParamContainerBase;
39 * A base class for SIP headers that have structure
40 * "mandatory part"delimiter"parameters"
42 * This is an abstract class and cannot be instantiated.
46 class CSIPParameterHeaderBase : public CSIPHeaderBase
48 public: // Constructors and destructor
51 * Destructor, deletes the resources of CSIPParameterHeaderBase.
53 IMPORT_C virtual ~CSIPParameterHeaderBase();
56 public: // New functions
59 * Checks if a parameter is present
60 * @param aName the name of the parameter
61 * @return ETrue if present, otherwise EFalse
63 IMPORT_C TBool HasParam(RStringF aName) const;
66 * Gets a parameter value
67 * @pre HasParam(aName) == ETrue
68 * @param aName the name of the parameter
69 * @return the parameter value if present,
70 * otherwise a zero-length length value.
72 IMPORT_C RStringF ParamValue(RStringF aName) const;
75 * Sets a parameter with a value.
76 * Takes copies of the name and value,
77 * so if the RStringFs have been dynamically allocated,
78 * they can be closed if necessary after the function returns.
79 * @pre HasParam(aName) == EFalse
80 * @param aName the name of the parameter
81 * @param aValue the parameter value to set
83 IMPORT_C void SetParamL(RStringF aName, RStringF aValue);
86 * Sets a parameter without a value
87 * Takes copy of the name,
88 * so if the RStringF has been dynamically allocated,
89 * it can be closed if necessary after the function returns.
90 * @pre HasParam(aName) == EFalse
91 * @param aName the parameter name to set
93 IMPORT_C void SetParamL(RStringF aName);
97 * @param aName the parameter name to delete
99 IMPORT_C void DeleteParam(RStringF aName);
102 * Gets the count of header parameters
103 * @return count of header parameters
105 IMPORT_C TInt ParamCount() const;
108 * Gets a header parameter name by index.
109 * This function can be used when looping through
110 * all the header parameters.
111 * @param aIndex the index of the parameter
112 * @param aName copy of the parameter name that must be
113 * closed by the caller.
114 * @return KErrNotFound if aIndex is invalid. Otherwise EFalse.
116 IMPORT_C TInt Param(TInt aIndex, RStringF& aName) const;
118 public: // From CSIPHeaderBase
121 * From CSIPHeaderBase ToTextValueL
123 IMPORT_C HBufC8* ToTextValueL() const;
126 protected: // Contructors
128 CSIPParameterHeaderBase(const TChar& aSeparator);
130 protected: // New functions
132 void ParseL(const TDesC8& aValue,
133 TBool aIgnoreParenthesis=ETrue,
134 TBool aSkipSeparatorsBeforeAt=EFalse);
136 protected: // Virtual functions
141 virtual TBool ParamInsertionAllowed() const;
143 protected: // Pure virtual functions
148 virtual HBufC8* ToTextMandatoryPartLC() const = 0;
153 virtual void ParseMandatoryPartL(const TDesC8& aMandatoryPart) = 0;
158 virtual const CSIPParamContainerBase& Params() const = 0;
163 virtual CSIPParamContainerBase& Params() = 0;
165 private: // Contructors
167 CSIPParameterHeaderBase();
173 private: // For testing purposes
175 friend class CSIPParameterHeaderBaseTest;
179 #endif // CSIPPARAMETERHEADERBASE_H