Use folly's split instead of custom split in day2
This commit is contained in:
parent
b83b0a098b
commit
05237669a0
15
day2/Makefile
Normal file
15
day2/Makefile
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
CC=g++
|
||||||
|
BIN_NAME=day2
|
||||||
|
CCFLAGS=-o $(BIN_NAME)
|
||||||
|
LDFLAGS=-lfolly
|
||||||
|
|
||||||
|
.PHONY: all, clean
|
||||||
|
|
||||||
|
all: $(BIN_NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(BIN_NAME)
|
||||||
|
|
||||||
|
$(BIN_NAME):
|
||||||
|
$(CC) $(CCFLAGS) $(LDFLAGS) day2.cpp
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <folly/String.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -75,8 +77,10 @@ class Entry {
|
||||||
*/
|
*/
|
||||||
static Entry parse(const std::string &input) {
|
static Entry parse(const std::string &input) {
|
||||||
int delimIndex = input.find(DELIM);
|
int delimIndex = input.find(DELIM);
|
||||||
std::string rawPolicy = input.substr(0, delimIndex);
|
std::vector<std::string> components;
|
||||||
std::string password = input.substr(delimIndex + DELIM.length());
|
folly::split(DELIM, input, components);
|
||||||
|
std::string rawPolicy = components.at(0);
|
||||||
|
std::string password = components.at(1);
|
||||||
Policy policy = Policy::parse(rawPolicy);
|
Policy policy = Policy::parse(rawPolicy);
|
||||||
|
|
||||||
return Entry(policy, password);
|
return Entry(policy, password);
|
||||||
|
|
Loading…
Reference in a new issue