Skip to content

Commit a7ea359

Browse files
authored
remove ofMain include and set std on string and vector (#7690)
#changelog #addons
1 parent c6e169e commit a7ea359

2 files changed

Lines changed: 55 additions & 51 deletions

File tree

addons/ofxXmlSettings/src/ofxXmlSettings.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <string>
55
#include <iostream>
66

7+
using std::string;
8+
using std::vector;
9+
710
// this increases the accuracy of ofToString() when saving floating point values
811
// but in the process of setting it also causes very small values to be ignored.
912
const float floatPrecision = 9;

addons/ofxXmlSettings/src/ofxXmlSettings.h

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

3-
#include "ofMain.h"
3+
#include "ofConstants.h"
4+
#include "ofParameter.h"
45
#include <string.h>
56
#if (_MSC_VER)
67
#include "../libs/tinyxml.h"
@@ -44,41 +45,41 @@
4445
#define MAX_TAG_VALUE_LENGTH_IN_CHARS 1024
4546

4647
class ofxXmlSettings{
47-
48+
4849
public:
4950
ofxXmlSettings();
50-
ofxXmlSettings(const string& xmlFile);
51+
ofxXmlSettings(const std::string& xmlFile);
5152

5253
~ofxXmlSettings();
5354

5455
void setVerbose(bool _verbose);
5556

56-
OF_DEPRECATED_MSG("ofxXmlSettings::loadFile() is deprecated, use load() instead.", bool loadFile(const string& xmlFile));
57-
OF_DEPRECATED_MSG("ofxXmlSettings::saveFile() is deprecated, use save() instead.", bool saveFile(const string& xmlFile));
57+
OF_DEPRECATED_MSG("ofxXmlSettings::loadFile() is deprecated, use load() instead.", bool loadFile(const std::string& xmlFile));
58+
OF_DEPRECATED_MSG("ofxXmlSettings::saveFile() is deprecated, use save() instead.", bool saveFile(const std::string& xmlFile));
5859
OF_DEPRECATED_MSG("ofxXmlSettings::saveFile() is deprecated, use save() instead.", bool saveFile());
5960

60-
bool load(const string & path);
61-
bool save(const string & path);
61+
bool load(const std::string & path);
62+
bool save(const std::string & path);
6263
bool save();
6364

6465

6566

66-
void clearTagContents(const string& tag, int which = 0);
67-
void removeTag(const string& tag, int which = 0);
67+
void clearTagContents(const std::string& tag, int which = 0);
68+
void removeTag(const std::string& tag, int which = 0);
6869

69-
bool tagExists(const string& tag, int which = 0) const;
70+
bool tagExists(const std::string& tag, int which = 0) const;
7071

7172
// removes all tags from within either the whole document
7273
// or the tag you are currently at using pushTag
7374
void clear();
7475

75-
int getValue(const string& tag, int defaultValue, int which = 0) const;
76-
double getValue(const string& tag, double defaultValue, int which = 0) const;
77-
string getValue(const string& tag, const string& defaultValue, int which = 0) const;
76+
int getValue(const std::string& tag, int defaultValue, int which = 0) const;
77+
double getValue(const std::string& tag, double defaultValue, int which = 0) const;
78+
std::string getValue(const std::string& tag, const std::string& defaultValue, int which = 0) const;
7879

79-
int setValue(const string& tag, int value, int which = 0);
80-
int setValue(const string& tag, double value, int which = 0);
81-
int setValue(const string& tag, const string& value, int which = 0);
80+
int setValue(const std::string& tag, int value, int which = 0);
81+
int setValue(const std::string& tag, double value, int which = 0);
82+
int setValue(const std::string& tag, const std::string& value, int which = 0);
8283

8384
//advanced
8485

@@ -90,7 +91,7 @@ class ofxXmlSettings{
9091
//the pushed tag - normally addValue only lets you create multiple tags of the same
9192
//at the top most level.
9293

93-
bool pushTag(const string& tag, int which = 0);
94+
bool pushTag(const std::string& tag, int which = 0);
9495
int popTag();
9596
int getPushLevel();
9697

@@ -99,7 +100,7 @@ class ofxXmlSettings{
99100
//use pushTag and popTag to get number of tags whithin other tags
100101
// both getNumTags("PT"); and getNumTags("PT:X"); will just return the
101102
//number of <PT> tags at the current root level.
102-
int getNumTags(const string& tag) const;
103+
int getNumTags(const std::string& tag) const;
103104

104105
//-- addValue/addTag
105106
//adds a tag to the document even if a tag with the same name
@@ -109,44 +110,44 @@ class ofxXmlSettings{
109110
//-- important - this only works for top level tags
110111
// to put multiple tags inside other tags - use pushTag() and popTag()
111112

112-
int addValue(const string& tag, int value);
113-
int addValue(const string& tag, double value);
114-
int addValue(const string& tag, const string& value);
113+
int addValue(const std::string& tag, int value);
114+
int addValue(const std::string& tag, double value);
115+
int addValue(const std::string& tag, const std::string& value);
115116

116-
int addTag(const string& tag); //adds an empty tag at the current level
117+
int addTag(const std::string& tag); //adds an empty tag at the current level
117118

118119
// Attribute-related methods
119-
int addAttribute(const string& tag, const string& attribute, int value, int which = 0);
120-
int addAttribute(const string& tag, const string& attribute, double value, int which = 0);
121-
int addAttribute(const string& tag, const string& attribute, const string& value, int which = 0);
120+
int addAttribute(const std::string& tag, const std::string& attribute, int value, int which = 0);
121+
int addAttribute(const std::string& tag, const std::string& attribute, double value, int which = 0);
122+
int addAttribute(const std::string& tag, const std::string& attribute, const std::string& value, int which = 0);
122123

123-
int addAttribute(const string& tag, const string& attribute, int value);
124-
int addAttribute(const string& tag, const string& attribute, double value);
125-
int addAttribute(const string& tag, const string& attribute, const string& value);
124+
int addAttribute(const std::string& tag, const std::string& attribute, int value);
125+
int addAttribute(const std::string& tag, const std::string& attribute, double value);
126+
int addAttribute(const std::string& tag, const std::string& attribute, const std::string& value);
126127

127-
void removeAttribute(const string& tag, const string& attribute, int which = 0);
128-
void clearTagAttributes(const string& tag, int which = 0);
128+
void removeAttribute(const std::string& tag, const std::string& attribute, int which = 0);
129+
void clearTagAttributes(const std::string& tag, int which = 0);
129130

130-
int getNumAttributes(const string& tag, int which = 0) const;
131+
int getNumAttributes(const std::string& tag, int which = 0) const;
131132

132-
bool attributeExists(const string& tag, const string& attribute, int which = 0) const;
133+
bool attributeExists(const std::string& tag, const std::string& attribute, int which = 0) const;
133134

134-
bool getAttributeNames(const string& tag, vector<string>& outNames, int which = 0) const;
135+
bool getAttributeNames(const std::string& tag, std::vector<std::string>& outNames, int which = 0) const;
135136

136-
int getAttribute(const string& tag, const string& attribute, int defaultValue, int which = 0) const;
137-
double getAttribute(const string& tag, const string& attribute, double defaultValue, int which = 0) const;
138-
string getAttribute(const string& tag, const string& attribute, const string& defaultValue, int which = 0) const;
137+
int getAttribute(const std::string& tag, const std::string& attribute, int defaultValue, int which = 0) const;
138+
double getAttribute(const std::string& tag, const std::string& attribute, double defaultValue, int which = 0) const;
139+
std::string getAttribute(const std::string& tag, const std::string& attribute, const std::string& defaultValue, int which = 0) const;
139140

140-
int setAttribute(const string& tag, const string& attribute, int value, int which = 0);
141-
int setAttribute(const string& tag, const string& attribute, double value, int which = 0);
142-
int setAttribute(const string& tag, const string& attribute, const string& value, int which = 0);
141+
int setAttribute(const std::string& tag, const std::string& attribute, int value, int which = 0);
142+
int setAttribute(const std::string& tag, const std::string& attribute, double value, int which = 0);
143+
int setAttribute(const std::string& tag, const std::string& attribute, const std::string& value, int which = 0);
143144

144-
int setAttribute(const string& tag, const string& attribute, int value);
145-
int setAttribute(const string& tag, const string& attribute, double value);
146-
int setAttribute(const string& tag, const string& attribute, const string& value);
145+
int setAttribute(const std::string& tag, const std::string& attribute, int value);
146+
int setAttribute(const std::string& tag, const std::string& attribute, double value);
147+
int setAttribute(const std::string& tag, const std::string& attribute, const std::string& value);
147148

148-
bool loadFromBuffer( string buffer );
149-
void copyXmlToString(string & str) const;
149+
bool loadFromBuffer(std::string buffer);
150+
void copyXmlToString(std::string & str) const;
150151

151152
TiXmlDocument doc;
152153
bool bDocLoaded;
@@ -157,16 +158,16 @@ class ofxXmlSettings{
157158
int level;
158159

159160

160-
int writeTag(const string& tag, const string& valueString, int which = 0);
161-
bool readTag(const string& tag, TiXmlHandle& valHandle, int which = 0) const; // max 1024 chars...
161+
int writeTag(const std::string& tag, const std::string& valueString, int which = 0);
162+
bool readTag(const std::string& tag, TiXmlHandle& valHandle, int which = 0) const; // max 1024 chars...
162163

163164

164-
int writeAttribute(const string& tag, const string& attribute, const string& valueString, int which = 0);
165+
int writeAttribute(const std::string& tag, const std::string& attribute, const std::string& valueString, int which = 0);
165166

166-
TiXmlElement* getElementForAttribute(const string& tag, int which) const;
167-
bool readIntAttribute(const string& tag, const string& attribute, int& valueString, int which) const;
168-
bool readDoubleAttribute(const string& tag, const string& attribute, double& outValue, int which) const;
169-
bool readStringAttribute(const string& tag, const string& attribute, string& outValue, int which) const;
167+
TiXmlElement* getElementForAttribute(const std::string& tag, int which) const;
168+
bool readIntAttribute(const std::string& tag, const std::string& attribute, int& valueString, int which) const;
169+
bool readDoubleAttribute(const std::string& tag, const std::string& attribute, double& outValue, int which) const;
170+
bool readStringAttribute(const std::string& tag, const std::string& attribute, std::string& outValue, int which) const;
170171
};
171172

172173
void ofSerialize(ofxXmlSettings & settings, const ofAbstractParameter & parameter);

0 commit comments

Comments
 (0)