Skip to content

Commit a6d0eef

Browse files
Add String Enumeratior stamp
1 parent 47278eb commit a6d0eef

File tree

6 files changed

+16
-85
lines changed

6 files changed

+16
-85
lines changed

blobstamper/Makefile

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11

2-
ALL_OBJS = blob.o \
3-
helpers.o \
4-
stamp.o \
5-
stamp_arithm.o \
6-
stamp_dict.o \
7-
galley.o \
8-
dict.o \
92

3+
BLOBSTAMPER_SRC := $(wildcard ./*.cpp)
4+
BLOBSTAMPER_OBJ := $(addsuffix .o, $(basename $(BLOBSTAMPER_SRC)))
105

11-
%.o: %.cpp $(DEPS)
12-
$(CXX) -c -g $(CXXFLAGS) $<
136

14-
%.o: %.c $(DEPS)
15-
$(CC) -c -g $(CFLAGS) $<
7+
%.o: %.cpp
8+
$(CXX) -c -g $(CXXFLAGS) -I .. $< -o $@
169

1710

18-
all: $(ALL_OBJS)
11+
all: $(BLOBSTAMPER_OBJ)
1912

2013
.PHONY: clean
2114
clean:

blobstamper/blobstamper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
#include "stamp_dict.h"
2323
#include "dict.h"
2424
#include "galley.h"
25-
25+
#include "stamp_enumerator.h"
2626

blobstamper/galley.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include <vector>
2525
#include <functional> // for std::reference_wrapper
2626

27+
#include "stamp.h"
28+
#include "blob.h"
29+
30+
2731
#define ORACLE_TYPE unsigned short int
2832
#define ORACLE_STAMP StampArithm<ORACLE_TYPE>
2933
#define ORACLE_SIZE sizeof(ORACLE_TYPE)
@@ -33,6 +37,7 @@ class GalleyBase: public virtual StampBase
3337
/* Galley is a kind of stamp, somwhere deep inside. */
3438
/* You can inherit it, and make a stamp out of it*/
3539
{
40+
3641
};
3742

3843
class GalleyVectorBase : public GalleyBase

blobstamper/stamp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <memory>
2626

2727
#include "helpers.h"
28+
#include "blob.h"
2829

2930

3031
class StampBase

examples/Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ all: $(EXAMPLES_BIN)
1111
build-libtappp:
1212
$(MAKE) -C ../libtappp
1313

14-
../blobstamper-pg/%.o: ../blobstamper-pg/%.cpp
15-
$(CXX) -c -g $(CXXFLAGS) -I .. $< -o $@
16-
17-
../wrappers/%.o: ../wrappers/%.cpp
18-
$(CXX) -c -g $(CXXFLAGS) -I .. $< -o $@
19-
20-
2114
%: %.cpp $(BLOBSTAMPER_OBJ) $(BLOBSTAMPER_PG_OBJ) $(WRAPPERS_OBJ)
2215
$(CXX) $(CXXFLAGS) -I.. -o $@ $< $(BLOBSTAMPER_OBJ)
2316

examples/example08.cpp

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -53,86 +53,25 @@ Point3D StampPoint3D::ExtractValue(Blob &blob)
5353
}
5454

5555

56-
class StampPolyLine3D: public GalleyVectorStr, public StampBaseStr
56+
class StampPolyLine3D: public StampStrEnumerator
5757
{
5858
protected:
5959
StampPoint3D * item_stamp_p;
6060
public:
61-
StampPolyLine3D(): GalleyVectorStr(*(item_stamp_p = new StampPoint3D())) {};
61+
StampPolyLine3D(): StampStrEnumerator(*(item_stamp_p = new StampPoint3D()), ",", "(",")") {};
6262
~StampPolyLine3D() {delete item_stamp_p;};
63-
64-
virtual std::string ExtractStr(Blob &blob) override;
65-
};
66-
67-
class StampStrEnumerator: public GalleyVectorStr, public StampBaseStr
68-
{
69-
protected:
70-
StampBaseStr & stamp_str;
71-
const std::string separator;
72-
const std::string left_bracket;
73-
const std::string right_bracket;
74-
public:
75-
StampStrEnumerator(StampBaseStr &arg_stamp,
76-
const std::string arg_sep,
77-
const std::string arg_l,
78-
const std::string arg_r
79-
):
80-
stamp_str(arg_stamp),
81-
separator(arg_sep),
82-
left_bracket(arg_l),
83-
right_bracket(arg_r),
84-
GalleyVectorStr(arg_stamp) {};
85-
86-
virtual std::string ExtractStr(Blob &blob) override;
87-
8863
};
8964

9065

91-
std::string StampStrEnumerator::ExtractStr(Blob &blob)
92-
{
93-
std::vector<std::string> data = ExtractStrVector(blob);
94-
std::string res = "";
95-
96-
for(std::string s : data)
97-
{
98-
if (!res.empty())
99-
{
100-
res+= separator;
101-
}
102-
res+= s;
103-
}
104-
res = left_bracket + res + right_bracket;
105-
return res;
106-
}
107-
108-
109-
110-
std::string StampPolyLine3D::ExtractStr(Blob &blob)
111-
{
112-
std::vector<std::string> data = ExtractStrVector(blob);
113-
std::string res = "";
114-
115-
for(std::string s : data)
116-
{
117-
if (!res.empty())
118-
{
119-
res+=", ";
120-
}
121-
res+= s;
122-
}
123-
res = "(" + res + ")";
124-
return res;
125-
}
12666

12767
int main()
12868
{
12969
char data[] = "abcdef" "abcdef" "ABCDEF" "012345";
13070
Blob blob(data, strlen(data));
131-
StampPoint3D stamp;
13271

133-
StampStrEnumerator stamp_e(stamp, " - ", "[", "]");
72+
StampPolyLine3D stamp;
13473

13574

136-
std::string s = stamp_e.ExtractStr(blob);
75+
std::string s = stamp.ExtractStr(blob);
13776
std::cout << s <<"\n";
13877
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy