|
-
April 28th, 2005, 09:47 PM
#1
how to use stl in a MFc application?
ar didn't overload << and >> for vector ,list ,map,and so on, and these didn't inherit from Cobject, so no the virtual function Serialize, can't use the
CTypedPtrlist.serialize(ar) to write and read ,and so on,so we lost the ways of MFC's writing and read,if we use stl in a MFC application?
how can do this ?
I know MFC macro max,min need be hidden if use stl.
-
April 28th, 2005, 10:54 PM
#2
Re: how to use stl in a MFc application?
first of all, don't use MFC serialization, but if you are going to then just write some functions
Code:
template<typename T>
CArchive& STORE_VECTOR(CArchive& ar, const std::vector<T>& t_vector)
{
ar << to_store.size();
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar << t_vector[i];
return ar;
}
template<typename T>
CArchive& LOAD_VECTOR(CArchive& ar, std::vector<T>& t_vector)
{
std::vector<T>::size_type size(0);
ar >> size;
t_vector.resize(size);
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar >> t_vector[i];
return ar;
}
Last edited by souldog; April 28th, 2005 at 11:00 PM.
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
April 29th, 2005, 05:10 AM
#3
Re: how to use stl in a MFc application?
 Originally Posted by souldog
first of all, don't use MFC serialization, but if you are going to then just write some functions
Code:
template<typename T>
CArchive& STORE_VECTOR(CArchive& ar, const std::vector<T>& t_vector)
{
ar << to_store.size();
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar << t_vector[i];
return ar;
}
template<typename T>
CArchive& LOAD_VECTOR(CArchive& ar, std::vector<T>& t_vector)
{
std::vector<T>::size_type size(0);
ar >> size;
t_vector.resize(size);
for(std::vector<T>::size_type i = 0; i < t_vector.size(); i++
ar >> t_vector[i];
return ar;
}
thanks!!
-
April 29th, 2005, 06:10 AM
#4
Re: how to use stl in a MFc application?
 Originally Posted by souldog
first of all, don't use MFC serialization
This means MFC serialization is a bad structure? So MFC lost many feathers.
How I understand this word?
Can tell me more about MFC's serialization, how to use it, when don't use it, why we don't use it? 3x!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|