Return-Path: Delivered-To: apmail-ws-axis-c-dev-archive@www.apache.org Received: (qmail 17296 invoked from network); 1 Jun 2004 08:10:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Jun 2004 08:10:07 -0000 Received: (qmail 40095 invoked by uid 500); 1 Jun 2004 08:10:01 -0000 Delivered-To: apmail-ws-axis-c-dev-archive@ws.apache.org Received: (qmail 40068 invoked by uid 500); 1 Jun 2004 08:10:00 -0000 Mailing-List: contact axis-c-dev-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: List-Id: "Apache AXIS C Developers List" Reply-To: "Apache AXIS C Developers List" Delivered-To: mailing list axis-c-dev@ws.apache.org Received: (qmail 40047 invoked by uid 99); 1 Jun 2004 08:10:00 -0000 Received: from [209.68.1.20] (HELO relay.pair.com) (209.68.1.20) by apache.org (qpsmtpd/0.27.1) with SMTP; Tue, 01 Jun 2004 01:10:00 -0700 Received: (qmail 37557 invoked from network); 1 Jun 2004 08:09:21 -0000 Received: from 54.251.adsl.sltnet.lk (HELO Roshan.opensource.lk) (220.247.251.54) by relay.pair.com with SMTP; 1 Jun 2004 08:09:21 -0000 X-pair-Authenticated: 220.247.251.54 Message-Id: <5.0.0.25.2.20040601135638.00bcb1e0@opensource.lk> X-Sender: roshan@opensource.lk X-Mailer: QUALCOMM Windows Eudora Version 5.0 Date: Tue, 01 Jun 2004 14:09:19 +0600 To: "Apache AXIS C Developers List" From: Roshan Weerasuriya Subject: RE: STL elimination - Suggestions In-Reply-To: <7D5800A5B6E26644B2EB7A862856B0D410EAC13F@SARASWATI> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_19442817==_" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii"; format=flowed hi all, Please have a look at the AxisMap class implemented below and provide your comments. The implementation files are attached with this mail. The attachement includes: 1) AxisMap.h, AxisMap.cpp //AxisMap implemntaion 2) AxisMapUtils.h, AxisMapUtils.cpp //Utility methods such as Standard De-allocator funcitons 3) TestMap3.cpp //The sample cpp file which includes example usage of the above AxisMap implementation The idea is to eliminate stl map from the code base and use Axis's own AxisMap implementation. rgds, Roshan At 10:13 AM 5/6/2004 +0530, you wrote: >What I would suggest - >1. expose a small set of classes and make the interface stl-free >2. in your internal classes you can still use stl > >Why do you want to remove stl all-together? > > > -----Original Message----- > > From: Kenneth Chiu [mailto:chiuk@cs.indiana.edu] > > Sent: Thursday, May 06, 2004 9:41 AM > > To: Apache AXIS C Developers List --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="map_test.dsp" # Microsoft Developer Studio Project File - Name="map_test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=map_test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "map_test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "map_test.mak" CFG="map_test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "map_test - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "map_test - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "map_test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "map_test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "map_test - Win32 Release" # Name "map_test - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\AxisMap.cpp # End Source File # Begin Source File SOURCE=.\AxisMapUtils.cpp # End Source File # Begin Source File SOURCE=.\TestMap3.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\AxisMap.h # End Source File # Begin Source File SOURCE=.\AxisMapUtils.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="map_test.dsw" Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "map_test"=".\map_test.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="TestMap3.cpp" #include "AxisMap.h" #include "AxisMapUtils.h" #include class My_Test_Class { public: My_Test_Class(int iNo) { iEmpNo = iNo; } ~My_Test_Class() { cout<<"In the descructor of My_Test_Class"< #include #include ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// AxisMap::AxisMap(bool (*pCompareFunction) (void* pKey1, void* pKey2), void (*pKeyDeallocFunction) (void* pObjPointer), void (*pValueDeallocFunction) (void* pObjPointer)) { m_iCapasity = 10; m_iCurrentPosition = 0; m_pKeys = (void**) malloc(sizeof(void*) * m_iCapasity); m_pValues = (void**) malloc(sizeof(void*) * m_iCapasity); this->pCompareFunction = pCompareFunction; this->pKeyDeallocFunction = pKeyDeallocFunction; this->pValueDeallocFunction = pValueDeallocFunction; m_iNextKeyPos = 0; m_iNextValuePos = 0; } AxisMap::~AxisMap() { for (int iInd=0; iInd < m_iCurrentPosition; iInd++) { pKeyDeallocFunction(m_pKeys[iInd]); //delete m_pKeys[iInd]; m_pKeys[iInd] = NULL; } for (iInd=0; iInd < m_iCurrentPosition; iInd++) { pValueDeallocFunction(m_pValues[iInd]); //delete m_pValues[iInd]; m_pValues[iInd] = NULL; } free(m_pKeys); free(m_pValues); m_pKeys = NULL; m_pValues = NULL; } int AxisMap::put(void *pKey, void *pValue) { if (m_iCurrentPosition == m_iCapasity ) { m_iCapasity += 10; m_pKeys = (void**) realloc(m_pKeys, sizeof(void*) * m_iCapasity); } bool bKeyFoundStatus = false; for (int i=0; i < m_iCurrentPosition; i++) { if (m_pKeys[i]) { if (pCompareFunction(pKey, m_pKeys[i])) { bKeyFoundStatus = true; /* *Clearing the memory of the current value, if a current value is available. */ if (m_pValues[i]) { delete m_pValues[i]; m_pValues[i] = NULL; } m_pValues[i] = pValue; } } } if (!bKeyFoundStatus) { m_pKeys[m_iCurrentPosition] = pKey; m_pValues[m_iCurrentPosition] = pValue; } m_iCurrentPosition++; return 1; } void* AxisMap::get(void *pKey) { bool bKeyFoundStatus = false; for (int i=0; i < m_iCurrentPosition; i++) { if (m_pKeys[i]) { if (pCompareFunction(pKey, m_pKeys[i])) { bKeyFoundStatus = true; return m_pValues[i]; } } } if (!bKeyFoundStatus) { return NULL; } return NULL; } int AxisMap::remove(void *pKey) { bool bKeyFoundStatus = false; int iRemovedPosition = 0; for (int i=0; i < m_iCurrentPosition; i++) { if (m_pKeys[i]) { if (pCompareFunction(pKey, m_pKeys[i])) { bKeyFoundStatus = true; iRemovedPosition = i; pKeyDeallocFunction(m_pKeys[i]); //delete m_pKeys[i]; pValueDeallocFunction(m_pValues[i]); //delete m_pValues[i]; m_pKeys[i] = NULL; m_pValues[i] = NULL; break; } } } if (!bKeyFoundStatus) { return 0; //fail } else { int iStopPositon = m_iCurrentPosition-1; for (int iPos = iRemovedPosition; iPos < iStopPositon; iPos++) { m_pKeys[iPos] = m_pKeys[iPos+1]; m_pValues[iPos] = m_pValues[iPos+1]; } m_pKeys[iStopPositon] = NULL; m_pValues[iStopPositon] = NULL; m_iCurrentPosition--; return 1; //success } } void* AxisMap::getNextKey() { if (m_iNextKeyPos < m_iCurrentPosition) { return m_pKeys[m_iNextKeyPos++]; } else { return NULL; } } void* AxisMap::getNextValue() { if (m_iNextValuePos < m_iCurrentPosition) { return m_pValues[m_iNextValuePos++]; } else { return NULL; } } int AxisMap::setNextKeyPositoin(int iPos) { if (iPos 1000 #pragma once #endif // _MSC_VER > 1000 class AxisMap { public: /** * resets the next value positoin to 0, so that when the user calls * getNextValue(), it starts to get the value from 0 position. */ void resetNextValuePositoin(); /** * resets the next key positoin to 0, so that when the user calls * getNextKey(), it starts to get the key from 0 position. Users has * to call this method before a new Next option round is used, because * otherwise it might start the Next pointer from a previousley stoped * position. */ void resetNextKeyPositoin(); /** * Checks and returns whether there is any next value from the current * position. The current position is maintained internaly and is * incremented by one location for each getNextValue() call. */ bool hasNextValues(); /** * Checks and returns whether there is any next key from the current * position. The current position is maintained internaly and is * incremented by one location for each getNextKey() call. */ bool hasNextKeys(); /** * Sets the next value positon. This positon is used internaly when the * user calls getNextValue(). getNextValue() will use this setted position. */ int setNextValuePositoin(int iPos=0); /** * Sets the next key positon. This positon is used internaly when the * user calls getNextKey(). getNextKey() will use this setted position. */ int setNextKeyPositoin(int iPos=0); /** * Gets the next value. This method is used to traverse through the values * of the map. */ void* getNextValue(); /** * Gets the next key. This method is used to traverse through the keys * of the map. */ void* getNextKey(); int remove(void* pKey); /** * Gets the Value of the given key. */ void* get(void* pKey); /** * Puts the Value of the given key to the map. */ int put(void* pKey, void* pValue); AxisMap(bool (*pCompareFunction) (void* pKey1, void* pKey2), void (*pKeyDeallocFunction) (void* pObjPointer), void (*pValueDeallocFunction) (void* pObjPointer)); virtual ~AxisMap(); private: int m_iCapasity; int m_iCurrentPosition; void** m_pKeys; void** m_pValues; bool (*pCompareFunction) (void* pKey1, void* pKey2); void (*pKeyDeallocFunction) (void* pObjPointer); void (*pValueDeallocFunction) (void* pObjPointer); int m_iNextKeyPos; int m_iNextValuePos; }; #endif // !defined(AFX_AXISMAP_H__33E1C2B8_BEB6_48CD_93BE_78CD2D846ED9__INCLUDED_) --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="AxisMapUtils.cpp" /* * Copyright 2003-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com) * */ // AxisMapUtils.cpp: implementation of the AxisMapUtils class. // ////////////////////////////////////////////////////////////////////// #include "AxisMapUtils.h" #include ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// AxisMapUtils::AxisMapUtils() { } AxisMapUtils::~AxisMapUtils() { } bool AxisMapUtils::compareInt(void *pKey1, void *pKey2) { int iKey1 = *(int*)pKey1; int iKey2 = *(int*)pKey2; if (iKey1 == iKey2) { return true; } else { return false; } } void AxisMapUtils::deallocInt(void *pIntPointer) { int* piIntPointer = (int*) pIntPointer; delete piIntPointer; piIntPointer = NULL; } --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="AxisMapUtils.h" /* * Copyright 2003-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com) * */ // AxisMapUtils.h: interface for the AxisMapUtils class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_AXISMAPUTILS_H__AF6E98CD_0ECB_4D91_BD9C_214289F83686__INCLUDED_) #define AFX_AXISMAPUTILS_H__AF6E98CD_0ECB_4D91_BD9C_214289F83686__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class AxisMapUtils { public: static void deallocInt(void* pObjPointer); /** * Standard compare function for int */ static bool compareInt(void* pKey1, void* pKey2); AxisMapUtils(); virtual ~AxisMapUtils(); }; #endif // !defined(AFX_AXISMAPUTILS_H__AF6E98CD_0ECB_4D91_BD9C_214289F83686__INCLUDED_) --=====================_19442817==_ Content-Type: text/plain; charset="us-ascii"; format=flowed --=====================_19442817==_--