1 /* $Id: nst_metadata_options.cpp 456088 2015-01-07 19:36:27Z satskyse $
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 * Authors: Sergey Satskiy
27 *
28 * File Description: Metadata options
29 */
30
31
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34
35 #include "nst_metadata_options.hpp"
36
37
38 BEGIN_NCBI_SCOPE
39
40
41 struct MetadataOptionToId
42 {
43 enum EMetadataOption option;
44 string id;
45 };
46
47
48 const MetadataOptionToId metadataOptionToIdMap[] = {
49 { eMetadataNotSpecified, "not set" },
50 { eMetadataRequired, "required" },
51 { eMetadataDisabled, "disabled" },
52 { eMetadataMonitoring, "monitoring" }
53 };
54
55 const size_t metadataOptionToIdMapSize = sizeof(metadataOptionToIdMap) /
56 sizeof(MetadataOptionToId);
57
58
59
g_IdToMetadataOption(const string & option_id)60 enum EMetadataOption g_IdToMetadataOption(const string & option_id)
61 {
62 for (size_t k = 0; k < metadataOptionToIdMapSize; ++k) {
63 if (NStr::CompareNocase(option_id, metadataOptionToIdMap[k].id) == 0)
64 return metadataOptionToIdMap[k].option;
65 }
66 return eMetadataUnknown;
67 }
68
69
g_MetadataOptionToId(enum EMetadataOption option)70 string g_MetadataOptionToId(enum EMetadataOption option)
71 {
72 for (size_t k = 0; k < metadataOptionToIdMapSize; ++k) {
73 if (metadataOptionToIdMap[k].option == option)
74 return metadataOptionToIdMap[k].id;
75 }
76 return "unknown";
77 }
78
79
g_GetSupportedMetadataOptions(void)80 vector<string> g_GetSupportedMetadataOptions(void)
81 {
82 vector<string> result;
83 for (size_t k = 0; k < metadataOptionToIdMapSize; ++k)
84 result.push_back(metadataOptionToIdMap[k].id);
85 return result;
86 }
87
88 END_NCBI_SCOPE
89
90
91