• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

test-tsconfig.cc

Go to the documentation of this file.
00001 /** @file
00002     @section license License
00003 
00004     Licensed to the Apache Software Foundation (ASF) under one
00005     or more contributor license agreements.  See the NOTICE file
00006     distributed with this work for additional information
00007     regarding copyright ownership.  The ASF licenses this file
00008     to you under the Apache License, Version 2.0 (the
00009     "License"); you may not use this file except in compliance
00010     with the License.  You may obtain a copy of the License at
00011 
00012     http://www.apache.org/licenses/LICENSE-2.0
00013 
00014     Unless required by applicable law or agreed to in writing, software
00015     distributed under the License is distributed on an "AS IS" BASIS,
00016     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017     See the License for the specific language governing permissions and
00018     limitations under the License.
00019 */
00020 
00021 # include "tsconfig/TsValue.h"
00022 # include <stdio.h>
00023 # include <iostream>
00024 
00025 using ts::config::Configuration;
00026 using ts::config::Value;
00027 
00028 inline std::ostream& operator << ( std::ostream& s, ts::ConstBuffer const& b ) {
00029   if (b._ptr) s.write(b._ptr, b._size);
00030   else s << b._size;
00031   return s;
00032 }
00033 
00034 int main(int /* argc ATS_UNUSED */, char **/* argv ATS_UNUSED */) {
00035   printf("Testing TsConfig\n");
00036   ts::Rv<Configuration> cv = Configuration::loadFromPath("test-1.tsconfig");
00037   if (cv.isOK()) {
00038     Value v = cv.result().find("thing-1.name");
00039     if (v) {
00040       std::cout << "thing-1.name = " << v.getText() << std::endl;
00041     } else {
00042       std::cout << "Failed to find 'name' in 'thing-1'" << std::endl;
00043     }
00044   } else {
00045     std::cout << "Load failed" << std::endl
00046               << cv.errata()
00047       ;
00048   }
00049 }

Generated by  doxygen 1.7.1