Mercurial > ~dholland > hg > ag > index.cgi
view anagram/support/agcstack.cpp @ 6:607e3be6bad8
Adjust to the moving target called the C++ standard.
Apparently nowadays it's not allowed to define an explicit copy
constructor but not an assignment operator. Consequently, defining the
explicit copy constructor in terms of the implicit/automatic
assignment operator for general convenience no longer works.
Add assignment operators.
Caution: not tested with the IBM compiler, but there's no particular
reason it shouldn't work.
author | David A. Holland |
---|---|
date | Mon, 30 May 2022 23:46:22 -0400 |
parents | 13d2b8934445 |
children |
line wrap: on
line source
/* * AnaGram, A System for Syntax Directed Programming * Copyright 1997-2002 Parsifal Software. All Rights Reserved. * See the file COPYING for license and usage terms. * * agcstk.cpp - character stack */ #include "agcstack.h" #include "assert.h" //#define INCLUDE_LOGGING #include "log.h" AgString AgCharStack::popString(unsigned n) { LOGSECTION("AgCharStack::popString(unsigned)"); assert(n <= size()); LOGV(size()); LOGV(n); AgString result(n); char *p = result.pointer(); while (n--) { p[n] = pop(); } return result; } AgString AgCharStack::popString() { LOGSECTION("AgCharStack::popString"); unsigned n = size(); LOGV(size()); LOGV(n); AgString result(n); char *p = result.pointer(); while (n--) { p[n] = pop(); } return result; } AgCharStack &AgCharStack::push(const char *s) { while (*s) { push(*s++); } return *this; } AgCharStack &AgCharStack::push(const char *s, unsigned n) { for (unsigned i = 0; i < n; i++) { push(s[i]); } return *this; } AgCharStack &AgCharStack::operator << (AgString s) { int n = s.size(); char *p = s.pointer(); while (n--) { (*this) << *p++; } return *this; } AgCharStack &AgCharStack::operator << (const char *s) { if (s) { while (*s) { push(*s++); } } return *this; }