Skip to content

Commit

Permalink
Use std::string directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
toregge committed Aug 20, 2024
1 parent 5557453 commit 2dc7368
Show file tree
Hide file tree
Showing 2,443 changed files with 10,421 additions and 10,334 deletions.
2 changes: 1 addition & 1 deletion config/src/apps/vespa-configproxy-cmd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Application::parseOpts(int argc, char **argv)
const Method method = methods::find(_flags.method);
if (optind + method.args <= argc) {
for (int i = 0; i < method.args; ++i) {
vespalib::string arg = argv[optind++];
std::string arg = argv[optind++];
_flags.args.push_back(arg);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion config/src/apps/vespa-configproxy-cmd/methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Method methods[] = {
{ 0, 0, 0}
};

const Method find(const vespalib::string &name) {
const Method find(const std::string &name) {
for (size_t i = 0; methods[i].shortName != 0; ++i) {
if (name == methods[i].shortName) {
return methods[i];
Expand Down
4 changes: 2 additions & 2 deletions config/src/apps/vespa-configproxy-cmd/methods.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <string>

struct Method {
const char *shortName;
Expand All @@ -11,7 +11,7 @@ struct Method {

namespace methods {

const Method find(const vespalib::string &name);
const Method find(const std::string &name);
void dump();

};
Expand Down
6 changes: 3 additions & 3 deletions config/src/apps/vespa-configproxy-cmd/proxycmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void ProxyCmd::printArray(FRT_Values *rvals) {
}
}

vespalib::string ProxyCmd::makeSpec() {
std::string ProxyCmd::makeSpec() {
return vespalib::make_string("tcp/%s:%d", _flags.targethost.c_str(), _flags.portnumber);
}

Expand All @@ -65,7 +65,7 @@ void ProxyCmd::autoPrint() {
std::cerr << "FAILURE ["<< _req->GetMethodName() <<"]: " << _req->GetErrorMessage() << std::endl;
return;
}
vespalib::string retspec = _req->GetReturnSpec();
std::string retspec = _req->GetReturnSpec();
FRT_Values *rvals = _req->GetReturn();
if (retspec == "S") {
printArray(rvals);
Expand All @@ -81,7 +81,7 @@ void ProxyCmd::autoPrint() {
int ProxyCmd::action() {
int errors = 0;
initRPC();
vespalib::string spec = makeSpec();
std::string spec = makeSpec();
_target = _server->supervisor().GetTarget(spec.c_str());
_req->SetMethodName(_flags.method.c_str());
FRT_Values &params = *_req->GetParams();
Expand Down
12 changes: 6 additions & 6 deletions config/src/apps/vespa-configproxy-cmd/proxycmd.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <vector>
#include <memory>
#include <string>
#include <vector>

class FRT_Target;
class FRT_RPCRequest;
Expand All @@ -12,9 +12,9 @@ class FRT_Values;
namespace fnet::frt { class StandaloneFRT; }

struct Flags {
vespalib::string method;
std::vector<vespalib::string> args;
vespalib::string targethost;
std::string method;
std::vector<std::string> args;
std::string targethost;
int portnumber;
Flags(const Flags &);
Flags & operator=(const Flags &);
Expand All @@ -34,7 +34,7 @@ class ProxyCmd
void invokeRPC();
void finiRPC();
void printArray(FRT_Values *rvals);
vespalib::string makeSpec();
std::string makeSpec();
void autoPrint();
public:
ProxyCmd(const Flags& flags);
Expand Down
8 changes: 4 additions & 4 deletions config/src/tests/configagent/configagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MyConfigResponse : public ConfigResponse
{
public:
MyConfigResponse(const ConfigKey & key, ConfigValue value, bool valid, int64_t timestamp,
const vespalib::string & xxhash64, const std::string & errorMsg, int errorC0de, bool iserror)
const std::string & xxhash64, const std::string & errorMsg, int errorC0de, bool iserror)
: _key(key),
_value(std::move(value)),
_fillCalled(false),
Expand All @@ -46,7 +46,7 @@ class MyConfigResponse : public ConfigResponse
bool hasValidResponse() const override { return _valid; }
bool validateResponse() override { return _valid; }
void fill() override { _fillCalled = true; }
vespalib::string errorMessage() const override { return _errorMessage; }
std::string errorMessage() const override { return _errorMessage; }
int errorCode() const override { return _errorCode; }
bool isError() const override { return _isError; }
const Trace & getTrace() const override { return _trace; }
Expand All @@ -56,13 +56,13 @@ class MyConfigResponse : public ConfigResponse
bool _fillCalled;
bool _valid;
const ConfigState _state;
vespalib::string _errorMessage;
std::string _errorMessage;
int _errorCode;
bool _isError;
Trace _trace;


static std::unique_ptr<ConfigResponse> createOKResponse(const ConfigKey & key, const ConfigValue & value, uint64_t timestamp = 10, const vespalib::string & xxhash64 = "a")
static std::unique_ptr<ConfigResponse> createOKResponse(const ConfigKey & key, const ConfigValue & value, uint64_t timestamp = 10, const std::string & xxhash64 = "a")
{
return std::make_unique<MyConfigResponse>(key, value, true, timestamp, xxhash64, "", 0, false);
}
Expand Down
14 changes: 7 additions & 7 deletions config/src/tests/configgen/map_inserter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct MyType{
};

TEST("require that map of ints can be inserted") {
std::map<vespalib::string, int32_t> map;
std::map<std::string, int32_t> map;
Slime slime;
Cursor & root = slime.setObject();
root.setLong("foo", 3);
Expand All @@ -36,7 +36,7 @@ TEST("require that map of ints can be inserted") {
}

TEST("require that map of struct can be inserted") {
std::map<vespalib::string, MyType> map;
std::map<std::string, MyType> map;
Slime slime;
Cursor & root = slime.setObject();
Cursor & one = root.setObject("foo");
Expand All @@ -55,7 +55,7 @@ TEST("require that map of struct can be inserted") {
}

TEST("require that map of long can be inserted") {
std::map<vespalib::string, int64_t> map;
std::map<std::string, int64_t> map;
Slime slime;
Cursor & root = slime.setObject();
root.setLong("foo", 3);
Expand All @@ -70,7 +70,7 @@ TEST("require that map of long can be inserted") {
}

TEST("require that map of double can be inserted") {
std::map<vespalib::string, double> map;
std::map<std::string, double> map;
Slime slime;
Cursor & root = slime.setObject();
root.setDouble("foo", 3.1);
Expand All @@ -85,7 +85,7 @@ TEST("require that map of double can be inserted") {
}

TEST("require that map of bool can be inserted") {
std::map<vespalib::string, bool> map;
std::map<std::string, bool> map;
Slime slime;
Cursor & root = slime.setObject();
root.setBool("foo", true);
Expand All @@ -100,13 +100,13 @@ TEST("require that map of bool can be inserted") {
}

TEST("require that map of string can be inserted") {
std::map<vespalib::string, vespalib::string> map;
std::map<std::string, std::string> map;
Slime slime;
Cursor & root = slime.setObject();
root.setString("foo", "baz");
root.setString("bar", "bar");
root.setString("baz", "foo");
MapInserter<vespalib::string> inserter(map);
MapInserter<std::string> inserter(map);
root.traverse(inserter);
ASSERT_EQUAL(3u, map.size());
ASSERT_EQUAL("foo", map["baz"]);
Expand Down
2 changes: 1 addition & 1 deletion config/src/tests/configgen/vector_inserter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ verify_vector_strings_can_be_inserted(V vector) {
}

TEST("require that different vectors of strings can be inserted") {
verify_vector_strings_can_be_inserted(std::vector<vespalib::string>());
verify_vector_strings_can_be_inserted(std::vector<std::string>());
verify_vector_strings_can_be_inserted(StringVector());
}

Expand Down
6 changes: 3 additions & 3 deletions config/src/tests/configparser/configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ using vespalib::asciistream;

namespace {

void writeFile(const vespalib::string & fileName, const vespalib::string & data)
void writeFile(const std::string & fileName, const std::string & data)
{
std::ofstream of;
of.open(fileName.c_str());
of << data;
of.close();
}

ConfigValue readConfig(const vespalib::string & fileName)
ConfigValue readConfig(const std::string & fileName)
{
asciistream is(asciistream::createFromFile(fileName));
return ConfigValue(getlines(is), "");
Expand Down Expand Up @@ -105,7 +105,7 @@ TEST("require that array lengths may be specified")
TEST("require that escaped values are properly unescaped") {
StringVector payload;
payload.push_back("foo \"a\\nb\\rc\\\\d\\\"e\x42g\"");
vespalib::string value(ConfigParser::parse<vespalib::string>("foo", payload));
std::string value(ConfigParser::parse<std::string>("foo", payload));
ASSERT_EQUAL("a\nb\rc\\d\"eBg", value);
}

Expand Down
10 changes: 5 additions & 5 deletions config/src/tests/configretriever/configretriever.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ FixedPayload::~FixedPayload() = default;

}

ConfigValue createKeyValueV2(const vespalib::string & key, const vespalib::string & value)
ConfigValue createKeyValueV2(const std::string & key, const std::string & value)
{
auto payload = std::make_unique<FixedPayload>();
payload->getData().setObject().setString(key, Memory(value));
Expand All @@ -175,7 +175,7 @@ TEST_F("require that basic retriever usage works", ConfigTestFixture("myid")) {
{
ConfigKeySet componentKeys;
for (size_t i = 0; i < bootstrapConfig->component.size(); i++) {
const vespalib::string & configId(bootstrapConfig->component[i].configid);
const std::string & configId(bootstrapConfig->component[i].configid);
componentKeys.add<FooConfig>(configId);
}
configs = ret.getConfigs(componentKeys);
Expand All @@ -186,7 +186,7 @@ TEST_F("require that basic retriever usage works", ConfigTestFixture("myid")) {
{
ConfigKeySet componentKeys;
for (size_t i = 0; i < bootstrapConfig->component.size(); i++) {
const vespalib::string & configId(bootstrapConfig->component[i].configid);
const std::string & configId(bootstrapConfig->component[i].configid);
componentKeys.add<BarConfig>(configId);
}
configs = ret.getConfigs(componentKeys);
Expand All @@ -197,7 +197,7 @@ TEST_F("require that basic retriever usage works", ConfigTestFixture("myid")) {
{
ConfigKeySet componentKeys;
for (size_t i = 0; i < bootstrapConfig->component.size(); i++) {
const vespalib::string & configId(bootstrapConfig->component[i].configid);
const std::string & configId(bootstrapConfig->component[i].configid);
componentKeys.add<FooConfig>(configId);
componentKeys.add<BarConfig>(configId);
}
Expand Down Expand Up @@ -339,7 +339,7 @@ TEST_FF("require that getConfigs throws exception when closed", ConfigTestFixtur
std::unique_ptr<BootstrapConfig> bootstrapConfig = configs.getConfig<BootstrapConfig>(f1.configId);
ConfigKeySet componentKeys;
for (size_t i = 0; i < bootstrapConfig->component.size(); i++) {
const vespalib::string & configId(bootstrapConfig->component[i].configid);
const std::string & configId(bootstrapConfig->component[i].configid);
componentKeys.add<FooConfig>(configId);
componentKeys.add<BarConfig>(configId);
}
Expand Down
10 changes: 5 additions & 5 deletions config/src/tests/configuri/configuri_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ TEST("Require that URI can be created from std::string") {
assertConfigId("", ConfigUri(std::string("dir:.")));
}

TEST("Require that URI can be created from vespalib::string") {
assertConfigId("foo/bar", ConfigUri(vespalib::string("foo/bar")));
assertConfigId("myfile", ConfigUri(vespalib::string("file:myfile.cfg")));
assertConfigId("", ConfigUri(vespalib::string("raw:myraw")));
assertConfigId("", ConfigUri(vespalib::string("dir:.")));
TEST("Require that URI can be created from std::string") {
assertConfigId("foo/bar", ConfigUri(std::string("foo/bar")));
assertConfigId("myfile", ConfigUri(std::string("file:myfile.cfg")));
assertConfigId("", ConfigUri(std::string("raw:myraw")));
assertConfigId("", ConfigUri(std::string("dir:.")));
}

TEST("Require that URI can be created from instance") {
Expand Down
18 changes: 9 additions & 9 deletions config/src/tests/failover/failover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ using namespace vespalib;

namespace {

int get_port(const vespalib::string &spec) {
int get_port(const std::string &spec) {
const char *port = (spec.data() + spec.size());
while ((port > spec.data()) && (port[-1] >= '0') && (port[-1] <= '9')) {
--port;
}
return atoi(port);
}

const vespalib::string requestTypes = "s";
const vespalib::string responseTypes = "sx";
const std::string requestTypes = "s";
const std::string responseTypes = "sx";

struct RPCServer : public FRT_Invokable {
vespalib::Barrier barrier;
Expand Down Expand Up @@ -72,7 +72,7 @@ struct RPCServer : public FRT_Invokable {

SimpleBuffer pbuf;
JsonFormat::encode(payload, pbuf, false);
vespalib::string d = pbuf.get().make_string();
std::string d = pbuf.get().make_string();
ret.AddData(d.c_str(), d.size());
LOG(info, "Answering...");
}
Expand All @@ -94,8 +94,8 @@ struct ServerFixture {
std::unique_ptr<fnet::frt::StandaloneFRT> frt;
RPCServer server;
Barrier b;
const vespalib::string listenSpec;
ServerFixture(const vespalib::string & ls)
const std::string listenSpec;
ServerFixture(const std::string & ls)
: frt(),
server(),
b(2),
Expand Down Expand Up @@ -134,7 +134,7 @@ struct NetworkFixture {
std::vector<ServerFixture::UP> serverList;
ServerSpec spec;
bool running;
NetworkFixture(const std::vector<vespalib::string> & serverSpecs)
NetworkFixture(const std::vector<std::string> & serverSpecs)
: spec(serverSpecs), running(true)
{
for (size_t i = 0; i < serverSpecs.size(); i++) {
Expand Down Expand Up @@ -258,7 +258,7 @@ struct ConfigReloadFixture {
};

struct ThreeServersFixture {
std::vector<vespalib::string> specs;
std::vector<std::string> specs;
ThreeServersFixture() : specs() {
specs.push_back("tcp/localhost:18590");
specs.push_back("tcp/localhost:18592");
Expand All @@ -267,7 +267,7 @@ struct ThreeServersFixture {
};

struct OneServerFixture {
std::vector<vespalib::string> specs;
std::vector<std::string> specs;
OneServerFixture() : specs() {
specs.push_back("tcp/localhost:18590");
}
Expand Down
2 changes: 1 addition & 1 deletion config/src/tests/file_acquirer/file_acquirer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ServerFixture : FRT_Invokable {
fnet::frt::StandaloneFRT server;
FNET_Transport transport;
FRT_Supervisor &orb;
vespalib::string spec;
std::string spec;

void init_rpc() {
FRT_ReflectionBuilder rb(&orb);
Expand Down
Loading

0 comments on commit 2dc7368

Please sign in to comment.