Boost logo

Boost :

From: mahesh karanth (tumkurkaranth_at_[hidden])
Date: 2006-04-27 06:15:12


1.URLHandler class which uses Boost.Regex

#ifndef _URLHANDLER_
#define _URLHANDLER_

#if !defined(NDEBUG)
#endif
//#include <boost/regex/v4/regex.hpp>
#include <boost/regex.hpp>
#include <stdio.h>
#include <iostream>
#include <cctype>
#include <math.h>
#include <fstream>
#include <string>

using namespace boost;
using namespace std;

#define DECIMAL 1
#define NORMAL_URL 4
#define HTTP 2
#define HTTPS 1
#define FTP 3

#define MALFORMEDURL 403

const string URLSYNTAXREGEX = "((https?|ftp)://)?(([a-zA-Z0-9-]+[.]{1}[a-zA-Z0-9]+)+([:]{1}((0[0-7]+)|(0[xX][0-9a-fA-F]+)|([0-9]+))){0,1})([?/][-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?";
const string DECIMALREGEX = "((0|[1-9]{1}[0-9]{0,2})[.]{1}(0|[1-9]{1}[0-9]{0,2})[.]{1}(0|[1-9]{1}[0-9]{0,2})[.]{1}(0|[1-9]{1}[0-9]{0,2}))([:]{1}((01?[0-7]{1,5})|(0[xX][0-9a-fA-F]{1,4})|(0|[1-9][0-9]{0,4}))){0,1}(/[-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?";
const string VALIDURLSYNTAXREGEX ="(([-a-zA-Z0-9.]+[.]+[-a-zA-Z]+)([:]{1}((01?[0-7]{1,5})|(0[xX][0-9a-fA-F]{1,4})|([1-9][0-9]{0,4}))){0,1})([?/][-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?";
const string VALIDIPREGEX="((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[.]{1}((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[.]{1}((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[.]{1}((0[0-7]{1,3})|(0[xX][0-9a-fA-F]{1,2})|(0|[1-9]{1}[0-9]{0,2}))[:]{0,1}((01?[0-7]{1,5})|(0[xX][0-9a-fA-F]{1,4})|(0|[1-9]{1}[0-9]{0,4})?)(/[-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?";

const string URL="0";
const string IP="1";
static bool isPort;

#define URLNORMALIZATION_ImportState __declspec( dllexport )

class URLNORMALIZATION_ImportState URLHandler
{
    
    bool isDecimal(string);
    bool isCDN(string,string&);
    bool EvaluateRegex(const string,string);
    int GetPortNumber(string&);
    int ConvertHexToDecimal(string);
    int ConvertOctalToDecimal(string);
    int GetDecimalIp(string,string&);
    string decodePercentageTraces(string);
    string Truncatelevels(string);
    string GetType(string);
    void ToLower(string&);
    void removeProtocol(string&);
public:
    

    URLHandler();
    virtual ~URLHandler();
    int validateURL(string,string&,string&);
    
    
    
};
#endif

2.CacheStore class which uses Boost.multiindex

#ifndef _CACHESTORE_H_
#define _CACHESTORE_H_
//#define NDEBUG

#if !defined(NDEBUG)
#define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING
#define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE
#endif

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/ordered_index.hpp>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <time.h>
#include <vector>
//#include <semaphore.h>

using boost::multi_index_container;
using namespace boost::multi_index;
using namespace std;

#define CACHEMANAGER_ImportState __declspec( dllexport )

class CACHEMANAGER_ImportState Cache
{
public:
std::string url;
std::string category;
int criticality;
long timeStamp;
int frequency;

Cache(){}
Cache(string url_,string category_,int criticality_,int frequency_,long timeStamp_)
{
    url=url_;
    category=category_;
        criticality=criticality_;
        timeStamp=timeStamp_;
        frequency=frequency_;
}

};

struct TAG_FREQUENCY{};
struct TAG_URL{};
struct TAG_CRITICALITY{};
struct TAG_TIMESTAMP{};

typedef multi_index_container
<
Cache,
    indexed_by
    <
      hashed_unique<tag<TAG_URL>,BOOST_MULTI_INDEX_MEMBER(Cache,std::string,url)>
      ,ordered_non_unique<tag<TAG_FREQUENCY>,BOOST_MULTI_INDEX_MEMBER(Cache,int,frequency)>
          ,ordered_non_unique<tag<TAG_CRITICALITY>,BOOST_MULTI_INDEX_MEMBER(Cache,int,criticality)>
          ,ordered_non_unique<tag<TAG_TIMESTAMP>,BOOST_MULTI_INDEX_MEMBER(Cache,long,timeStamp)>
>
> cache_set;

class CACHEMANAGER_ImportState CacheStore
{
private:
//pthread_mutex_t getLock;
//pthread_mutex_t insertLock;
cache_set cacheSet;

public:
    /*const static int NON_CRITICAL;
    const static int CRITICAL;*/

    void insert(Cache cacheObj);
    int getCache(string url,Cache& cache_obj);
    void updateFrequency(string url);//Always increment frquency by one
    void updateCategory(string url,string category);
    void updateCache(string url,string category,int frequency,int criticality,long timeStamp);
    int getSize();
    int getNonCriticalCacheSize();
    int remove(int count=1);
    void display();
    std::vector<string> getAllEntry();
    void removeElapsedEntries();
    
    CacheStore()
    {
         //cacheSet=new cache_set();
        //pthread_mutex_init(&(getLock),NULL);
        //pthread_mutex_init(&(insertLock),NULL);
    }
    
    CacheStore(const CacheStore& obj){} //copy constructure
    CacheStore& operator=(const CacheStore& ) { return *this; } //assignment op overloading
};

#endif //_CACHESTORE_H_

Both are of diffrent DLL's.

I am using the above two class inside the main() which looks as follows

#include "URLHandler.h"
#include "CacheStore.h"
#include <string>

using namespace std;

void main()
{
    ....
    ....
   .....
}

When I compile 'URLHandler' and 'CacheStore' independently both will compile without any errors.
But when integrated with main() gives the compilation errors.

I have included 'boost_regex-vc6-mt-1_33_1.lib' for URLHandler and no lib is specified for 'CacheStore'.

Include path contains the paths
    Boost\include\boost-1_33_1
and
    Boost\lib

Best Regards
Mahesh Karanth

Joaqu�n M� L�pez Mu�oz <joaquin_at_[hidden]> wrote: Hello Mahesh,

mahesh karanth ha escrito:

> Unfortunately I am using 'using namespace std;' after all the include statements only.
>
> And I am using VC 6
>
> I think I should tell you how I have creted my workspace
>
> I have a workspace in which a) 'Win32 console application' b)'Win32 Dinamic Link Library' (This project uses Boost.multi index) c)'Win32 Dinamic Link Library (This project uses Boost.Regex).
>
> I have used both b) and c) dll's in main (Win32 console application).
>
> Class hirarchy is as follows
>
> WorkSpace -> main files , multiindex files , regex files

Which multi_index files? Boost.MultiIndex is a header only library. When you say

"But when I indipendently compile multiindex package and regex package both
compiles without any error."

what do you mean by compiling multiindex package? Could you describe
what is this process you do in more detail?

> in the main I am calling the methods of multiindex and regex.

Maybe can you post the file of yours where the compile error shows?
If you can't for confidentiality reasons, you can either post
privately of at least send the includes part. I tend to think, along with
John, you're implicitly issuing a using directive, maybe in some of
your headers.

Joaqu�n M L�pez Mu�oz
Telef�nica, Investigaci�n y Desarrollo

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

                
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk