rm TokenParser

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry
2026-02-28 15:45:34 -08:00
parent cd21c43693
commit e76f54a068
8 changed files with 41 additions and 200 deletions

View File

@@ -33,6 +33,8 @@
namespace sta {
using StdStringSeq = std::vector<std::string>;
inline bool
stringEq(const char *str1,
const char *str2)
@@ -201,12 +203,9 @@ deleteTmpStrings();
void
trimRight(std::string &str);
using StringVector = std::vector<std::string>;
void
split(const std::string &text,
const std::string &delims,
// Return values.
StringVector &tokens);
// Spit text into delimiter separated tokens and skip whitepace.
StdStringSeq
parseTokens(const std::string &s,
const char delimiter);
} // namespace

View File

@@ -1,62 +0,0 @@
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2025, Parallax Software, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software.
//
// Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// This notice may not be removed or altered from any source distribution.
#pragma once
#include <vector>
#include <string>
namespace sta {
using StdStringSeq = std::vector<std::string>;
// Iterate over the tokens in str separated by character sep.
// Similar in functionality to strtok, but does not leave the string
// side-effected. This is preferable to using strtok because it leaves
// string terminators where the separators were.
// Using STL string functions to parse tokens is messy and extremely slow
// on the RogueWave/Solaris implementation, apparently because of mutexes
// on temporary strings.
class TokenParser
{
public:
TokenParser(const char *str,
const char *delimiters);
bool hasNext();
char *next();
private:
const char *delimiters_;
char *token_;
char *token_end_;
char token_delimiter_;
bool first_;
};
// Parse delimiter separated tokens and skipp spaces.
StdStringSeq
parseTokens(const std::string &s,
const char delimiter);
} // namespace