map, set and other containers in exported class

map, set and other containers in exported class

Post by Ilya Livshit » Thu, 18 Jan 2001 19:48:05



        Hi
How to get around compiler warnings like:
"warning C4251: '_mapA' : class 'std::map<int,class A *,struct
std::less<int>,class std::allocator<class A *> >
' needs to have dll-interface to be used by clients of class B "

Source code looks like:

typedef map< int, A *> Tmap;

 __declspec(dllexport) class B {
...
        Tmap _map;
...

Quote:}

                        Any help will be appreaciated.
                                        Ilya.
 
 
 

map, set and other containers in exported class

Post by Ron Natali » Fri, 19 Jan 2001 00:22:19



>         Hi
> How to get around compiler warnings like:
> "warning C4251: '_mapA' : class 'std::map<int,class A *,struct
> std::less<int>,class std::allocator<class A *> >
> ' needs to have dll-interface to be used by clients of class B "

__declspec(dllexport) class B  { } x;
says export the object x;

class __declspec(dllexport) B { } x;
says export the CLASS DEFINITION.

note the position of the __declspec.

 
 
 

1. Reading from file to a set container of type class

I have managed to write a number of class data members to file in the
following manner:

void printFPolicies(const PolicyTable & policies) {
std::ofstream outfile("PolicyFile.txt");

        std::copy(policies.begin(),policies.end(),
        std::ostream_iterator<Policy>(outfile, "\n"));

However if I wish to initialize the container with the values in this
file I am a little confused how to go about it, I know getline would
work I could probably create a variable of type string, but how to
iterate, initializing and inserting ? The way I know how to do it is
to inelegant, in that I would specify each data member that I assigned
the value to, but in outputting to file I didn't have to "touch" the
data member elements.

Here is the policy class

class Policy
{
public:
        int  Index;
        unsigned long int IfIndex;
        std::string Source_IP;
        std::string Process_Name;
        std::string Protocol;
        std::string Remote_Ip;
        unsigned short Remote_Port;
        std::string State;
        DWORD   dwProcessID;
        DWORD   dwLocalIpAddress;
        DWORD   dwLocalPort;
        BOOL    bTcpOrUdp;

        Policy();
        bool operator< (Policy const &) const;
        bool matches(Session &) const;
        void dump(std::ostream &) const;

typedef std::set<Policy> PolicyTable;

std::ostream & operator<< (std::ostream &,Policy const &);
std::ofstream & operator<< (std::ofstream &,Policy const &);

Thanks


      [ about comp.lang.c++.moderated. First time posters: do this! ]

2. Help needed

3. Can I derive a class from a base class exported from a static DLL?

4. HELP with Internet Explorer

5. Exporting classes derived from STL classes?

6. Advance Program for Workshop on Fault-tolerant Parallel and Distributed Systems (Latex Version)

7. O/S headers define "struct map" conflicts with STL "class map"

8. 3524-XL-EN error

9. Unicode source character set (Was: pi, epsilon and others)

10. Exporting data from OLE container to Word/Excel

11. Linking Iterator class with Container class

12. Classes with container classes as members.

13. Q: Creating a template container class with dynamic sub class (specialization) allocation