WvStreams
uniinigen.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A generator for .ini files.
6  */
7 #ifndef __UNICONFINI_H
8 #define __UNICONFINI_H
9 
10 #include "unitempgen.h"
11 #include "wvlog.h"
12 #include <sys/stat.h>
13 
14 class WvFile;
15 
25 class UniIniGen : public UniTempGen
26 {
27 public:
28  typedef wv::function<void()> SaveCallback;
29 
30 private:
31  WvString filename;
32  int create_mode;
33  WvLog log;
34  struct stat old_st;
35  SaveCallback save_cb;
36 
37 public:
42  UniIniGen(WvStringParm filename, int _create_mode = 0666,
43  SaveCallback _save_cb = SaveCallback());
44 
45  virtual ~UniIniGen();
46 
47  /***** Overridden members *****/
48 
49  virtual void commit();
50  virtual bool refresh();
51  virtual void set(const UniConfKey &key, WvStringParm value);
52 
53 private:
54 #ifndef _WIN32
55  // helper methods for commit
56  bool commit_atomic(WvStringParm real_filename);
57 #endif
58 
59  void save(WvStream &file, UniConfValueTree &parent);
60  bool refreshcomparator(const UniConfValueTree *a,
61  const UniConfValueTree *b);
62 };
63 
64 
65 #endif // __UNICONFINI_H
UniIniGen::commit
virtual void commit()
Commits any changes.
Definition: uniinigen.cc:294
UniIniGen::set
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
Definition: uniinigen.cc:39
WvFile
WvFile implements a stream connected to a file or Unix device.
Definition: wvfile.h:28
UniIniGen
Loads and saves ".ini"-style files similar to those used by Windows, but adapted to represent keys an...
Definition: uniinigen.h:25
UniIniGen::refresh
virtual bool refresh()
Refreshes information about a key recursively.
Definition: uniinigen.cc:55
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvLog
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition: wvlog.h:56
UniConfKey
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition: uniconfkey.h:38
UniIniGen::UniIniGen
UniIniGen(WvStringParm filename, int _create_mode=0666, SaveCallback _save_cb=SaveCallback())
Creates a generator which can load/modify/save a .ini file.
Definition: uniinigen.cc:30
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
UniConfValueTree
A plain UniConfTree that holds keys and values.
Definition: uniconftree.h:152
UniTempGen
A UniConf generator that stores keys in memory.
Definition: unitempgen.h:20