Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

oxp_parse_seqname.cxx

Go to the documentation of this file.
00001 // This is oxl/oxp/oxp_parse_seqname.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 
00006 #include "oxp_parse_seqname.h"
00007 
00008 #include <vcl_cstring.h>
00009 #include <vcl_cstdlib.h> // atoi()
00010 #include <vcl_iostream.h>
00011 
00012 #include <vul/vul_reg_exp.h>
00013 
00014 // Default ctor
00015 oxp_parse_seqname::oxp_parse_seqname(char const* s)
00016 {
00017   parse(s);
00018 }
00019 
00020 // Copy ctor
00021 oxp_parse_seqname::oxp_parse_seqname(vcl_string const& s)
00022 {
00023   parse(s.c_str());
00024 }
00025 
00026 // Assignment
00027 void oxp_parse_seqname::parse(char const* s)
00028 {
00029   start_ = -1;
00030   step_ = -1;
00031   end_ = -1;
00032 
00033   // First match any trailing ",n[:n]:[n]" (can use ; or ,)
00034   filename_ = s;
00035   vul_reg_exp re("[,;]([0-9]+)(:[0-9]+)?:([0-9]+)?$");
00036   if (re.find(s)) {
00037     vcl_string match_start = re.match(1);
00038     vcl_string match_step = re.match(2);
00039     vcl_string match_end = re.match(3);
00040 
00041     int last = re.start(0);
00042     filename_ = filename_.substr(0,last);
00043 
00044     vcl_cerr << "oxp_parse_seqname: " << filename_ << " [" << match_start
00045              << ':' << match_step.c_str()+1 << ':' << match_end << "]  -> ";
00046 
00047     if (match_start.length() > 0)
00048       start_ = vcl_atoi(match_start.c_str());
00049 
00050     if (match_step.length() > 0)
00051       step_ = vcl_atoi(match_step.c_str()+1);
00052 
00053     if (match_end.length() > 0)
00054       end_ = vcl_atoi(match_end.c_str());
00055 
00056     vcl_cerr << '[' << start_ << ':' << step_ << ':' << end_ << "]\n";
00057 
00058   } else if (vcl_strchr(s, ','))
00059     vcl_cerr << "oxp_parse_seqname: Warning: \"" << s << "\" contains a comma, but didn't match my regexp.\n";
00060 }

Generated on Thu Jan 10 14:46:06 2008 for contrib/oxl/oxp by  doxygen 1.4.4