Fresco/Fresco-C++-demos/src Makefile.in,1.19,1.20 pinyin_demo.cc,1.16,1.17

Neil John Pilgrim <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Fresco-C++-demos/src
In directory purcel:/tmp/cvs-serv9791/Fresco-C++-demos/src

Modified Files:
	Makefile.in pinyin_demo.cc 
Log Message:
Factor code from server.cc into RCManager, to enable use across all Berlin binaries. Modify pinyin demo to not use RCManager (for now) - its a Berlin library, not something that clients should use.


Index: Makefile.in
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-C++-demos/src/Makefile.in,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- Makefile.in	6 Apr 2003 16:15:51 -0000	1.19
+++ Makefile.in	14 Apr 2003 00:25:06 -0000	1.20
@@ -32,6 +32,9 @@
 # -stefan
 LIBS		:= -lBerlin $(LIBS)
 
+# Inserted for pinyin-db default path -neiljp
+CPPFLAGS        += -DDATADIR='"$(DESTDIR)$(datadir)/Fresco-demos"'
+
 DEMO_SRC	:= Application.cc LayoutDemo.cc TextDemo.cc \
 		   EditTextDemo.cc RasterDemo.cc TransformDemo.cc \
 		   ColorDemo.cc LogoDemo.cc FocusDemo.cc \
@@ -81,8 +84,8 @@
 	@for target in $(TARGETS); do \
 	  $(SHTOOL) install -C -m 755 ../bin/$$target $(DESTDIR)$(bindir); \
 	done
-	$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(datadir)/Berlin
-	$(SHTOOL) install -C -m 644 $(top_srcdir)/share/pinyin.db $(DESTDIR)$(datadir)/Berlin
+	$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(datadir)/Fresco-demos
+	$(SHTOOL) install -C -m 644 $(top_srcdir)/share/pinyin.db $(DESTDIR)$(datadir)/Fresco-demos
 
 uninstall:
 	for target in $(TARGETS) ; do

Index: pinyin_demo.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-C++-demos/src/pinyin_demo.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- pinyin_demo.cc	11 Apr 2003 00:09:35 -0000	1.16
+++ pinyin_demo.cc	14 Apr 2003 00:25:06 -0000	1.17
@@ -47,9 +47,14 @@
 
 #include <Fresco/TextBuffer.hh>
 #include <Babylon/Babylon.hh>
-#include <Prague/Sys/Path.hh>
-#include <Prague/Sys/GetOpt.hh>
-#include <Berlin/RCManager.hh>
+
+#ifdef DATADIR
+const std::string data_dir = DATADIR;
+#else
+const std::string data_dir = "";
+#endif
+
+static std::string pinyin_db_file;
 
 class InputObserver : public ObserverImpl {
 public:
@@ -59,9 +64,7 @@
 					      select(s),
 					      output(o) {
 	// get the path of the Memorymap we need from the RCManager
-	Prague::Path path = RCManager::get_path("pinyindbpath");
-	std::string pinyinDB = path.lookup_file("pinyin.db");
-	converter = new TextConverter(pinyinDB);
+	converter = new TextConverter(pinyin_db_file);
     }
 	
 
@@ -133,8 +136,8 @@
     // Parse args:
     Prague::GetOpt getopt(argv[0], "a simple pinyin input application.");
     getopt.add('h', "help", Prague::GetOpt::novalue, "help text");
-    getopt.add('r', "resource", Prague::GetOpt::mandatory,
-	       "the resource file to load");
+    getopt.add('p', "pinyin-db-path", Prague::GetOpt::mandatory,
+	       "path to the pinyin database file to load");
     add_resolving_options_to_getopt(getopt);
     size_t argo = getopt.parse(argc, argv);
     argc -= argo;
@@ -146,17 +149,12 @@
       return 0;
     }
 
-    std::string value;
-    if (!getopt.get("resource", &value))
-    {
-      std::cerr << "ERROR: Must specify --resource option" << std::endl;
-      getopt.usage();
-      return 1;
-    }
-    else
-    {
-      RCManager::read(Prague::Path::expand_user(value));
-    }
+    // find the pinyin database
+    std::string pinyin_path;
+    getopt.get("pinyin-db-path", &pinyin_path);
+    if (pinyin_path=="") pinyin_path = data_dir;
+    Prague::Path path(pinyin_path);
+    pinyin_db_file = path.lookup_file("pinyin.db");
 
     // do the real work:
     CORBA::ORB_var orb;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.