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)
//#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&);

    virtual ~URLHandler();
    int validateURL(string,string&,string&);

2.CacheStore class which uses Boost.multiindex

#ifndef _CACHESTORE_H_
#define _CACHESTORE_H_
//#define NDEBUG

#if !defined(NDEBUG)

#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
std::string url;
std::string category;
int criticality;
long timeStamp;
int frequency;

Cache(string url_,string category_,int criticality_,int frequency_,long timeStamp_)


struct TAG_URL{};

typedef multi_index_container
> cache_set;

class CACHEMANAGER_ImportState CacheStore
//pthread_mutex_t getLock;
//pthread_mutex_t insertLock;
cache_set cacheSet;

    /*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();
         //cacheSet=new cache_set();
    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

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:

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

Boost list run by bdawes at, gregod at, cpdaniel at, john at