Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 17th, 2005, 07:15 AM
Chinmoy Mukherjee
Guest
 
Posts: n/a
Default How to upgrade config file

Hi All,
I have a config file as followings

[SERVER_DETAILS]
IP_ADDR=1.2.3.4
PORT=1290

[CLIENT_DETAILS]
IP_ADDR=1.2.3.5
PORT=1291

,etc now my requirement is to write a C++ program which can add a new
entry in the config file, delete existing entry from config file and
modify value of existing entry from the config file
Is there any easy way of solving this?

Regards,
Chinmoy

  #2  
Old August 17th, 2005, 07:55 AM
Alf P. Steinbach
Guest
 
Posts: n/a
Default Re: How to upgrade config file

* Chinmoy Mukherjee:[color=blue]
> I have a config file as followings
>
> [SERVER_DETAILS]
> IP_ADDR=1.2.3.4
> PORT=1290
>
> [CLIENT_DETAILS]
> IP_ADDR=1.2.3.5
> PORT=1291
>
> ,etc now my requirement is to write a C++ program which can add a new
> entry in the config file, delete existing entry from config file and
> modify value of existing entry from the config file
> Is there any easy way of solving this?[/color]

Question the requirement. Use a script language. Or, for C++, use the
platform's usual API for updating such config files.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
  #3  
Old August 17th, 2005, 01:15 PM
BigBrian
Guest
 
Posts: n/a
Default Re: How to upgrade config file


Alf P. Steinbach wrote:[color=blue]
> * Chinmoy Mukherjee:[color=green]
> > I have a config file as followings
> >
> > [SERVER_DETAILS]
> > IP_ADDR=1.2.3.4
> > PORT=1290
> >
> > [CLIENT_DETAILS]
> > IP_ADDR=1.2.3.5
> > PORT=1291
> >
> > ,etc now my requirement is to write a C++ program which can add a new
> > entry in the config file, delete existing entry from config file and
> > modify value of existing entry from the config file
> > Is there any easy way of solving this?[/color]
>
> Question the requirement.[/color]

LOL. That's exactly what some people I work with do, when they're lazy
and don't want to write code.

Their are times when requirements need to be questioned. But on this
newsgroup the topic is the C++ language ( and not system design or
software engineering where requirements should be reviewed closely )
The question was "Is there any easy way of solving this ( assuming in
C++ )"? Avoiding the answer by suggesting changing the requirements
probably isn't how the OP though C++ experts would handle such a
question.

Here's my answer....
"Easy" is a relative term. It can be done in C++, but most people who
ask such questions probably wouldn't consider it easy. One project
that I work on supports config files similar to yours by defining data
structures to hold the data, it parses the file and fills these data
structures. There is also code to write the data structures back to
file. If your program doesn't need to use any of the info in the config
file, but only needs to change or add a value, you could use a C++
library which supports regular expressions to make the changes you need
to the file.

However, If I were asked to write something to only change the file (
and it wasn't required to be in C++ ), I would choose perl instead of
C++.

-Brian

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles