473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

keep an open stream

Hi

I need to save on open(ing) ifstream in a loop, so I thought to have a
map<string, ifstreamwhere the input streams are open all them time.

class A
{
std::map<std::string, std::ifstreamm_is;

public:
void populate_the _stream();
};

A::A()
{
for( vector<string>::iterator i = files_vec.begin(); i !=
files_vec.end(); i++ )
{
m_is[*i] = ifstream (*i)( f.c_str() );

hummmm

not sure.

thanks for helping

Feb 5 '07 #1
2 1637
Gary Wessle wrote:
Hi

I need to save on open(ing) ifstream in a loop, so I thought to have a
map<string, ifstreamwhere the input streams are open all them time.

class A
{
std::map<std::string, std::ifstreamm_is;
You can't copy an ifstream, so you can't store them in a container.

--
Ian Collins.
Feb 5 '07 #2
Ian Collins schrieb:
Gary Wessle wrote:
>Hi

I need to save on open(ing) ifstream in a loop, so I thought to have a
map<string, ifstreamwhere the input streams are open all them time.

class A
{
std::map<std::string, std::ifstreamm_is;

You can't copy an ifstream, so you can't store them in a container.
Right, but you can store a pointer or smart pointer in a container, like:

std::map<std::string, boost::shared_ptr<std::ifstream m_is;

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Feb 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: VladG | last post by:
The following code being repeated in a loop sends keep-alive at frst iteration only. So I quickly run out of ports (all are in time_wait state) Why? // create the web request to get the remote...
3
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want...
10
by: Gunnar G | last post by:
I'm having problem reading from the beginning of a file. Here is the code (more or less) ifstream codefin; ofstream codefout; while (not_annoyed)
0
by: Madhavi | last post by:
Hi I am working on a proted project from VB to C# in VB stream.open without any parameters works but in C# i need to pass certain arguments like Stream.Open(null,...
5
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.