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

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

The parser is now able to parse unicode categories.

File size: 1.6 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
57            {
58                return "Bad Byte Sequence!";
59            }
60        }
61
62        return name;
63    }
64    else
65    {
66        return "Unnamed Sequence";
67    }
68}
69
70std::list<RE*>* Seq::GetREList()
71{
72    return mList;
73}
74
75void Seq::AddREListItem(RE *re)
76{
77    mList->push_back(re);
78}
79
80Seq::Type Seq::getType()
81{
82    return mType;
83}
84
85void Seq::setType(Seq::Type type)
86{
87    mType = type;
88}
Note: See TracBrowser for help on using the repository browser.