NCBI C++ ToolKit
sequtil_convert.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: sequtil_convert.cpp 64228 2014-08-26 20:15:25Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Mati Shomrat
27  *
28  * File Description:
29  * Sequence conversion utility.
30  */
31 #include <ncbi_pch.hpp>
32 #include <corelib/ncbistd.hpp>
33 #include <corelib/ncbistr.hpp>
34 #include <vector>
35 
37 #include "sequtil_convert_imp.hpp"
38 
39 
41 
42 
43 // -- Conversion methods
44 
45 // string to string
47 (const CTempString& src,
48  TCoding src_coding,
49  TSeqPos pos,
50  TSeqPos length,
51  string& dst,
52  TCoding dst_coding)
53 {
54  return CSeqConvert_imp::Convert(src, src_coding,
55  pos, length,
56  dst, dst_coding);
57 }
58 
59 
60 // string to vector
62 (const string& src,
63  TCoding src_coding,
64  TSeqPos pos,
65  TSeqPos length,
66  vector< char >& dst,
67  TCoding dst_coding)
68 {
69  return CSeqConvert_imp::Convert(src, src_coding,
70  pos, length,
71  dst, dst_coding);
72 }
73 
74 
75 // vector to string
77 (const vector< char >& src,
78  TCoding src_coding,
79  TSeqPos pos,
80  TSeqPos length,
81  string& dst,
82  TCoding dst_coding)
83 {
84  return CSeqConvert_imp::Convert(src, src_coding,
85  pos, length,
86  dst, dst_coding);
87 }
88 
89 
90 // vector to vector
92 (const vector< char >& src,
93  TCoding src_coding,
94  TSeqPos pos,
95  TSeqPos length,
96  vector< char >& dst,
97  TCoding dst_coding)
98 {
99  return CSeqConvert_imp::Convert(src, src_coding,
100  pos, length,
101  dst, dst_coding);
102 }
103 
104 // char* to char*
106 (const char src[],
107  TCoding src_coding,
108  TSeqPos pos,
109  TSeqPos length,
110  char dst[],
111  TCoding dst_coding)
112 {
113  return CSeqConvert_imp::Convert(src, src_coding,
114  pos, length,
115  dst, dst_coding);
116 }
117 
118 
119 // -- Get part of a sequence (same coding conversion)
120 
122 (const string& src,
123  TCoding coding,
124  TSeqPos pos,
125  TSeqPos length,
126  string& dst)
127 {
128  return CSeqConvert_imp::Subseq(src, coding, pos, length, dst);
129 }
130 
131 
133 (const string& src,
134  TCoding coding,
135  TSeqPos pos,
136  TSeqPos length,
137  vector<char>& dst)
138 {
139  return CSeqConvert_imp::Subseq(src, coding, pos, length, dst);
140 }
141 
142 
144 (const vector<char>& src,
145  TCoding coding,
146  TSeqPos pos,
147  TSeqPos length,
148  string& dst)
149 {
150  return CSeqConvert_imp::Subseq(src, coding, pos, length, dst);
151 }
152 
153 
155 (const vector<char>& src,
156  TCoding coding,
157  TSeqPos pos,
158  TSeqPos length,
159  vector<char>& dst)
160 {
161  return CSeqConvert_imp::Subseq(src, coding, pos, length, dst);
162 }
163 
164 
166 (const char* src,
167  TCoding coding,
168  TSeqPos pos,
169  TSeqPos length,
170  char* dst)
171 {
172  return CSeqConvert_imp::Subseq(src, coding, pos, length, dst);
173 }
174 
175 
176 // -- Packing
177 
179 (const string& src,
180  TCoding src_coding,
181  vector<char>& dst,
182  TCoding& dst_coding,
183  TSeqPos length)
184 {
185  return CSeqConvert_imp::Pack(src, src_coding, dst, dst_coding, length);
186 }
187 
188 
190 (const vector<char>& src,
191  TCoding src_coding,
192  vector<char>& dst,
193  TCoding& dst_coding,
194  TSeqPos length)
195 {
196  return CSeqConvert_imp::Pack(src, src_coding, dst, dst_coding, length);
197 }
198 
200 (const char* src,
201  TSeqPos length,
202  TCoding src_coding,
203  char* dst,
204  TCoding& dst_coding)
205 {
206  return CSeqConvert_imp::Pack(src, length, src_coding, dst, dst_coding);
207 }
208 
209 
210 SIZE_TYPE CSeqConvert::Pack(const string& src, TCoding src_coding,
211  IPackTarget& dst, TSeqPos length)
212 {
213  return CSeqConvert_imp::Pack(src, src_coding, dst, length);
214 }
215 
216 SIZE_TYPE CSeqConvert::Pack(const vector<char>& src, TCoding src_coding,
217  IPackTarget& dst, TSeqPos length)
218 {
219  return CSeqConvert_imp::Pack(src, src_coding, dst, length);
220 }
221 
222 SIZE_TYPE CSeqConvert::Pack(const char* src, TSeqPos length, TCoding src_coding,
223  IPackTarget& dst)
224 {
225  return CSeqConvert_imp::Pack(src, length, src_coding, dst);
226 }
227 
228 
static SIZE_TYPE Subseq(const SrcCont &src, TCoding coding, TSeqPos pos, TSeqPos length, DstCont &dst)
static SIZE_TYPE Convert(const SrcCont &src, TCoding src_coding, TSeqPos pos, TSeqPos length, DstCont &dst, TCoding dst_coding)
static SIZE_TYPE Pack(const SrcCont &src, TCoding src_coding, DstCont &dst, TCoding &dst_coding, TSeqPos length)
static SIZE_TYPE Pack(const string &src, TCoding src_coding, vector< char > &dst, TCoding &dst_coding, TSeqPos length=ncbi::numeric_limits< TSeqPos >::max())
static SIZE_TYPE Subseq(const string &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst)
static SIZE_TYPE Convert(const CTempString &src, TCoding src_coding, TSeqPos pos, TSeqPos length, string &dst, TCoding dst_coding)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
Include a standard set of the NCBI C++ Toolkit most basic headers.
The NCBI C++ standard methods for dealing with std::string.
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
Modified on Fri Sep 20 14:57:35 2024 by modify_doxy.py rev. 669887