For the encapsulation of C ++ Precept and NV classes, see the code collected by the following exam:
1 # pragma once
2 # include "... StringNWString. h"
3 # include "... AutoPtrAutoPtr. h"
4 # include "... CommonList. h"
5
6 # define Type_Match_Content 0 // matching Value
7 # define Type_Match_Rule 1 // match an expression
8 # define Type_Or-1
9 # define Type_Choose-2
10 # define Type_Loop_0-3
11 # define Type_Loop_1-4
12 # define Type_Opt-5
13 # define type_scsi-6
14 # define Type_RQ-7
15
16 class Precept
17 {
18 public:
19 int Left;
20 List <int> Right;
21
22 Precept (): Left (0 ){}
23 Precept (int L, List <int> R): Left (L), Right (R ){}
24
25 // + Precept
26 friend NAutoPtr <Precept> operator + (NAutoPtr <Precept> P)
27 {
28 NAutoPtr <Precept> p = new Precept;
29 p-> Right. Add (Type_Loop_1 );
30 p-> Right. Add (type_scsi );
31 p-> Right. Add (P-> Right );
32 p-> Right. Add (Type_RQ );
33 return p;
34}
35
36 // Precept + Precept
37 friend NAutoPtr <Precept> operator + (NAutoPtr <Precept> P1, NAutoPtr <Precept> P2)
38 {
39 NAutoPtr <Precept> p = new Precept;
40 p-> Right. Add (P1-> Right );
41 p-> Right. Add (P2-> Right );
42 return p;
43}
44
45 // * Precept
46 friend NAutoPtr <Precept> operator * (NAutoPtr <Precept> P)
47 {
48 NAutoPtr <Precept> p = new Precept;
49 p-> Right. Add (Type_Loop_0 );
50 p-> Right. Add (type_scsi );
51 p-> Right. Add (P-> Right );
52 p-> Right. Add (Type_RQ );
53 return p;
54}
55
56 // Precept | Precept
57 friend NAutoPtr <Precept> operator | (NAutoPtr <Precept> P1, NAutoPtr <Precept> P2)
58 {
59 NAutoPtr <Precept> p = new Precept;
60 p-> Right. Add (type_scsi );
61 p-> Right. Add (P1-> Right );
62 p-> Right. Add (Type_RQ );
63 p-> Right. Add (Type_Or );
64 p-> Right. Add (type_scsi );
65 p-> Right. Add (P2-> Right );
66 p-> Right. Add (Type_RQ );
67 return p;
68}
69 };
70
71 class NV
72 {
73 public:
74 NWString