WvStreams
include/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
14class WvFile;
15
25class UniIniGen : public UniTempGen
26{
27public:
28 typedef wv::function<void()> SaveCallback;
29
30private:
31 WvString filename;
32 int create_mode;
33 WvLog log;
34 struct stat old_st;
35 SaveCallback save_cb;
36
37public:
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
53private:
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
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
A plain UniConfTree that holds keys and values.
Loads and saves ".ini"-style files similar to those used by Windows, but adapted to represent keys an...
UniIniGen(WvStringParm filename, int _create_mode=0666, SaveCallback _save_cb=SaveCallback())
Creates a generator which can load/modify/save a .ini file.
virtual bool refresh()
Refreshes information about a key recursively.
virtual void set(const UniConfKey &key, WvStringParm value)
Stores a string value for a key into the registry.
virtual void commit()
Commits any changes.
A UniConf generator that stores keys in memory.
WvFile implements a stream connected to a file or Unix device.
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...