Дмитрий ⬡
Без регулярки можно руками писать цикл по строчке, запарившись с всеми случаями
Дмитрий ⬡
Но вопрос что проще)
Anatoly
потому что правильный regex-валидатор очень большой и выглядит очень сложно, поэтому для начала спрашиваю что-то более стандартное
мне надо было как-то на части разложить url, но я ничего такого не нашел, поэтому написал regexp. для моей задачи подошел, можешь взять за основу:
URL URL::Parse(const char * url) {
std::regex r("^"
"(" // 1. server = protocol user:password @ host : port
"(" // 2. protocol = scheme + ://
"([^:]+)" // 3. scheme
"://" //
")"
"(" // 4. user:password
"([^:@]+)?" // 5. user
"(:([^@]*))?" // 6. :password 7. password
"@)?"
"([^:/$]+)?" // 8. host
"(:(\\d+))?" // 9. :port 10. port
")"
"(/[^$]*)?" // 11. path
"$"
);
std::cmatch m;
bool matched = std::regex_match(url, m, r);
not
Спасибо :)
Alexander
std::regex может неожиданно сьесть очень много стека
Igor
Alexander
ну, как говорится: у меня была проблема, и я решил решить ее с помочью регэкспов. Теперь у меня две проблемы :)
Alexander "SonnySlave"
Alexander
просто реализация в некоторых стандартных либах странная (?), и я просто решил поделиться соображением
Anatoly
kitsu
kitsu
под схему вообще любую бяку можно подставить
kitsu
так и появляются cve-шечки
Anatoly
@spoonson @zamazan4ik ваш посыл какой? regexp сложно, проблемно, страдай и пиши парсер руками?
Anton
так и шо делать?
Alexander "SonnySlave"
Alexander "SonnySlave"
Вредные советы
Alexander "SonnySlave"
Тоже вариант
Anatoly
а я тебя не спрашивал про посыл, я его знаю :)
Alexander "SonnySlave"
В poco есть poco::uri::parse
Alexander "SonnySlave"
А что там внутри и что они реализуют - надо смотреть
Anatoly
Stanislav
а был пропозал и драфт, но с 2014 не было обновлений
🦥Alex Fails
Stanislav
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3975.html
Igor
Anatoly
а чего так? БНФ сложно? Формальные грамматики сложно?
🦥Alex Fails
сложно(не)
kitsu
а в c++17 для rvo все еще нужен конструктор копирования?
Igor
вопрос исторического характера - все мы знаем, что в чистых сях sizeof('c') == sizeof(int), даже стандарт об этом говорит вроде, а почему сложилось именно так?
Alexander
А что в стандарте по этому поводу написано?
mr13tech
Привет, кто подскажет где найти 'C++ Templates: The Complete Guide (2nd Edition)'
Alexander "SonnySlave"
Igor
Danil
Danil
Stanislav
вопрос исторического характера - все мы знаем, что в чистых сях sizeof('c') == sizeof(int), даже стандарт об этом говорит вроде, а почему сложилось именно так?
In the dark days of early C there were no types at all. By the time I first learnt to program in C, types had been introduced, but functions didn't have prototypes to tell the caller what the argument types were. Instead it was standardised that everything passed as a parameter would either be the size of an int (this included all pointers) or it would be a double.
This meant that when you were writing the function, all the parameters that weren't double were stored on the stack as ints, no matter how you declared them, and the compiler put code in the function to handle this for you.
This made things somewhat inconsistent, so when K&R wrote their famous book, they put in the rule that a character literal would always be promoted to an int in any expression, not just a function parameter.
When the ANSI committee first standardised C, they changed this rule so that a character literal would simply be an int, since this seemed a simpler way of achieving the same thing.
Stanislav
с SO
Igor
с SO
хм, видимо плохо глядел, спс
Alexander
https://stackoverflow.com/questions/2172943/size-of-character-a-in-c-c
Ignat
Нет, 'c' в С имеет тип int
Dmitry
Можно как то на концептах написать шаблон, который принимает один тип и "пробрасывает" все его операторы. А для тех операторов, которых нет - бросает исключение?
Dmitry
Надо отдельный концепт для каждого оператора?
Dmitry
(сам ещё не тыкал концепты)
Ignat
Ну да
Ignat
Вот бы ещё при промоушоне чаров (которые обычно знаковые) к интам не получалось отрицательных чисел, а то практически любое использование ctype.h — шанс отстрелить ногу
Max
Max
и никакие ctypes.h не страшны =)
Ignat
В принципе и -funsigned-char можно, но если об этом не знаешь/забыл, то можно на ровном месте огрести
Anonymous
Короче, есть проект, у него несколько файлов которые компилируются при помощи make два раза, во второй раз компилируется с флагом -fpic. Как сделать так, что бы компилировать 1 раз с флагом -fpic?
Igor
а вот это звучит познавательно, спасибо)
🦥Alex Fails
Слайды я тож собираю
Maksym
Anonymous
Где Страуструп?
Maksym
отдыхает
🦥Alex Fails
No
Крылатый
🤔
🦥Alex Fails
#old #good #classic #logo
Dan
😂👍
Ildar
Anton
а вы в списке слева выделите канал
Roman
круглый симпотнее
Anton
уже не так прикольно
Anonymous
Anonymous
Он плприятнее
Ilia
Anatoly
что это за packman поедающий плюсы?
Vjačeslavs
текущая иконка вернула мне мой скевоморфизм
Roman
в круглом бордюр надо маленький сделать белый и будет огонь
Roman
Two sad things were found here, one huge and one annoying:
https://blog.jetbrains.com/clion/2018/06/iso-cpp-committee-rapperswil-2018-trip-report/
Huge. C++20 most likely won't have Modules.
That's disappointing. I hate my compile times (yes, yes, my code is bad, modularization sucks, coupling is tight as hell, etc, etc). But I hate. And I hoped that modules in the standard (=> the same in all three major compilers, I'm building on all of them) would force me to grow and improve structure and design.
Annoying. Implicit capture of this via [=] is now deprecated.
I use lambdas a lot, and I use [=] capture a lot. Many (almost all?) of my closures are guarded by one way or another:
1. They'll automatically unsubscribe themselves when this dies.
or
2. They're guarded by weak pointer to this, so that they're safe to be called even if this is already dead.
Either way, I'm always capturing this by [=], all the time. And converting it to [=, this] will kill half of fun and all of beauty. I've never had a bug (yet?) with incorrect capture of this inside a [=] lambda.
And the motivation (confusion with the newly introduced [*this] capture-by-value) doesn't work for me — I can't imagine (yet?) a single case of [*this] capture in my code :(
🦥Alex Fails
🦥Alex Fails
Two sad things were found here, one huge and one annoying:
https://blog.jetbrains.com/clion/2018/06/iso-cpp-committee-rapperswil-2018-trip-report/
Huge. C++20 most likely won't have Modules.
That's disappointing. I hate my compile times (yes, yes, my code is bad, modularization sucks, coupling is tight as hell, etc, etc). But I hate. And I hoped that modules in the standard (=> the same in all three major compilers, I'm building on all of them) would force me to grow and improve structure and design.
Annoying. Implicit capture of this via [=] is now deprecated.
I use lambdas a lot, and I use [=] capture a lot. Many (almost all?) of my closures are guarded by one way or another:
1. They'll automatically unsubscribe themselves when this dies.
or
2. They're guarded by weak pointer to this, so that they're safe to be called even if this is already dead.
Either way, I'm always capturing this by [=], all the time. And converting it to [=, this] will kill half of fun and all of beauty. I've never had a bug (yet?) with incorrect capture of this inside a [=] lambda.
And the motivation (confusion with the newly introduced [*this] capture-by-value) doesn't work for me — I can't imagine (yet?) a single case of [*this] capture in my code :(
Жалко престона, он копировал this по значению в лямбдах
Roman
8 байт можно и скопировать
Roman
он его не приводил
Roman
"I can't imagine (yet?) a single case of [*this] capture in my code :("