1 /*
2  * Copyright 2017, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "word_stream.h"
18 
19 #include "file_utils.h"
20 #include "word_stream_impl.h"
21 
22 namespace android {
23 namespace spirit {
24 
Create()25 InputWordStream *InputWordStream::Create() { return new WordStreamImpl(); }
26 
Create(std::vector<uint32_t> && words)27 InputWordStream *InputWordStream::Create(std::vector<uint32_t> &&words) {
28   return new WordStreamImpl(words);
29 }
30 
Create(const std::vector<uint32_t> & words)31 InputWordStream *InputWordStream::Create(const std::vector<uint32_t> &words) {
32   return new WordStreamImpl(words);
33 }
34 
Create(const std::vector<uint8_t> & bytes)35 InputWordStream *InputWordStream::Create(const std::vector<uint8_t> &bytes) {
36   std::vector<uint32_t> words((uint32_t *)bytes.data(),
37                               (uint32_t *)(bytes.data() + bytes.size()));
38   return InputWordStream::Create(words);
39 }
40 
Create(const char * filePath)41 InputWordStream *InputWordStream::Create(const char *filePath) {
42   return InputWordStream::Create(readFile<uint32_t>(filePath));
43 }
44 
Create()45 OutputWordStream *OutputWordStream::Create() { return new WordStreamImpl(); }
46 
Create()47 WordStream *WordStream::Create() { return new WordStreamImpl(); }
48 
Create(const std::vector<uint32_t> & words)49 WordStream *WordStream::Create(const std::vector<uint32_t> &words) {
50   return new WordStreamImpl(words);
51 }
52 
53 } // namespace spirit
54 } // namespace android
55