dsrc isn't necessary for this repo
[client-tools.git] / src / external / 3rd / library / perforce / include / strdict.h
blob6e5309686002208f9497cf703fee575505b19674
1 /*
2 * Copyright 1995, 1996 Perforce Software. All rights reserved.
4 * This file is part of Perforce - the FAST SCM System.
5 */
7 /*
8 * StrDict.h - a set/get dictionary interface
10 * Classes:
12 * StrDict - a GetVar/PutVar dictionary interface
14 * Methods:
18 class Error;
20 class StrVarName : public StrRef {
22 public:
23 StrVarName( const char *buf, int length )
25 memcpy( varName, buf, length );
26 varName[ length ] = 0;
27 Set( varName, length );
30 StrVarName( const StrPtr &name, int x );
31 StrVarName( const StrPtr &name, int x, int y );
33 private:
34 char varName[64];
35 } ;
37 class StrDict {
39 public:
41 virtual ~StrDict();
43 // Handy wrappers
45 void SetVar( const char *var );
46 void SetVar( const char *var, int value );
47 void SetVar( const char *var, const char *value );
48 void SetVar( const char *var, const StrPtr *value );
49 void SetVar( const char *var, const StrPtr &value );
50 void SetVar( const StrPtr &var, const StrPtr &value )
51 { VSetVar( var, value ); }
53 void SetVarV( const char *arg );
54 void SetArgv( int argc, char *const *argv );
55 void SetVar( const StrPtr &var, int x, const StrPtr &val );
56 void SetVar( const char *var, int x, const StrPtr &val );
57 void SetVar( const char *var, int x, int y, const StrPtr &val );
59 StrPtr *GetVar( const char *var );
60 StrPtr *GetVar( const char *var, Error *e );
61 StrPtr *GetVar( const StrPtr &var, int x );
62 StrPtr *GetVar( const StrPtr &var, int x, int y );
63 StrPtr *GetVar( const StrPtr &var )
64 { return VGetVar( var ); }
66 int GetVar( int x, StrRef &var, StrRef &val )
67 { return VGetVarX( x, var, val ); }
69 void ReplaceVar( const char *var, const char *value );
70 void RemoveVar( const char *var );
72 int Save( FILE * out );
73 int Load( FILE * out );
75 protected:
77 // Get/Set vars, provided by subclass
79 virtual StrPtr *VGetVar( const StrPtr &var ) = 0;
80 virtual void VSetVar( const StrPtr &var, const StrPtr &val );
81 virtual void VRemoveVar( const StrPtr &var );
82 virtual int VGetVarX( int x, StrRef &var, StrRef &val );
83 virtual void VSetError( const StrPtr &var, Error *e );
85 } ;