source: icGREP/icgrep-devel/icgrep/re_seq.cpp @ 4133

Last change on this file since 4133 was 3955, checked in by daled, 5 years ago

icGREP now uses scanthru for multibyte unicode character classes.

File size: 1.7 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include "re_seq.h"
8
9Seq::Seq()
10{
11    mList = new std::list<RE*>();
12    mType = Seq::Normal;
13}
14
15Seq::Seq(std::list<RE*>* lst)
16{
17    mList = new std::list<RE*>();
18    std::list<RE*>::iterator it;
19    it=lst->begin();
20    mList->assign(it, lst->end());
21    mList->reverse();
22    mType = Seq::Normal;
23}
24
25Seq::Seq(std::list<RE*> lst)
26{
27    mList = new std::list<RE*>();
28    std::list<RE*>::iterator it;
29    it=lst.begin();
30    mList->assign(it, lst.end());
31    mList->reverse();
32    mType = Seq::Normal;
33}
34
35Seq::~Seq()
36{
37    while(!mList->empty()) delete mList->back(), mList->pop_back();
38    delete mList;
39}
40
41std::string Seq::getName()
42{
43    if (mType == Seq::Byte)
44    {
45        std::string name = "Seq";
46
47        std::list<RE*> re_list;
48        std::list<RE*>::iterator it = mList->begin();
49
50        for (it = mList->begin(); it != mList->end(); ++it)
51        {
52            if (CC* seq_cc = dynamic_cast<CC*>(*it))
53            {
54                name += seq_cc->getName();
55            }
56            else if (Name* seq_name = dynamic_cast<Name*>(*it))
57            {
58                name += seq_name->getName();
59            }
60            else
61            {
62                return "Bad Byte Sequence!";
63            }
64        }
65
66        return name;
67    }
68    else
69    {
70        return "Unnamed Sequence";
71    }
72}
73
74std::list<RE*>* Seq::GetREList()
75{
76    return mList;
77}
78
79void Seq::AddREListItem(RE *re)
80{
81    mList->push_back(re);
82}
83
84Seq::Type Seq::getType()
85{
86    return mType;
87}
88
89void Seq::setType(Seq::Type type)
90{
91    mType = type;
92}
Note: See TracBrowser for help on using the repository browser.